[][src]Enum snmp_mp::ScopedPduData

pub enum ScopedPduData {
    Plaintext(ScopedPdu),
    Encrypted(Vec<u8>),
}

Represents either the plaintext scoped PDU if the privacy flag is not set, or it represents an encrypted PDU encoded as a byte string.

Examples

use snmp_mp::{ScopedPdu, ScopedPduData};

let scoped_pdu_data = ScopedPduData::Plaintext(ScopedPdu::new(1));
let scoped_pdu = scoped_pdu_data.plaintext();
assert_eq!(scoped_pdu.unwrap(), &ScopedPdu::new(1));

Variants

Plaintext(ScopedPdu)

Plaintext scoped PDU.

Encrypted(Vec<u8>)

Encrypted PDU as a byte string.

Implementations

impl ScopedPduData[src]

pub fn plaintext(&self) -> Option<&ScopedPdu>[src]

Returns a reference to the plaintext scoped PDU, or None if the scoped PDU is encrypted.

Examples

let scoped_pdu_data = ScopedPduData::Plaintext(ScopedPdu::new(1));
let scoped_pdu = scoped_pdu_data.plaintext();
assert_eq!(scoped_pdu.unwrap(), &ScopedPdu::new(1));

pub fn plaintext_mut(&mut self) -> Option<&mut ScopedPdu>[src]

Returns a mutable reference to the plaintext scoped PDU, or None if the scoped PDU is encrypted.

Examples

let mut scoped_pdu_data = ScopedPduData::Plaintext(ScopedPdu::new(1));
let scoped_pdu = scoped_pdu_data.plaintext_mut().unwrap();
scoped_pdu.set_request_id(1234);
assert_eq!(scoped_pdu.request_id(), 1234);

pub fn encrypted(&self) -> Option<&[u8]>[src]

Returns a reference to the encrypted scoped PDU, or None if the scoped PDU is plaintext.

Examples

let scoped_pdu_data = ScopedPduData::Encrypted(encrypted_scoped_pdu.clone());
let optional_encrypted_scoped_pdu = scoped_pdu_data.encrypted();
assert_eq!(optional_encrypted_scoped_pdu.unwrap(), &encrypted_scoped_pdu[..]);

Trait Implementations

impl Clone for ScopedPduData[src]

impl Debug for ScopedPduData[src]

impl Default for ScopedPduData[src]

impl Eq for ScopedPduData[src]

impl Hash for ScopedPduData[src]

impl PartialEq<ScopedPduData> for ScopedPduData[src]

impl StructuralEq for ScopedPduData[src]

impl StructuralPartialEq for ScopedPduData[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.