Module error

Module error 

Source
Expand description

Error types for async-snmp.

This module provides:

  • Error - The main error type (8 variants covering all failure modes)
  • ErrorStatus - SNMP protocol errors returned by agents (RFC 3416)
  • WalkAbortReason - Reasons a walk operation was aborted

§Error Handling

Errors are boxed for efficiency: Result<T> = Result<T, Box<Error>>.

use async_snmp::{Error, Result};

fn handle_error(result: Result<()>) {
    match result {
        Ok(()) => println!("Success"),
        Err(e) => match &*e {
            Error::Timeout { target, retries, .. } => {
                println!("{} unreachable after {} retries", target, retries);
            }
            Error::Auth { target } => {
                println!("Authentication failed for {}", target);
            }
            _ => println!("Error: {}", e),
        }
    }
}

Enums§

Error
The main error type for all async-snmp operations.
ErrorStatus
SNMP protocol error status codes (RFC 3416).
WalkAbortReason
Reason a walk operation was aborted.

Type Aliases§

Result
Result type alias using the library’s boxed Error type.