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 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
source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)