[][src]Struct snmp_mp::VarBind

pub struct VarBind { /* fields omitted */ }

Represents a variable binding.

Examples

use snmp_mp::{ObjectIdent, VarBind, VarValue};

let name = ObjectIdent::from_slice(&[0x01, 0x03, 0x06, 0x01, 0x02, 0x01, 0x01, 0x01, 0x00]);
let var_bind = VarBind::new(name);
assert_eq!(var_bind.value(), &VarValue::Unspecified);

Implementations

impl VarBind[src]

pub fn new(name: ObjectIdent) -> Self[src]

Constructs a new VarBind with the passed ObjectIdent and a value of VarValue::Unspecified.

Examples

let name = ObjectIdent::from_slice(&[0x01, 0x03, 0x06, 0x01, 0x02, 0x01, 0x01, 0x01, 0x00]);
let var_bind = VarBind::new(name);
assert_eq!(var_bind.value(), &VarValue::Unspecified);

pub fn with_value(name: ObjectIdent, value: VarValue) -> Self[src]

Constructs a new VarBind with the passed ObjectIdent and VarValue.

Examples

let name = ObjectIdent::from_slice(&[0x01, 0x03, 0x06, 0x01, 0x02, 0x01, 0x01, 0x01, 0x00]);
let value = VarValue::String(b"System description".to_vec());
let var_bind = VarBind::with_value(name, value);
assert_eq!(var_bind.value(), &VarValue::String(b"System description".to_vec()));

pub fn name(&self) -> &ObjectIdent[src]

Returns the variable name.

Examples

let name = ObjectIdent::from_slice(&[0x01, 0x03, 0x06, 0x01, 0x02, 0x01, 0x01, 0x01, 0x00]);
let var_bind = VarBind::new(name.clone());
assert_eq!(var_bind.name(), &name);

pub fn set_name(&mut self, name: ObjectIdent) -> &mut Self[src]

Sets the variable name.

Examples

let name = ObjectIdent::from_slice(&[0x01, 0x03, 0x06, 0x01, 0x02, 0x01, 0x01, 0x01, 0x00]);
let mut var_bind = VarBind::new(name);
let new_name = ObjectIdent::from_slice(&[0x01, 0x03, 0x06, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01]);
var_bind.set_name(new_name.clone());

assert_eq!(var_bind.name(), &new_name);

pub fn value(&self) -> &VarValue[src]

Returns the variable value.

Examples

let name = ObjectIdent::from_slice(&[0x01, 0x03, 0x06, 0x01, 0x02, 0x01, 0x01, 0x01, 0x00]);
let var_bind = VarBind::new(name);
assert_eq!(var_bind.value(), &VarValue::Unspecified);

pub fn set_value(&mut self, value: VarValue) -> &mut Self[src]

Sets the variable value.

Examples

let name = ObjectIdent::from_slice(&[0x01, 0x03, 0x06, 0x01, 0x02, 0x01, 0x01, 0x01, 0x00]);
let mut var_bind = VarBind::new(name);
let new_value = VarValue::NoSuchInstance;
var_bind.set_value(new_value.clone());

assert_eq!(var_bind.value(), &new_value);

Trait Implementations

impl Clone for VarBind[src]

impl Debug for VarBind[src]

impl Eq for VarBind[src]

impl Hash for VarBind[src]

impl PartialEq<VarBind> for VarBind[src]

impl StructuralEq for VarBind[src]

impl StructuralPartialEq for VarBind[src]

Auto Trait Implementations

impl RefUnwindSafe for VarBind

impl Send for VarBind

impl Sync for VarBind

impl Unpin for VarBind

impl UnwindSafe for VarBind

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.