Struct StackDB

Source
pub struct StackDB<'l, A: Allocator<'l>> { /* private fields */ }

Implementations§

Source§

impl<'l, A: Allocator<'l>> StackDB<'l, A>

Source

pub fn new(alloc: A) -> Result<Self, Error>

creates a database interface; either loads an existing db or creates a new one.

Source

pub fn read(&mut self, addr: Range<u64>) -> Result<Box<[u8]>, Error>

Reads data from either the heap or disk layers

Source

pub fn rebase(&mut self, buffer_size: u64) -> Result<(), Error>

Rebases and drops overwritten layers (the database history) by compressing all the layers into one to save space

Warning: will temporarity double database size

Source

pub fn write(&mut self, addr: u64, data: &[u8]) -> Result<(), Error>

Writes data to the heap layer (collisions are fine) (flush to commit the heap layers to disk)

Source

pub fn commit(&mut self) -> Result<(), Error>

Commits / writes the read-write layer’s (on the heap) writes to the database (on the disk); making it read-only

Trait Implementations§

Source§

impl<'l, A: Debug + Allocator<'l>> Debug for StackDB<'l, A>
where A::LayerStream: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'l, A> Freeze for StackDB<'l, A>
where A: Freeze,

§

impl<'l, A> RefUnwindSafe for StackDB<'l, A>

§

impl<'l, A> Send for StackDB<'l, A>
where A: Send, <A as Allocator<'l>>::LayerStream: Send,

§

impl<'l, A> Sync for StackDB<'l, A>
where A: Sync, <A as Allocator<'l>>::LayerStream: Sync,

§

impl<'l, A> Unpin for StackDB<'l, A>
where A: Unpin, <A as Allocator<'l>>::LayerStream: Unpin,

§

impl<'l, A> UnwindSafe for StackDB<'l, A>
where A: UnwindSafe, <A as Allocator<'l>>::LayerStream: UnwindSafe,

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.