[−][src]Struct gf::support::buffer::Buffer
A byte-granular buffer that can have undefined bits.
Internally, a buffer is a collection of fixed-size pages, each a
BufferPage
structure. Pages are allocated on-demand. Missing pages are
defined to have no concrete bits.
Implementations
impl Buffer
[src]
pub fn new<I: Into<BufferSize>>(size: I) -> Self
[src]
Create an entirely undefined buffer.
pub fn size(&self) -> BufferSize
[src]
Return buffer size.
pub fn clear(&mut self)
[src]
Clear buffer, resetting all bits to undefined.
pub fn get_bit<I: IntoU128>(&self, bit_index: I) -> Option<bool>
[src]
pub fn get_byte<I: IntoU128>(&self, byte_index: I) -> Option<u8>
[src]
pub fn get_bytes<I: IntoU128>(
&self,
byte_index: I,
num_bytes: usize
) -> Option<Vec<u8>>
[src]
&self,
byte_index: I,
num_bytes: usize
) -> Option<Vec<u8>>
Return values of num_bytes
bytes starting at byte_index
as a vector,
None
if any of the bytes is undefined.
Errors
- Panics on out-of-bound indexing.
#[must_use = "check return value before accessing the slice"]pub fn get_bytes_into<I: IntoU128>(
&self,
byte_index: I,
slice: &mut [u8]
) -> bool
[src]
&self,
byte_index: I,
slice: &mut [u8]
) -> bool
Copy values of bytes starting at byte_index
into a slice, returning
whether all bytes have been defined.
If any of the bytes are undefined, the entire contents of the slice are undefined on exit from this function, so it is important to check the return value before doing anything with the slice.
Errors
- Panics on out-of-bound indexing.
pub fn set_bit<I: IntoU128>(&mut self, bit_index: I, value: bool)
[src]
pub fn set_byte<I: IntoU128>(&mut self, byte_index: I, value: u8)
[src]
pub fn set_bytes<I: IntoU128>(&mut self, byte_index: I, slice: &[u8])
[src]
pub fn unset_bit<I: IntoU128>(&mut self, bit_index: I)
[src]
pub fn unset_byte<I: IntoU128>(&mut self, byte_index: I)
[src]
pub fn unset_bytes<I: IntoU128>(&mut self, byte_index: I, num_bytes: usize)
[src]
pub fn page_of_bit<I: IntoU128>(&self, bit_index: I) -> Option<&BufferPage>
[src]
Return a shared reference to page for bit_index
, None
if the entire
page is undefined.
Errors
- Panics on out-of-bound indexing.
pub fn page_of_bit_mut<I: IntoU128>(&mut self, bit_index: I) -> &mut BufferPage
[src]
Return a mutable reference to page for bit_index
, default-constructing
it as needed.
Errors
- Panics on out-of-bound indexing.
pub fn page_of_byte<I: IntoU128>(&self, byte_index: I) -> Option<&BufferPage>
[src]
Return shared reference to page for byte_index
, None
if the entire
page is undefined.
Errors
- Panics on out-of-bound indexing.
pub fn page_of_byte_mut<I: IntoU128>(
&mut self,
byte_index: I
) -> &mut BufferPage
[src]
&mut self,
byte_index: I
) -> &mut BufferPage
Return mutable reference to page for byte_index
, default-constructing
it as needed.
Errors
- Panics on out-of-bound indexing.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Buffer
impl Send for Buffer
impl Sync for Buffer
impl Unpin for Buffer
impl UnwindSafe for Buffer
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,