pub struct BitString { /* private fields */ }
pkcs8
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§
§impl BitString
impl BitString
pub const MAX_UNUSED_BITS: u8 = 7u8
pub const MAX_UNUSED_BITS: u8 = 7u8
Maximum number of unused bits allowed.
pub fn new(
unused_bits: u8,
bytes: impl Into<Vec<u8>>
) -> Result<BitString, Error>
pub fn new( unused_bits: u8, bytes: impl Into<Vec<u8>> ) -> Result<BitString, Error>
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.
pub fn from_bytes(bytes: &[u8]) -> Result<BitString, Error>
pub fn from_bytes(bytes: &[u8]) -> Result<BitString, Error>
Create a new ASN.1 BIT STRING
from the given bytes.
The “unused bits” are set to 0.
pub 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
.
pub fn has_unused_bits(&self) -> bool
pub fn has_unused_bits(&self) -> bool
Is the number of unused bits a value other than 0?
pub 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.
pub fn bits(&self) -> BitStringIter<'_> ⓘ
pub fn bits(&self) -> BitStringIter<'_> ⓘ
Iterator over the bits of this BIT STRING
.
Trait Implementations§
§impl<'a> DecodeValue<'a> for BitString
impl<'a> DecodeValue<'a> for BitString
§impl EncodeValue for BitString
impl EncodeValue for BitString
§impl<'a> From<&'a BitString> for BitStringRef<'a>
impl<'a> From<&'a BitString> for BitStringRef<'a>
§fn from(bit_string: &'a BitString) -> BitStringRef<'a>
fn from(bit_string: &'a BitString) -> BitStringRef<'a>
§impl Ord for BitString
impl Ord for BitString
§impl OwnedToRef for BitString
impl OwnedToRef for BitString
§type Borrowed<'a> = BitStringRef<'a>
type Borrowed<'a> = BitStringRef<'a>
§fn owned_to_ref(&self) -> <BitString as OwnedToRef>::Borrowed<'_>
fn owned_to_ref(&self) -> <BitString as OwnedToRef>::Borrowed<'_>
§impl PartialOrd for BitString
impl PartialOrd for BitString
§fn partial_cmp(&self, other: &BitString) -> Option<Ordering>
fn partial_cmp(&self, other: &BitString) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moreimpl Eq 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§
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
§impl<'a, T> Choice<'a> for T
impl<'a, T> Choice<'a> for T
§fn can_decode(tag: Tag) -> bool
fn can_decode(tag: Tag) -> bool
Tag
decodable as a variant of this CHOICE
?§impl<'a, T> Decode<'a> for Twhere
T: DecodeValue<'a> + FixedTag,
impl<'a, T> Decode<'a> for Twhere
T: DecodeValue<'a> + FixedTag,
§impl<T> Encode for Twhere
T: EncodeValue + Tagged,
impl<T> Encode for Twhere
T: EncodeValue + Tagged,
§fn encoded_len(&self) -> Result<Length, Error>
fn encoded_len(&self) -> Result<Length, Error>
Compute the length of this value in bytes when encoded as ASN.1 DER.
§fn encode(&self, writer: &mut impl Writer) -> Result<(), Error>
fn encode(&self, writer: &mut impl Writer) -> Result<(), Error>
Encode this value as ASN.1 DER using the provided Writer
.