Struct marble::Marble

source ·
pub struct Marble { /* private fields */ }
Expand description

Garbage-collecting object store. A nice solution to back a pagecache, for people building their own databases.

Writes should generally be performed by some background process whose job it is to clean logs etc…

Implementations§

source§

impl Marble

source

pub fn maintenance(&self) -> Result<usize>

Defragments backing storage files, blocking concurrent calls to write_batch but not blocking concurrent calls to read. Returns the number of rewritten objects.

source§

impl Marble

source

pub fn read(&self, object_id: u64) -> Result<Option<Box<[u8]>>>

Read a object out of storage. If this object is unknown or has been removed, returns Ok(None). If there is an IO problem, returns Err.

source§

impl Marble

source

pub fn write_batch<B, I>(&self, write_batch: I) -> Result<()>where B: AsRef<[u8]>, I: IntoIterator<Item = (u64, Option<B>)>,

Write a batch of objects to disk. This function is crash-atomic but NOT runtime atomic. If you are concurrently serving reads, and require atomic batch semantics, you should serve reads out of an in-memory cache until this function returns. Creates one file per call. May perform several fsync calls per call. Ideally, you will heavily batch objects being written using a logger of some sort before calling this function occasionally in the background, then deleting corresponding logs after this function returns.

source§

impl Marble

source

pub fn stats(&self) -> Stats

Statistics about current files, intended to inform decisions about when to call maintenance based on desired write and space amplification characteristics.

source

pub fn sync_all(&self) -> Result<()>

If Config::fsync_each_batch is false, this method can be called at a desired interval to ensure that the written batches are durable on disk.

source

pub fn free_object_ids<'a>(&'a self) -> (u64, impl 'a + Iterator<Item = u64>)

Intended for use in recovery, to bootstrap a higher level object ID allocator.

Returns a tuple of 1 higher than the current max allocated object ID, and an iterator over all object IDs beneath that which are currently deleted (due to being stored as a None in a write batch).

source

pub fn allocated_object_ids<'a>(&'a self) -> impl 'a + Iterator<Item = u64>

Returns an Iterator over all currently allocated object IDs.

Trait Implementations§

source§

impl Clone for Marble

source§

fn clone(&self) -> Marble

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Marble

source§

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

Formats the value using the given formatter. Read more
source§

impl Display for Marble

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Marble

§

impl Send for Marble

§

impl !Sync for Marble

§

impl Unpin for Marble

§

impl UnwindSafe for Marble

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.