async_snmp/handler/
mod.rs

1//! Handler types and traits for SNMP MIB operations.
2//!
3//! This module provides the interface for implementing SNMP handlers:
4//!
5//! - [`MibHandler`] - Trait for handling GET, GETNEXT, and SET operations
6//! - [`RequestContext`] - Information about the incoming request
7//! - [`GetResult`], [`GetNextResult`], [`SetResult`] - Operation results
8//! - [`OidTable`] - Helper for implementing GETNEXT with sorted OID storage
9//!
10//! # Example
11//!
12//! ```rust
13//! use async_snmp::handler::{MibHandler, RequestContext, GetResult, GetNextResult, BoxFuture};
14//! use async_snmp::{Oid, Value, VarBind, oid};
15//!
16//! struct MyHandler;
17//!
18//! impl MibHandler for MyHandler {
19//!     fn get<'a>(&'a self, _ctx: &'a RequestContext, oid: &'a Oid) -> BoxFuture<'a, GetResult> {
20//!         Box::pin(async move {
21//!             if oid == &oid!(1, 3, 6, 1, 4, 1, 99999, 1, 0) {
22//!                 return GetResult::Value(Value::Integer(42));
23//!             }
24//!             GetResult::NoSuchObject
25//!         })
26//!     }
27//!
28//!     fn get_next<'a>(&'a self, _ctx: &'a RequestContext, oid: &'a Oid) -> BoxFuture<'a, GetNextResult> {
29//!         Box::pin(async move {
30//!             let my_oid = oid!(1, 3, 6, 1, 4, 1, 99999, 1, 0);
31//!             if oid < &my_oid {
32//!                 return GetNextResult::Value(VarBind::new(my_oid, Value::Integer(42)));
33//!             }
34//!             GetNextResult::EndOfMibView
35//!         })
36//!     }
37//! }
38//! ```
39
40mod context;
41mod oid_table;
42mod results;
43mod traits;
44
45pub use context::RequestContext;
46pub use oid_table::OidTable;
47pub use results::{GetNextResult, GetResult, Response, SetResult};
48pub use traits::{BoxFuture, MibHandler};
49
50// Re-export SecurityModel from agent::vacm for convenience
51pub use crate::agent::vacm::SecurityModel;