#[non_exhaustive]pub enum Value {
}Expand description
SNMP value.
Represents all SNMP data types including SMIv2 types and exception values.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Integer(i32)
INTEGER (ASN.1 primitive, signed 32-bit)
OctetString(Bytes)
OCTET STRING (arbitrary bytes).
Per RFC 2578 (SMIv2), OCTET STRING values have a maximum size of 65535 octets. This limit is not enforced during decoding to maintain permissive parsing behavior. Applications that require strict compliance should validate size after decoding.
Null
NULL
ObjectIdentifier(Oid)
OBJECT IDENTIFIER
IpAddress([u8; 4])
IpAddress (4 bytes, big-endian)
Counter32(u32)
Counter32 (unsigned 32-bit, wrapping)
Gauge32(u32)
Gauge32 / Unsigned32 (unsigned 32-bit, non-wrapping)
TimeTicks(u32)
TimeTicks (hundredths of seconds since epoch)
Opaque(Bytes)
Opaque (legacy, arbitrary bytes)
Counter64(u64)
Counter64 (unsigned 64-bit, wrapping).
SNMPv2c/v3 only. Counter64 was introduced in SNMPv2 (RFC 2578) and is not supported in SNMPv1. When sending Counter64 values to an SNMPv1 agent, the value will be silently ignored or cause an error depending on the agent implementation.
If your application needs to support SNMPv1, avoid using Counter64 or fall back to Counter32 (with potential overflow for high-bandwidth counters).
NoSuchObject
noSuchObject exception - OID exists but no value
NoSuchInstance
noSuchInstance exception - Instance doesn’t exist
EndOfMibView
endOfMibView exception - End of MIB reached during walk
Unknown
Unknown/unrecognized value type (for forward compatibility)
Implementations§
Source§impl Value
impl Value
Sourcepub fn is_exception(&self) -> bool
pub fn is_exception(&self) -> bool
Check if this is an exception value.
Sourcepub fn format_with_hint(&self, hint: &str) -> Option<String>
pub fn format_with_hint(&self, hint: &str) -> Option<String>
Format an OctetString or Opaque value using RFC 2579 DISPLAY-HINT.
Returns None if this is not an OctetString or Opaque value.
On invalid hint syntax, falls back to hex encoding.
§Example
use async_snmp::Value;
use bytes::Bytes;
let mac = Value::OctetString(Bytes::from_static(&[0x00, 0x1a, 0x2b, 0x3c, 0x4d, 0x5e]));
assert_eq!(mac.format_with_hint("1x:"), Some("00:1a:2b:3c:4d:5e".into()));
let integer = Value::Integer(42);
assert_eq!(integer.format_with_hint("1d"), None);