Enum bsn1::Length[][src]

pub enum Length {
    Indefinite,
    Definite(usize),
}
Expand description

Length represents ASN.1 length.

Note that Length represents the byte count of the contents in ASN.1. The total byte size of BER, DER, and CER is greater than that. (BER, DER, and CER are constituted of identifier, length, and contents.)

Variants

Indefinite

Represents ‘Indefinite’ length.

‘Indefinite’ is only for ‘BER’, and the contents must end with ‘EOC’ octets.

Definite(usize)

Tuple Fields

0: usize

‘Definite’ is for ‘BER’, ‘DER’, and ‘CER’, and represents the byte count of the contents.

Implementations

Serializes length .

This function won’t allocate heap memory.

Examples
use bsn1::Length;
use core::convert::TryFrom;

let length = Length::Definite(3);
let bytes = length.to_bytes();

let deserialized = Length::try_from(bytes.as_ref()).unwrap();
assert_eq!(length, deserialized);

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

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

This method tests for !=.

Parses bytes starting with length octets and returns a Length .

This function ignores extra octet(s) at the end of bytes if any.

The type returned in the event of a conversion error.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

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

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.