pub enum GetNextResult {
Value(VarBind),
EndOfMibView,
}Expand description
Result of a GETNEXT operation (RFC 3416).
GETNEXT retrieves the lexicographically next OID after the requested one. This is the foundation of SNMP walking (iterating through MIB subtrees) and is also used internally by GETBULK.
§Version Differences
- SNMPv1:
EndOfMibViewresults in anoSuchNameerror response - SNMPv2c/v3: Returns the
endOfMibViewexception value in the response
§Lexicographic Ordering
OIDs are compared arc-by-arc as unsigned integers:
1.3.6.1.2<1.3.6.1.2.1(shorter is less than longer with same prefix)1.3.6.1.2.1<1.3.6.1.3(compare at first differing arc)1.3.6.1.10>1.3.6.1.9(numeric comparison, not lexicographic string)
§Example
use async_snmp::handler::GetNextResult;
use async_snmp::{Value, VarBind, Oid, oid};
struct SimpleTable {
oids: Vec<(Oid, Value)>, // Must be sorted!
}
impl SimpleTable {
fn get_next(&self, after: &Oid) -> GetNextResult {
// Find first OID that is strictly greater than 'after'
for (oid, value) in &self.oids {
if oid > after {
return GetNextResult::Value(VarBind::new(oid.clone(), value.clone()));
}
}
GetNextResult::EndOfMibView
}
}
let table = SimpleTable {
oids: vec![
(oid!(1, 3, 6, 1, 2, 1, 1, 1, 0), Value::OctetString("sysDescr".into())),
(oid!(1, 3, 6, 1, 2, 1, 1, 3, 0), Value::TimeTicks(12345)),
],
};
// Before first OID - returns first
let result = table.get_next(&oid!(1, 3, 6, 1, 2, 1, 1, 0));
assert!(result.is_value());
// After last OID - returns EndOfMibView
let result = table.get_next(&oid!(1, 3, 6, 1, 2, 1, 1, 3, 0));
assert!(result.is_end_of_mib_view());Variants§
Value(VarBind)
The next OID/value pair in the MIB tree.
The returned OID must be strictly greater than the input OID.
EndOfMibView
No more OIDs after the given one (end of MIB view).
Return this when the requested OID is at or past the last OID in your handler’s subtree.
Implementations§
Source§impl GetNextResult
impl GetNextResult
Sourcepub fn from_option(value: Option<VarBind>) -> Self
pub fn from_option(value: Option<VarBind>) -> Self
Create a GetNextResult from an Option<VarBind>.
This is a convenience method for migrating from the previous
Option<VarBind> interface. None is treated as EndOfMibView.
Sourcepub fn is_end_of_mib_view(&self) -> bool
pub fn is_end_of_mib_view(&self) -> bool
Returns true if this is end of MIB view.
Sourcepub fn into_option(self) -> Option<VarBind>
pub fn into_option(self) -> Option<VarBind>
Converts to an Option<VarBind>.
Trait Implementations§
Source§impl Clone for GetNextResult
impl Clone for GetNextResult
Source§fn clone(&self) -> GetNextResult
fn clone(&self) -> GetNextResult
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more