pub struct Length(/* private fields */);
Expand description
ASN.1-encoded length.
Maximum length is defined by the Length::MAX
constant (256 MiB).
Implementations§
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.
Trait Implementations§
source§impl<'a> Arbitrary<'a> for Length
Available on crate feature arbitrary
only.
impl<'a> Arbitrary<'a> for Length
Available on crate feature
arbitrary
only.source§fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
Generate an arbitrary value of
Self
from the given unstructured data. Read moresource§fn size_hint(depth: usize) -> (usize, Option<usize>)
fn size_hint(depth: usize) -> (usize, Option<usize>)
Get a size hint for how many bytes out of an
Unstructured
this type
needs to construct itself. Read moresource§fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
Generate an arbitrary value of
Self
from the entirety of the given
unstructured data. Read moresource§impl Encode for Length
impl Encode for Length
source§fn encoded_len(&self) -> Result<Length>
fn encoded_len(&self) -> Result<Length>
Compute the length of this value in bytes when encoded as ASN.1 DER.
source§fn encode(&self, writer: &mut impl Writer) -> Result<()>
fn encode(&self, writer: &mut impl Writer) -> Result<()>
Encode this value as ASN.1 DER using the provided
Writer
.source§fn encode_to_slice<'a>(&self, buf: &'a mut [u8]) -> Result<&'a [u8]>
fn encode_to_slice<'a>(&self, buf: &'a mut [u8]) -> Result<&'a [u8]>
Encode this value to the provided byte slice, returning a sub-slice
containing the encoded message.
source§impl From<Length> for IndefiniteLength
impl From<Length> for IndefiniteLength
source§fn from(length: Length) -> IndefiniteLength
fn from(length: Length) -> IndefiniteLength
Converts to this type from the input type.
source§impl Ord for Length
impl Ord for Length
source§impl PartialEq for Length
impl PartialEq for Length
source§impl PartialOrd for Length
impl PartialOrd for Length
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl TryFrom<IndefiniteLength> for Length
impl TryFrom<IndefiniteLength> for Length
impl Copy for Length
impl Eq for Length
impl StructuralPartialEq for Length
Auto Trait Implementations§
impl Freeze for Length
impl RefUnwindSafe for Length
impl Send for Length
impl Sync for Length
impl Unpin for Length
impl UnwindSafe for Length
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more