Struct ed25519_dalek::pkcs8::BitStringRef
pub struct BitStringRef<'a> { /* private fields */ }
pkcs8
only.Expand description
ASN.1 BIT STRING
type.
This type contains a sequence of any number of bits, modeled internally as a sequence of bytes with a known number of “unused bits”.
This is a zero-copy reference type which borrows from the input data.
Implementations§
§impl<'a> BitStringRef<'a>
impl<'a> BitStringRef<'a>
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: &'a [u8]) -> Result<BitStringRef<'a>, Error>
pub fn new(unused_bits: u8, bytes: &'a [u8]) -> Result<BitStringRef<'a>, 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: &'a [u8]) -> Result<BitStringRef<'a>, Error>
pub fn from_bytes(bytes: &'a [u8]) -> Result<BitStringRef<'a>, 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 this byte slice.
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 byte_len(&self) -> Length
pub fn byte_len(&self) -> Length
Get the number of bytes/octets needed to represent this BIT STRING
when serialized in an octet-aligned manner.
pub fn as_bytes(&self) -> Option<&'a [u8]>
pub fn as_bytes(&self) -> Option<&'a [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 raw_bytes(&self) -> &'a [u8] ⓘ
pub fn raw_bytes(&self) -> &'a [u8] ⓘ
Borrow the raw bytes of this BIT STRING
.
Note that the byte string may contain extra unused bits in the final
octet. If the number of unused bits is expected to be 0, the
BitStringRef::as_bytes
function can be used instead.
pub fn bits(self) -> BitStringIter<'a> ⓘ
pub fn bits(self) -> BitStringIter<'a> ⓘ
Iterator over the bits of this BIT STRING
.
Trait Implementations§
§impl<'a> Clone for BitStringRef<'a>
impl<'a> Clone for BitStringRef<'a>
§fn clone(&self) -> BitStringRef<'a>
fn clone(&self) -> BitStringRef<'a>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more§impl<'a> Debug for BitStringRef<'a>
impl<'a> Debug for BitStringRef<'a>
§impl<'a> DecodeValue<'a> for BitStringRef<'a>
impl<'a> DecodeValue<'a> for BitStringRef<'a>
§fn decode_value<R>(
reader: &mut R,
header: Header
) -> Result<BitStringRef<'a>, Error>where
R: Reader<'a>,
fn decode_value<R>(
reader: &mut R,
header: Header
) -> Result<BitStringRef<'a>, Error>where
R: Reader<'a>,
Reader
.§impl EncodeValue for BitStringRef<'_>
impl EncodeValue for BitStringRef<'_>
§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<'a> From<&BitStringRef<'a>> for BitStringRef<'a>
impl<'a> From<&BitStringRef<'a>> for BitStringRef<'a>
§fn from(value: &BitStringRef<'a>) -> BitStringRef<'a>
fn from(value: &BitStringRef<'a>) -> BitStringRef<'a>
§impl<'a> Ord for BitStringRef<'a>
impl<'a> Ord for BitStringRef<'a>
§fn cmp(&self, other: &BitStringRef<'a>) -> Ordering
fn cmp(&self, other: &BitStringRef<'a>) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
§impl<'a> PartialEq for BitStringRef<'a>
impl<'a> PartialEq for BitStringRef<'a>
§fn eq(&self, other: &BitStringRef<'a>) -> bool
fn eq(&self, other: &BitStringRef<'a>) -> bool
self
and other
values to be equal, and is used
by ==
.§impl<'a> PartialOrd for BitStringRef<'a>
impl<'a> PartialOrd for BitStringRef<'a>
§fn partial_cmp(&self, other: &BitStringRef<'a>) -> Option<Ordering>
fn partial_cmp(&self, other: &BitStringRef<'a>) -> 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 more§impl<'a> RefToOwned<'a> for BitStringRef<'a>
impl<'a> RefToOwned<'a> for BitStringRef<'a>
§fn ref_to_owned(&self) -> <BitStringRef<'a> as RefToOwned<'a>>::Owned
fn ref_to_owned(&self) -> <BitStringRef<'a> as RefToOwned<'a>>::Owned
§impl<'a> TryFrom<&&'a [u8]> for BitStringRef<'a>
impl<'a> TryFrom<&&'a [u8]> for BitStringRef<'a>
Hack for simplifying the custom derive use case.
§impl<'a> TryFrom<&'a [u8]> for BitStringRef<'a>
impl<'a> TryFrom<&'a [u8]> for BitStringRef<'a>
§impl<'__der, 'a> TryFrom<&'__der Any> for BitStringRef<'a>where
'__der: 'a,
Available on crate feature alloc
only.
impl<'__der, 'a> TryFrom<&'__der Any> for BitStringRef<'a>where
'__der: 'a,
alloc
only.§impl<'__der, 'a> TryFrom<AnyRef<'__der>> for BitStringRef<'a>where
'__der: 'a,
impl<'__der, 'a> TryFrom<AnyRef<'__der>> for BitStringRef<'a>where
'__der: 'a,
§impl<'a> TryFrom<BitStringRef<'a>> for &'a [u8]
impl<'a> TryFrom<BitStringRef<'a>> for &'a [u8]
§impl ValueOrd for BitStringRef<'_>
impl ValueOrd for BitStringRef<'_>
impl<'a> Copy for BitStringRef<'a>
impl<'a> Eq for BitStringRef<'a>
impl<'a> StructuralPartialEq for BitStringRef<'a>
Auto Trait Implementations§
impl<'a> RefUnwindSafe for BitStringRef<'a>
impl<'a> Send for BitStringRef<'a>
impl<'a> Sync for BitStringRef<'a>
impl<'a> Unpin for BitStringRef<'a>
impl<'a> UnwindSafe for BitStringRef<'a>
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
.