[][src]Struct gf::support::buffer::Buffer

pub struct Buffer { /* fields omitted */ }

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]

Return bit value at bit_index, None if undefined.

Errors

  • Panics on out-of-bound indexing.

pub fn get_byte<I: IntoU128>(&self, byte_index: I) -> Option<u8>[src]

Return byte value at byte_index, None if undefined.

Errors

  • Panics on out-of-bound indexing.

pub fn get_bytes<I: IntoU128>(
    &self,
    byte_index: I,
    num_bytes: usize
) -> Option<Vec<u8>>
[src]

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]

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]

Set bit value at bit_index to value.

Errors

  • Panics on out-of-bound indexing.

pub fn set_byte<I: IntoU128>(&mut self, byte_index: I, value: u8)[src]

Set byte value at byte_index to value.

Errors

  • Panics on out-of-bound indexing.

pub fn set_bytes<I: IntoU128>(&mut self, byte_index: I, slice: &[u8])[src]

Set values bytes starting at byte_index from a slice.

Errors

  • Panics on out-of-bound indexing.

pub fn unset_bit<I: IntoU128>(&mut self, bit_index: I)[src]

Unset bit at bit_index.

Errors

  • Panics on out-of-bound indexing.

pub fn unset_byte<I: IntoU128>(&mut self, byte_index: I)[src]

Unset byte at byte_index.

Errors

  • Panics on out-of-bound indexing.

pub fn unset_bytes<I: IntoU128>(&mut self, byte_index: I, num_bytes: usize)[src]

Unset num_bytes bytes starting at byte_index.

Errors

  • Panics on out-of-bound indexing.

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]

Return mutable reference to page for byte_index, default-constructing it as needed.

Errors

  • Panics on out-of-bound indexing.

Trait Implementations

impl Clone for Buffer[src]

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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.