[][src]Enum bcder::decode::Content

pub enum Content<'a, S: 'a> {
    Primitive(Primitive<'a, S>),
    Constructed(Constructed<'a, S>),
}

The content octets of a BER-encoded value.

A value is either primitive, containing actual octets of an actual value, or constructed, in which case its content contains additional BER encoded values. This enum is useful for cases where a certain type may be encoded as either a primitive value or a complex constructed value.

Note that this type represents the content octets only, i.e., it does not contain the tag of the value.

Variants

Primitive(Primitive<'a, S>)

The value is a primitive value.

Constructed(Constructed<'a, S>)

The value is a constructed value.

Implementations

impl<'a, S: Source + 'a> Content<'a, S>[src]

pub fn mode(&self) -> Mode[src]

Returns the encoding mode used by the value.

pub fn is_primitive(&self) -> bool[src]

Returns whether this value is a primitive value.

pub fn is_constructed(&self) -> bool[src]

Returns whether this value is a constructed value.

pub fn as_primitive(&mut self) -> Result<&mut Primitive<'a, S>, S::Err>[src]

Converts a reference into into one to a primitive value or errors out.

pub fn as_constructed(&mut self) -> Result<&mut Constructed<'a, S>, S::Err>[src]

Converts a reference into on to a constructed value or errors out.

impl<'a, S: Source + 'a> Content<'a, S>[src]

pub fn to_u8(&mut self) -> Result<u8, S::Err>[src]

Converts content into a u8.

If the content is not primitive or does not contain a single BER encoded INTEGER value between 0 and 256, returns a malformed error.

pub fn skip_u8_if(&mut self, expected: u8) -> Result<(), S::Err>[src]

Skips over the content if it contains an INTEGER of value expected.

The content needs to be primitive and contain a validly encoded integer of value expected or else a malformed error will be returned.

pub fn to_u16(&mut self) -> Result<u16, S::Err>[src]

Converts content into a u16.

If the content is not primitive or does not contain a single BER encoded INTEGER value between 0 and 2^16-1, returns a malformed error.

pub fn to_u32(&mut self) -> Result<u32, S::Err>[src]

Converts content into a u32.

If the content is not primitive or does not contain a single BER encoded INTEGER value between 0 and 2^32-1, returns a malformed error.

pub fn to_u64(&mut self) -> Result<u64, S::Err>[src]

Converts content into a u64.

If the content is not primitive or does not contain a single BER encoded INTEGER value between 0 and 2^64-1, returns a malformed error.

pub fn to_null(&mut self) -> Result<(), S::Err>[src]

Converts the content into a NULL value.

If the content isn’t primitive and contains a single BER encoded NULL value (i.e., nothing), returns a malformed error.

Auto Trait Implementations

impl<'a, S> RefUnwindSafe for Content<'a, S> where
    S: RefUnwindSafe
[src]

impl<'a, S> Send for Content<'a, S> where
    S: Send
[src]

impl<'a, S> Sync for Content<'a, S> where
    S: Sync
[src]

impl<'a, S> Unpin for Content<'a, S>[src]

impl<'a, S> !UnwindSafe for Content<'a, S>[src]

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, 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.