[][src]Struct snmp_mp::ScopedPdu

pub struct ScopedPdu { /* fields omitted */ }

Scoped PDU contained in an SNMP message.

Builder methods are provided to update the scoped PDU.

Examples

use snmp_mp::{PduType, ScopedPdu};

let mut scoped_pdu = ScopedPdu::new(1);
scoped_pdu
    .set_pdu_type(PduType::GetNextRequest)
    .set_engine_id(b"engine_id");

Implementations

impl ScopedPdu[src]

pub const REQUEST_ID_MIN: i32[src]

The smallest value that can be used as a request ID.

Examples

assert_eq!(ScopedPdu::REQUEST_ID_MIN, -214_783_648);

pub const REQUEST_ID_MAX: i32[src]

The largest value that can be used as a request ID.

Examples

assert_eq!(ScopedPdu::REQUEST_ID_MAX, 214_783_647);

pub fn new(request_id: i32) -> Self[src]

Constructs a new empty ScopedPdu.

Examples

let scoped_pdu = ScopedPdu::new(1);

pub fn engine_id(&self) -> &[u8][src]

Returns the context engine ID.

Examples

let engine_id = scoped_pdu.engine_id();

pub fn set_engine_id(&mut self, engine_id: &[u8]) -> &mut Self[src]

Sets the context engine ID.

Examples

let mut scoped_pdu = ScopedPdu::new(1);
scoped_pdu.set_engine_id(b"engine_id");
assert_eq!(scoped_pdu.engine_id(), b"engine_id");

pub fn context_name(&self) -> &[u8][src]

Returns the context name.

The context name field in conjunction with the context engine ID field, identifies the particular context associated with the management information contained in the PDU portion of the message. The contextName is unique within the SNMP entity specified by the context engine ID, which may realize the managed objects referenced within the PDU.

Examples

let context_name = scoped_pdu.context_name();

pub fn set_context_name(&mut self, context_name: &[u8]) -> &mut Self[src]

Sets the context name.

Examples

let mut scoped_pdu = ScopedPdu::new(1);
scoped_pdu.set_context_name(b"context_name");
assert_eq!(scoped_pdu.context_name(), b"context_name");

pub fn pdu_type(&self) -> PduType[src]

Returns the PDU type.

Examples

let pdu_type = scoped_pdu.pdu_type();

pub fn set_pdu_type(&mut self, pdu_type: PduType) -> &mut Self[src]

Sets the PDU type.

Examples

let mut scoped_pdu = ScopedPdu::new(1);
scoped_pdu.set_pdu_type(PduType::GetNextRequest);
assert_eq!(scoped_pdu.pdu_type(), PduType::GetNextRequest);

pub fn request_id(&self) -> i32[src]

Returns the request ID.

Examples

let request_id = scoped_pdu.request_id();

pub fn set_request_id(&mut self, request_id: i32) -> &mut Self[src]

Sets the request ID.

Examples

let mut scoped_pdu = ScopedPdu::new(1);
scoped_pdu.set_request_id(1234);
assert_eq!(scoped_pdu.request_id(), 1234);

pub fn error_status(&self) -> PduErrorStatus[src]

Returns the error status.

Examples

let error_status = scoped_pdu.error_status();

pub fn set_error_status(&mut self, error_status: PduErrorStatus) -> &mut Self[src]

Sets the error status.

Examples

let mut scoped_pdu = ScopedPdu::new(1);
scoped_pdu.set_error_status(PduErrorStatus::NoSuchName);
assert_eq!(scoped_pdu.error_status(), PduErrorStatus::NoSuchName);

pub fn error_index(&self) -> u32[src]

Returns the error index.

Examples

assert_eq!(scoped_pdu.error_index(), 0);

pub fn set_error_index(&mut self, error_index: u32) -> &mut Self[src]

Sets the error index.

Examples

let mut scoped_pdu = ScopedPdu::new(1);
scoped_pdu.set_error_index(1);
assert_eq!(scoped_pdu.error_index(), 1);

pub fn var_binds(&self) -> &[VarBind][src]

Returns the variable bindings.

Examples

let var_binds = scoped_pdu.var_binds();

pub fn set_var_binds<I>(&mut self, var_binds_iter: I) -> &mut Self where
    I: IntoIterator<Item = VarBind>, 
[src]

Sets the variable bindings.

Examples


let mut scoped_pdu = ScopedPdu::new(1);
scoped_pdu.set_var_binds(var_binds.clone());
assert_eq!(var_binds, scoped_pdu.var_binds());

pub fn push_var_bind(&mut self, var_bind: VarBind) -> &mut Self[src]

Appends an element to the back of the list of variable bindings.

Examples

let oid = ObjectIdent::from_slice(&[0x01, 0x03, 0x06, 0x01, 0x02, 0x01, 0x01, 0x01, 0x00]);
let var_bind = VarBind::new(oid);

let mut scoped_pdu = ScopedPdu::new(1);
scoped_pdu.push_var_bind(var_bind.clone());
assert_eq!(vec![var_bind], scoped_pdu.var_binds());

pub fn encode(&self) -> Vec<u8>[src]

Encodes a scoped PDU.

Examples

let scoped_pdu = ScopedPdu::new(1);
let encoded_scoped_pdu = scoped_pdu.encode();

pub fn decode(buf: &[u8]) -> MsgProcessingResult<Self>[src]

Decodes an encoded scope PDU.

Errors

If the scoped PDU is not properly formed a result with MalformedMsg error is returned.

Examples

let scoped_pdu = ScopedPdu::decode(&encoded_scoped_pdu)?;

Trait Implementations

impl Clone for ScopedPdu[src]

impl Debug for ScopedPdu[src]

impl Default for ScopedPdu[src]

impl Eq for ScopedPdu[src]

impl Hash for ScopedPdu[src]

impl PartialEq<ScopedPdu> for ScopedPdu[src]

impl StructuralEq for ScopedPdu[src]

impl StructuralPartialEq for ScopedPdu[src]

Auto Trait Implementations

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.