Struct der::Length[][src]

pub struct Length(_);
Expand description

ASN.1-encoded length.

Maximum length is defined by the Length::MAX constant (1 MiB).

Implementations

impl Length[src]

pub const ZERO: Self[src]

Length of 0

pub const ONE: Self[src]

Length of 1

pub const MAX: Self[src]

Maximum length currently supported: 1 MiB

pub const fn new(value: u16) -> Self[src]

Create a new Length for any value which fits inside of a u16.

This function is const-safe and therefore useful for Length constants.

pub const fn zero() -> Self[src]

👎 Deprecated since 0.3.3:

please use Length::ZERO

Return a length of 0.

pub const fn one() -> Self[src]

👎 Deprecated since 0.3.3:

please use Length::ONE

Return a length of 1.

pub const fn max() -> Self[src]

👎 Deprecated since 0.3.3:

please use Length::MAX

Get the maximum length supported by this crate

pub fn for_tlv(self) -> Result<Self>[src]

Get the length of DER Tag-Length-Value (TLV) encoded data if self is the length of the inner “value” portion of the message.

Trait Implementations

impl Add<Length> for Length[src]

type Output = Result<Self>

The resulting type after applying the + operator.

fn add(self, other: Self) -> Result<Self>[src]

Performs the + operation. Read more

impl Add<Length> for Result<Length>[src]

type Output = Self

The resulting type after applying the + operator.

fn add(self, other: Length) -> Self[src]

Performs the + operation. Read more

impl Add<u16> for Length[src]

type Output = Result<Self>

The resulting type after applying the + operator.

fn add(self, other: u16) -> Result<Self>[src]

Performs the + operation. Read more

impl Add<u32> for Length[src]

type Output = Result<Self>

The resulting type after applying the + operator.

fn add(self, other: u32) -> Result<Self>[src]

Performs the + operation. Read more

impl Add<u8> for Length[src]

type Output = Result<Self>

The resulting type after applying the + operator.

fn add(self, other: u8) -> Result<Self>[src]

Performs the + operation. Read more

impl Add<usize> for Length[src]

type Output = Result<Self>

The resulting type after applying the + operator.

fn add(self, other: usize) -> Result<Self>[src]

Performs the + operation. Read more

impl Clone for Length[src]

fn clone(&self) -> Length[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for Length[src]

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

Formats the value using the given formatter. Read more

impl Decodable<'_> for Length[src]

fn decode(decoder: &mut Decoder<'_>) -> Result<Length>[src]

Attempt to decode this message using the provided decoder.

fn from_der(bytes: &'a [u8]) -> Result<Self>[src]

Parse Self from the provided DER-encoded byte slice.

impl Default for Length[src]

fn default() -> Length[src]

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

impl Display for Length[src]

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

Formats the value using the given formatter. Read more

impl Encodable for Length[src]

fn encoded_len(&self) -> Result<Length>[src]

Compute the length of this value in bytes when encoded as ASN.1 DER.

fn encode(&self, encoder: &mut Encoder<'_>) -> Result<()>[src]

Encode this value as ASN.1 DER using the provided Encoder.

fn encode_to_slice<'a>(&self, buf: &'a mut [u8]) -> Result<&'a [u8]>[src]

Encode this value to the provided byte slice, returning a sub-slice containing the encoded message. Read more

fn encode_to_vec(&self, buf: &mut Vec<u8>) -> Result<Length>[src]

This is supported on crate feature alloc only.

Encode this message as ASN.1 DER, appending it to the provided byte vector. Read more

fn to_vec(&self) -> Result<Vec<u8>>[src]

This is supported on crate feature alloc only.

Serialize this message as a byte vector.

impl From<u16> for Length[src]

fn from(len: u16) -> Length[src]

Performs the conversion.

impl From<u8> for Length[src]

fn from(len: u8) -> Length[src]

Performs the conversion.

impl Ord for Length[src]

fn cmp(&self, other: &Length) -> Ordering[src]

This method returns an Ordering between self and other. Read more

#[must_use]
fn max(self, other: Self) -> Self
1.21.0[src]

Compares and returns the maximum of two values. Read more

#[must_use]
fn min(self, other: Self) -> Self
1.21.0[src]

Compares and returns the minimum of two values. Read more

#[must_use]
fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]

Restrict a value to a certain interval. Read more

impl PartialEq<Length> for Length[src]

fn eq(&self, other: &Length) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &Length) -> bool[src]

This method tests for !=.

impl PartialOrd<Length> for Length[src]

fn partial_cmp(&self, other: &Length) -> Option<Ordering>[src]

This method returns an ordering between self and other values if one exists. Read more

#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests less than (for self and other) and is used by the < operator. Read more

#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl TryFrom<u32> for Length[src]

type Error = Error

The type returned in the event of a conversion error.

fn try_from(len: u32) -> Result<Length>[src]

Performs the conversion.

impl TryFrom<usize> for Length[src]

type Error = Error

The type returned in the event of a conversion error.

fn try_from(len: usize) -> Result<Length>[src]

Performs the conversion.

impl Copy for Length[src]

impl Eq for Length[src]

impl StructuralEq for Length[src]

impl StructuralPartialEq for Length[src]

Auto Trait Implementations

impl RefUnwindSafe for Length

impl Send for Length

impl Sync for Length

impl Unpin for Length

impl UnwindSafe for Length

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

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

type Output = T

Should always be Self

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

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

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

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

impl<T> ToString for T where
    T: Display + ?Sized
[src]

pub default fn to_string(&self) -> String[src]

Converts the given value to a String. Read more

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.

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

Performs the conversion.

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.

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

Performs the conversion.