Expand description
Handler types and traits for SNMP MIB operations.
This module provides the interface for implementing SNMP handlers:
MibHandler- Trait for handling GET, GETNEXT, and SET operationsRequestContext- Information about the incoming requestGetResult,GetNextResult,SetResult- Operation resultsOidTable- Helper for implementing GETNEXT with sorted OID storage
§Example
use async_snmp::handler::{MibHandler, RequestContext, GetResult, GetNextResult, BoxFuture};
use async_snmp::{Oid, Value, VarBind, oid};
struct MyHandler;
impl MibHandler for MyHandler {
fn get<'a>(&'a self, _ctx: &'a RequestContext, oid: &'a Oid) -> BoxFuture<'a, GetResult> {
Box::pin(async move {
if oid == &oid!(1, 3, 6, 1, 4, 1, 99999, 1, 0) {
return GetResult::Value(Value::Integer(42));
}
GetResult::NoSuchObject
})
}
fn get_next<'a>(&'a self, _ctx: &'a RequestContext, oid: &'a Oid) -> BoxFuture<'a, GetNextResult> {
Box::pin(async move {
let my_oid = oid!(1, 3, 6, 1, 4, 1, 99999, 1, 0);
if oid < &my_oid {
return GetNextResult::Value(VarBind::new(my_oid, Value::Integer(42)));
}
GetNextResult::EndOfMibView
})
}
}Re-exports§
pub use crate::agent::vacm::SecurityModel;
Structs§
- OidTable
- Helper for implementing GETNEXT with lexicographic OID ordering.
- Request
Context - Request context passed to MIB handlers.
- Response
- Response to return from a handler.
Enums§
- GetNext
Result - Result of a GETNEXT operation.
- GetResult
- Result of a GET operation on a specific OID.
- SetResult
- Result of a SET operation phase.
Traits§
- MibHandler
- Handler for SNMP MIB operations.
Type Aliases§
- BoxFuture
- Type alias for boxed async return type (dyn-compatible).