#[non_exhaustive]pub enum Error {
Network {
target: SocketAddr,
source: Error,
},
Timeout {
target: SocketAddr,
elapsed: Duration,
retries: u32,
},
Closed {
target: SocketAddr,
},
Snmp {
target: SocketAddr,
status: ErrorStatus,
index: u32,
oid: Option<Oid>,
},
Auth {
target: SocketAddr,
},
MalformedResponse {
target: SocketAddr,
},
WalkAborted {
target: SocketAddr,
reason: WalkAbortReason,
},
Config(Box<str>),
InvalidOid(Box<str>),
}Expand description
The main error type for all async-snmp operations.
This enum covers all possible error conditions including network issues, protocol errors, authentication failures, and configuration problems.
Errors are boxed (via Result) to keep the size small on the stack.
§Common Patterns
§Checking Error Type
Use pattern matching to handle specific error conditions:
use async_snmp::{Error, ErrorStatus};
fn is_retriable(error: &Error) -> bool {
matches!(error,
Error::Timeout { .. } |
Error::Network { .. }
)
}
fn is_access_error(error: &Error) -> bool {
matches!(error,
Error::Snmp { status: ErrorStatus::NoAccess | ErrorStatus::AuthorizationError, .. } |
Error::Auth { .. }
)
}Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Network
Network failure (connection refused, unreachable, etc.)
Timeout
Request timed out after retries.
Closed
Transport was shut down while a request was pending.
Not retriable: the transport will never deliver a response again. Recovery requires creating a new transport.
Fields
target: SocketAddrSnmp
SNMP protocol error from agent.
Auth
Authentication/authorization failed.
Fields
target: SocketAddrMalformedResponse
Malformed response from agent.
Fields
target: SocketAddrWalkAborted
Walk aborted due to agent misbehavior.
Config(Box<str>)
Invalid configuration.
InvalidOid(Box<str>)
Invalid OID format.
Implementations§
Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Auto Trait Implementations§
impl !RefUnwindSafe for Error
impl !UnwindSafe for Error
impl Freeze for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Error
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more