Enum bcder::Mode

source ·
pub enum Mode {
    Ber,
    Cer,
    Der,
}
Expand description

The BER Mode.

X.680 defines not one but three sets of related encoding rules. All three follow the same basic ideas but implement them in slightly different ways.

This type represents these rules. The decode method provides a way to decode a source using the specific decoding mode. You can also change the decoding mode later on through the set_mode methods of Primitive and Constructed.

Variants§

§

Ber

Basic Encoding Rules.

These are the most flexible rules, allowing alternative encodings for some types as well as indefinite length values.

§

Cer

Canonical Encoding Rules.

These rules always employ indefinite length encoding for constructed values and the shortest possible form for primitive values. There are additional restrictions for certain types.

§

Der

Distinguished Encoding Rules.

These rules always employ definite length values and require the shortest possible encoding. Additional rules apply to some types.

Implementations§

source§

impl Mode

source

pub fn decode<S, F, T>( self, source: S, op: F ) -> Result<T, DecodeError<<S::Source as Source>::Error>>
where S: IntoSource, F: FnOnce(&mut Constructed<'_, S::Source>) -> Result<T, DecodeError<<S::Source as Source>::Error>>,

Decode a source using a specific mode.

The method will attempt to decode source using the rules represented by this value. The closure op will be given the content of the source as a sequence of values. The closure does not need to process all values in the source.

source

pub fn is_ber(self) -> bool

Returns whether the mode is Mode::Ber.

source

pub fn is_cer(self) -> bool

Returns whether the mode is Mode::Cer.

source

pub fn is_der(self) -> bool

Returns whether the mode is Mode::Der.

Trait Implementations§

source§

impl Clone for Mode

source§

fn clone(&self) -> Mode

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Mode

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Mode

source§

fn default() -> Mode

Returns the “default value” for a type. Read more
source§

impl PartialEq for Mode

source§

fn eq(&self, other: &Mode) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for Mode

source§

impl Eq for Mode

source§

impl StructuralEq for Mode

source§

impl StructuralPartialEq for Mode

Auto Trait Implementations§

§

impl RefUnwindSafe for Mode

§

impl Send for Mode

§

impl Sync for Mode

§

impl Unpin for Mode

§

impl UnwindSafe for Mode

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.