Struct csnmp::oid::ObjectIdentifier
source · pub struct ObjectIdentifier { /* private fields */ }
Expand description
An SNMP object identifier.
Equivalent to an ASN.1 object identifier, except limited to maximum MAX_SUB_IDENTIFIER_COUNT
sub-identifiers of a value of up to 2**32-1.
Implementations§
source§impl ObjectIdentifier
impl ObjectIdentifier
sourcepub const fn new(length: usize, sub_identifiers: [u32; 128]) -> Self
pub const fn new(length: usize, sub_identifiers: [u32; 128]) -> Self
Makes a new object identifier.
sub_identifiers
elements at index >= length
must all be 0. Panics if this is not the
case.
You probably want to use the functions of the TryFrom<&[u32]>
implementation instead.
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the length of this object identifier. Guaranteed to be at least 0 and less than
MAX_SUB_IDENTIFIER_COUNT
.
sourcepub fn get(&self, index: usize) -> Option<u32>
pub fn get(&self, index: usize) -> Option<u32>
Obtains the sub-identifier at the given index, or None
if the index is out of bounds.
sourcepub fn as_slice(&self) -> &[u32]
pub fn as_slice(&self) -> &[u32]
Returns this object identifier als a slice of unsigned 32-bit integers.
sourcepub fn parent(&self) -> Option<Self>
pub fn parent(&self) -> Option<Self>
Returns the parent of this object identifier, or None
if it has no parent.
sourcepub fn child(&self, sub_id: u32) -> Option<Self>
pub fn child(&self, sub_id: u32) -> Option<Self>
Returns a child of this object identifier constructed by appending the given sub_id
,
or None
if that would create an object identifier that is too long.
sourcepub fn is_prefix_of_or_equal(&self, other: &Self) -> bool
pub fn is_prefix_of_or_equal(&self, other: &Self) -> bool
Returns whether this object identifier is a prefix of another object identifier or equal to it.
sourcepub fn is_prefix_of(&self, other: &Self) -> bool
pub fn is_prefix_of(&self, other: &Self) -> bool
Returns whether this object identifier is a prefix of another object identifier. Returns
false
if the object identifiers are equal.
sourcepub fn relative_to(&self, base: &Self) -> Option<Self>
pub fn relative_to(&self, base: &Self) -> Option<Self>
Returns this object identifier relative to the given base
object identifier. Returns
None
if base
is not a prefix of or equal to this object identifier.
Trait Implementations§
source§impl Clone for ObjectIdentifier
impl Clone for ObjectIdentifier
source§fn clone(&self) -> ObjectIdentifier
fn clone(&self) -> ObjectIdentifier
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ObjectIdentifier
impl Debug for ObjectIdentifier
source§impl Default for ObjectIdentifier
impl Default for ObjectIdentifier
source§impl Display for ObjectIdentifier
impl Display for ObjectIdentifier
source§impl FromStr for ObjectIdentifier
impl FromStr for ObjectIdentifier
source§impl Hash for ObjectIdentifier
impl Hash for ObjectIdentifier
source§impl Ord for ObjectIdentifier
impl Ord for ObjectIdentifier
source§impl PartialEq for ObjectIdentifier
impl PartialEq for ObjectIdentifier
source§fn eq(&self, other: &ObjectIdentifier) -> bool
fn eq(&self, other: &ObjectIdentifier) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for ObjectIdentifier
impl PartialOrd for ObjectIdentifier
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more