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
Represents ‘Indefinite’ length.
‘Indefinite’ is only for ‘BER’, and the contents must end with ‘EOC’ octets.
Definite(usize)
‘Definite’ is for ‘BER’, ‘DER’, and ‘CER’, and represents the byte count of the contents.
Implementations
impl Length
[src]
impl Length
[src]pub fn to_bytes(&self) -> impl AsRef<[u8]>
[src]
pub fn to_bytes(&self) -> impl AsRef<[u8]>
[src]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
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> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
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]
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