pub enum GetNextResult {
Value(VarBind),
EndOfMibView,
}Available on crate feature
agent only.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
Trait Implementations§
Source§impl Clone for GetNextResult
impl Clone for GetNextResult
Source§fn clone(&self) -> GetNextResult
fn clone(&self) -> GetNextResult
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for GetNextResult
impl Debug for GetNextResult
Source§impl From<VarBind> for GetNextResult
impl From<VarBind> for GetNextResult
Source§impl PartialEq for GetNextResult
impl PartialEq for GetNextResult
impl StructuralPartialEq for GetNextResult
Auto Trait Implementations§
impl !Freeze for GetNextResult
impl RefUnwindSafe for GetNextResult
impl Send for GetNextResult
impl Sync for GetNextResult
impl Unpin for GetNextResult
impl UnsafeUnpin for GetNextResult
impl UnwindSafe for GetNextResult
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