#[non_exhaustive]pub enum Error {
Network {
target: SocketAddr,
source: Error,
},
Timeout {
target: SocketAddr,
elapsed: Duration,
retries: u32,
},
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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Network
Network failure (connection refused, unreachable, etc.)
Timeout
Request timed out after retries.
Snmp
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)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Auto Trait Implementations§
impl Freeze for Error
impl !RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl !UnwindSafe 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
Mutably borrows from an owned value. Read more