pub struct BooleanBufferBuilder {
buffer: MutableBuffer,
len: usize,
}
Expand description
Builder for BooleanBuffer
Fields§
§buffer: MutableBuffer
§len: usize
Implementations§
Source§impl BooleanBufferBuilder
impl BooleanBufferBuilder
Sourcepub fn new_from_buffer(buffer: MutableBuffer, len: usize) -> Self
pub fn new_from_buffer(buffer: MutableBuffer, len: usize) -> Self
Creates a new BooleanBufferBuilder
from MutableBuffer
of len
Sourcepub fn truncate(&mut self, len: usize)
pub fn truncate(&mut self, len: usize)
Truncates the builder to the given length
If len
is greater than the buffer’s current length, this has no effect
Sourcepub fn reserve(&mut self, additional: usize)
pub fn reserve(&mut self, additional: usize)
Reserve space to at least additional
new bits.
Capacity will be >= self.len() + additional
.
New bytes are uninitialized and reading them is undefined behavior.
Sourcepub fn resize(&mut self, len: usize)
pub fn resize(&mut self, len: usize)
Resizes the buffer, either truncating its contents (with no change in capacity), or
growing it (potentially reallocating it) and writing false
in the newly available bits.
Sourcepub fn append_n(&mut self, additional: usize, v: bool)
pub fn append_n(&mut self, additional: usize, v: bool)
Appends n additional
bits of value v
into the buffer
Sourcepub fn append_slice(&mut self, slice: &[bool])
pub fn append_slice(&mut self, slice: &[bool])
Appends a slice of booleans into the buffer
Sourcepub fn append_packed_range(&mut self, range: Range<usize>, to_set: &[u8])
pub fn append_packed_range(&mut self, range: Range<usize>, to_set: &[u8])
Append range
bits from to_set
to_set
is a slice of bits packed LSB-first into [u8]
§Panics
Panics if to_set
does not contain ceil(range.end / 8)
bytes
Sourcepub fn append_buffer(&mut self, buffer: &BooleanBuffer)
pub fn append_buffer(&mut self, buffer: &BooleanBuffer)
Append BooleanBuffer
to this BooleanBufferBuilder
Sourcepub fn as_slice_mut(&mut self) -> &mut [u8] ⓘ
pub fn as_slice_mut(&mut self) -> &mut [u8] ⓘ
Returns the packed bits
Sourcepub fn finish(&mut self) -> BooleanBuffer
pub fn finish(&mut self) -> BooleanBuffer
Creates a BooleanBuffer
Sourcepub fn finish_cloned(&self) -> BooleanBuffer
pub fn finish_cloned(&self) -> BooleanBuffer
Builds the BooleanBuffer without resetting the builder.