Struct picky_asn1::wrapper::BitStringAsn1
source · 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<BitStringAsn1> for BitStringAsn1
impl PartialEq<BitStringAsn1> for BitStringAsn1
source§fn eq(&self, other: &BitStringAsn1) -> bool
fn eq(&self, other: &BitStringAsn1) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl Serialize for BitStringAsn1
impl Serialize for BitStringAsn1
impl Eq for BitStringAsn1
impl StructuralEq for BitStringAsn1
impl StructuralPartialEq for BitStringAsn1
Auto Trait Implementations§
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