pub struct Length(u32);Expand description
ASN.1-encoded length.
Maximum length is defined by the Length::MAX constant (256 MiB).
Tuple Fields§
§0: u32Implementations§
Source§impl Length
 
impl Length
Sourcepub fn for_tlv(self) -> Result<Self>
 
pub fn for_tlv(self) -> Result<Self>
Get the length of DER Tag-Length-Value (TLV) encoded data if self
is the length of the inner “value” portion of the message.
Sourcepub fn saturating_add(self, rhs: Self) -> Self
 
pub fn saturating_add(self, rhs: Self) -> Self
Perform saturating addition of two lengths.
Sourcepub fn saturating_sub(self, rhs: Self) -> Self
 
pub fn saturating_sub(self, rhs: Self) -> Self
Perform saturating subtraction of two lengths.
Sourcefn initial_octet(self) -> Option<u8>
 
fn initial_octet(self) -> Option<u8>
Get initial octet of the encoded length (if one is required).
From X.690 Section 8.1.3.5:
In the long form, the length octets shall consist of an initial octet and one or more subsequent octets. The initial octet shall be encoded as follows:
a) bit 8 shall be one; b) bits 7 to 1 shall encode the number of subsequent octets in the length octets, as an unsigned binary integer with bit 7 as the most significant bit; c) the value 11111111₂ shall not be used.
Trait Implementations§
Source§impl Encode for Length
 
impl Encode for Length
Source§fn encoded_len(&self) -> Result<Length>
 
fn encoded_len(&self) -> Result<Length>
Source§fn encode(&self, writer: &mut impl Writer) -> Result<()>
 
fn encode(&self, writer: &mut impl Writer) -> Result<()>
Writer.