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
Auto Trait Implementations
impl RefUnwindSafe for Length
impl UnwindSafe for Length
Blanket Implementations
Mutably borrows from an owned value. Read more