Struct BArrayStore

Source
pub struct BArrayStore { /* private fields */ }
Expand description

Main storage for all states

Implementations§

Source§

impl BArrayStore

§Main Array Storage API

Create a new array store, which can store any number of arrays as long as their stride matches.

  • stride the sizeof() each element,

Note while a stride of 1 will always work, its less efficient since duplicate chunks of memory will be searched at positions unaligned with the array data.

  • chunk_count Number of elements to split each chunk into.

    • A small value increases the ability to de-duplicate chunks, but adds overhead by increasing the number of chunks to look-up when searching for duplicates, as well as some overhead constructing the original array again, with more calls to memcpy.
    • Larger values reduce the book keeping overhead, but increase the chance a small, isolated change will cause a larger amount of data to be duplicated.

Return a new array store.

Source

pub fn new(stride: usize, chunk_count: usize) -> BArrayStore

Source

pub fn clear(&mut self)

Clear all contents, allowing reuse of self.

Source

pub fn calc_size_expanded_get(&self) -> usize

§BArrayStore Statistics

return the total amount of memory that would be used by getting the arrays for all states.

Source

pub fn calc_size_compacted_get(&self) -> usize

return the amount of memory used by all BChunk.data (duplicate chunks are only counted once).

Source

pub fn state_add( &mut self, data: &[u8], state_reference: Option<*const BArrayState>, ) -> *mut BArrayState

§BArrayState Access

  • data Data used to create.

  • state_reference The state to use as a reference when adding the new state, typically this is the previous state, however it can be any previously created state from this self.

Returns the new state, which is used by the caller as a handle to get back the contents of data. This may be removed using BArrayStore.state_remove, otherwise it will be removed with BArrayStore.destroy.

Source

pub fn state_remove(&mut self, state: *mut BArrayState)

Remove a state and free any unused BChunk data.

The states can be freed in any order.

Source

pub fn state_size_get(state: *const BArrayState) -> usize

return the expanded size of the array, use this to know how much memory to allocate BArrayStore.state_data_get ’s argument.

Source

pub fn state_data_get(state: *const BArrayState, data: &mut [u8])

Fill in existing allocated memory with the contents of state.

Source

pub fn state_data_get_alloc(state: *const BArrayState) -> Vec<u8>

Allocate an array for state and return it.

Source

pub fn is_valid(&self) -> bool

Trait Implementations§

Source§

impl Drop for BArrayStore

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.