MemObjectStore

Struct MemObjectStore 

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

In-memory object store backed by FabricHashMap.

Objects are stored as serialized entries in a hash map over leased DRAM. Large objects (>64 KiB) are split into 64 KiB chunks, each stored under a derived key (<uri>#chunk/<n>), with the root entry holding metadata and the chunk count.

§Example

use grafos_store::{MemObjectStore, ObjectStore, FabricUri};

let mut store = MemObjectStore::new(64)?;
let uri: FabricUri = "fabric://p/b/k".parse()?;
store.put(&uri, b"data", None)?;
let obj = store.get(&uri)?.unwrap();
assert_eq!(obj.data, b"data");

Implementations§

Source§

impl MemObjectStore

Source

pub fn new(buckets: usize) -> Result<Self>

Create a new in-memory object store with the given number of hash map buckets.

Trait Implementations§

Source§

impl ObjectStore for MemObjectStore

Source§

fn put( &mut self, uri: &FabricUri, data: &[u8], opts: Option<PutOptions>, ) -> Result<()>

Store an object at the given URI. Read more
Source§

fn get(&self, uri: &FabricUri) -> Result<Option<ObjectData>>

Retrieve an object by URI. Read more
Source§

fn head(&self, uri: &FabricUri) -> Result<Option<ObjectInfo>>

Retrieve object metadata without reading the data.
Source§

fn delete(&mut self, uri: &FabricUri) -> Result<bool>

Delete an object by URI. Returns true if the object existed.
Source§

fn list(&self, _pool: &str, _bucket: &str, prefix: &str) -> Result<Vec<String>>

List object keys matching a prefix within a bucket. 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.