pub struct BitString { /* private fields */ }
alloc
only.Expand description
Owned form of ASN.1 BIT STRING
type.
This type provides the same functionality as BitStringRef
but owns the
backing data.
Implementations
sourceimpl BitString
impl BitString
sourcepub const MAX_UNUSED_BITS: u8 = 7u8
pub const MAX_UNUSED_BITS: u8 = 7u8
Maximum number of unused bits allowed.
sourcepub fn new(unused_bits: u8, bytes: impl Into<Vec<u8>>) -> Result<Self>
pub fn new(unused_bits: u8, bytes: impl Into<Vec<u8>>) -> Result<Self>
Create a new ASN.1 BIT STRING
from a byte slice.
Accepts an optional number of “unused bits” (0-7) which are omitted from the final octet. This number is 0 if the value is octet-aligned.
sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self>
pub fn from_bytes(bytes: &[u8]) -> Result<Self>
Create a new ASN.1 BIT STRING
from the given bytes.
The “unused bits” are set to 0.
sourcepub fn unused_bits(&self) -> u8
pub fn unused_bits(&self) -> u8
Get the number of unused bits in the octet serialization of this
BIT STRING
.
sourcepub fn has_unused_bits(&self) -> bool
pub fn has_unused_bits(&self) -> bool
Is the number of unused bits a value other than 0?
sourcepub fn as_bytes(&self) -> Option<&[u8]>
pub fn as_bytes(&self) -> Option<&[u8]>
Borrow the inner byte slice.
Returns None
if the number of unused bits is not equal to zero,
i.e. if the BIT STRING
is not octet aligned.
Use BitString::raw_bytes
to obtain access to the raw value
regardless of the presence of unused bits.
sourcepub fn raw_bytes(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub fn raw_bytes(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
Borrow the raw bytes of this BIT STRING
.
sourcepub fn bits(&self) -> BitStringIter<'_>ⓘNotable traits for BitStringIter<'a>impl<'a> Iterator for BitStringIter<'a> type Item = bool;
pub fn bits(&self) -> BitStringIter<'_>ⓘNotable traits for BitStringIter<'a>impl<'a> Iterator for BitStringIter<'a> type Item = bool;
Iterator over the bits of this BIT STRING
.
Trait Implementations
sourceimpl<'a> DecodeValue<'a> for BitString
impl<'a> DecodeValue<'a> for BitString
sourceimpl EncodeValue for BitString
impl EncodeValue for BitString
sourceimpl<'a> From<&'a BitString> for BitStringRef<'a>
impl<'a> From<&'a BitString> for BitStringRef<'a>
sourcefn from(bit_string: &'a BitString) -> BitStringRef<'a>
fn from(bit_string: &'a BitString) -> BitStringRef<'a>
Converts to this type from the input type.
sourceimpl Ord for BitString
impl Ord for BitString
sourceimpl PartialOrd<BitString> for BitString
impl PartialOrd<BitString> for BitString
sourcefn partial_cmp(&self, other: &BitString) -> Option<Ordering>
fn partial_cmp(&self, other: &BitString) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn 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 more
impl Eq for BitString
impl StructuralEq for BitString
impl StructuralPartialEq for BitString
Auto Trait Implementations
impl RefUnwindSafe for BitString
impl Send for BitString
impl Sync for BitString
impl Unpin for BitString
impl UnwindSafe for BitString
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more