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 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more