pub struct NetlinkBitArray(/* private fields */);
Expand description
A bit array meant to be compatible with the bit array
returned by the NETLINK_LIST_MEMBERSHIPS
socket operation
on netlink sockets.
Implementations§
Source§impl NetlinkBitArray
bittest/bitset instrinsics are not stable in Rust so this
needs to be implemented this way.
impl NetlinkBitArray
bittest/bitset instrinsics are not stable in Rust so this needs to be implemented this way.
Sourcepub fn new(bit_len: usize) -> Self
pub fn new(bit_len: usize) -> Self
Create a new bit array.
This method will round bit_len
up to the nearest
multiple of size_of::<u32>()
.
Sourcepub fn resize_bits(&mut self, bit_len: usize)
pub fn resize_bits(&mut self, bit_len: usize)
Resize the underlying vector to have enough space for
the nearest multiple of size_of::<u32>()
rounded up.
Sourcepub fn resize(&mut self, bytes: usize)
pub fn resize(&mut self, bytes: usize)
Resize the underlying vector to have enough space for
the nearest multiple of size_of::<BitArrayType>()
.
Sourcepub fn to_vec(&self) -> Vec<u32>
pub fn to_vec(&self) -> Vec<u32>
Get a vector representation of all of the bit positions set to 1 in this bit array.
§Example
use neli::utils::NetlinkBitArray;
let mut array = NetlinkBitArray::new(24);
array.set(4);
array.set(7);
array.set(23);
assert_eq!(array.to_vec(), vec![4, 7, 23]);
Auto Trait Implementations§
impl Freeze for NetlinkBitArray
impl RefUnwindSafe for NetlinkBitArray
impl Send for NetlinkBitArray
impl Sync for NetlinkBitArray
impl Unpin for NetlinkBitArray
impl UnwindSafe for NetlinkBitArray
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