pub struct BitStringAsn1(pub BitString);
Expand description
Wrapper type
Tuple Fields§
§0: BitString
Methods from Deref<Target = BitString>§
Sourcepub fn get_num_bits(&self) -> usize
pub fn get_num_bits(&self) -> usize
Get the number of available bits in the BitString
Sourcepub fn set_num_bits(&mut self, num_bits: usize)
pub fn set_num_bits(&mut self, num_bits: usize)
Set the length of a BitString
with each additional slot filled with 0.
§Examples
use picky_asn1::bit_string::BitString;
let v: Vec<u8> = vec![0x01, 0x01];
let mut b = BitString::with_bytes_and_len(v, 16);
assert_eq!(b.is_set(7), true);
assert_eq!(b.is_set(15), true);
b.set_num_bits(8);
assert_eq!(b.is_set(7), true);
b.set(15, true); // attempts to set a value out of the bounds are ignored
assert_eq!(b.is_set(15), false);
b.set_num_bits(16);
assert_eq!(b.is_set(7), true);
assert_eq!(b.is_set(15), false);
b.set(15, true);
assert_eq!(b.is_set(15), true);
Sourcepub fn is_set(&self, i: usize) -> bool
pub fn is_set(&self, i: usize) -> bool
Check if bit i
is set.
§Examples
use picky_asn1::bit_string::BitString;
let mut b = BitString::with_len(10);
assert_eq!(b.is_set(7), false);
b.set(7, true);
assert_eq!(b.is_set(7), true);
pub fn get_num_unused_bits(&self) -> u8
pub fn get_num_buckets(&self) -> usize
pub fn get_bucket(&self, i: usize) -> u8
pub fn get_bucket_mut(&mut self, i: usize) -> &mut u8
pub fn set_bucket(&mut self, i: usize, value: u8)
Sourcepub fn payload_view(&self) -> &[u8] ⓘ
pub fn payload_view(&self) -> &[u8] ⓘ
Returns an immutabe view on the payload.
§Examples
use picky_asn1::bit_string::BitString;
let v: Vec<u8> = vec![0x01, 0x00];
let mut b = BitString::with_bytes_and_len(v, 15);
b.set(14, true);
let payload = b.payload_view();
assert_eq!(payload, &[0x01, 0x02]);
Sourcepub fn payload_view_mut(&mut self) -> &mut [u8] ⓘ
pub fn payload_view_mut(&mut self) -> &mut [u8] ⓘ
Returns a mutabe view on the payload.
§Examples
use picky_asn1::bit_string::BitString;
let v: Vec<u8> = vec![0x01, 0x00];
let mut b = BitString::with_bytes_and_len(v, 15);
b.set(14, true);
let payload = b.payload_view_mut();
payload[0] = 0x20;
assert_eq!(payload, &[0x20, 0x02]);
Trait Implementations§
Source§impl Asn1Type for BitStringAsn1
impl Asn1Type for BitStringAsn1
Source§impl Clone for BitStringAsn1
impl Clone for BitStringAsn1
Source§fn clone(&self) -> BitStringAsn1
fn clone(&self) -> BitStringAsn1
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for BitStringAsn1
impl Debug for BitStringAsn1
Source§impl Default for BitStringAsn1
impl Default for BitStringAsn1
Source§impl Deref for BitStringAsn1
impl Deref for BitStringAsn1
Source§impl DerefMut for BitStringAsn1
impl DerefMut for BitStringAsn1
Source§impl<'de> Deserialize<'de> for BitStringAsn1
impl<'de> Deserialize<'de> for BitStringAsn1
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<BitString> for BitStringAsn1
impl From<BitString> for BitStringAsn1
Source§impl From<BitStringAsn1> for BitString
impl From<BitStringAsn1> for BitString
Source§fn from(wrapper: BitStringAsn1) -> BitString
fn from(wrapper: BitStringAsn1) -> BitString
Converts to this type from the input type.
Source§impl PartialEq<BitString> for BitStringAsn1
impl PartialEq<BitString> for BitStringAsn1
Source§impl PartialEq for BitStringAsn1
impl PartialEq for BitStringAsn1
Source§impl Serialize for BitStringAsn1
impl Serialize for BitStringAsn1
impl Eq for BitStringAsn1
impl StructuralPartialEq for BitStringAsn1
Auto Trait Implementations§
impl Freeze for BitStringAsn1
impl RefUnwindSafe for BitStringAsn1
impl Send for BitStringAsn1
impl Sync for BitStringAsn1
impl Unpin for BitStringAsn1
impl UnwindSafe for BitStringAsn1
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