BackingStore

Struct BackingStore 

Source
pub struct BackingStore<B: BackingStoreT> { /* private fields */ }
Expand description

A manager that wraps a BackingStoreT implementation, providing concurrency control, task management via a Tokio runtime, and tracking of persisted paths.

It handles potential races and deduplication of tasks, ensuring that multiple tasks can safely operate on the same backing store without conflicts.

Implementations§

Source§

impl<B: BackingStoreT> BackingStore<B>

Source

pub fn new(backing: B, runtime: Handle) -> Self

Creates a new BackingStore manager.

§Arguments
  • backing - The low-level BackingStoreT implementation.
  • runtime - A handle to a Tokio runtime used for spawning background tasks and managing async operations.

If all available blocking threads on this runtime are simultaneously attempting a blocking_load, there can potentially be a deadlock. Either don’t directly call spawn_blocking on this runtime or at least don’t saturate the blocking thread pool. Alternatively don’t use this runtime to call the blocking_* functions within file-backed, or else use a separate tokio runtime.

Source

pub fn track_path( self: &Arc<Self>, path: B::PersistPath, ) -> JoinHandle<TrackedPath<B::PersistPath>>

Asynchronously begins tracking the given persistence path.

It retrieves all keys currently persisted at the path using the iterator returned from BackingStoreT::sanitize_path and returns a JoinHandle resolving to a TrackedPath containing the path and keys.

Source

pub fn blocking_track_path( self: &Arc<Self>, path: B::PersistPath, ) -> TrackedPath<B::PersistPath>

Blocking version of track_path. Waits for the path tracking to complete. Must not be called from an async context that isn’t allowed to block.

Source

pub fn spawn_blocking<R: Send + 'static>( self: &Arc<Self>, f: impl FnOnce() -> R + Send + 'static, ) -> JoinHandle<R>

Spawns a blocking function f onto the store’s managed Tokio runtime’s blocking pool. Returns a JoinHandle to await the result R.

Source

pub fn task_tracker(&self) -> &TaskTracker

Returns a reference to the underlying TaskTracker used for detecting when all background tasks have completed.

Source

pub async fn finished(&self)

Returns a future that completes when all background tasks currently queued or running within this BackingStore instance have finished. This includes tasks like delayed deletions or background flushes.

Source

pub fn sync( self: &Arc<Self>, tracked: &Arc<TrackedPath<B::PersistPath>>, ) -> JoinHandle<()>

Asynchronously triggers the underlying BackingStoreT::sync_persisted operation for the given tracked path. Returns a JoinHandle that completes when the sync operation is done.

Source

pub fn blocking_sync(&self, path: &B::PersistPath)

Blocking version of sync. Calls BackingStoreT::sync_persisted and waits for completion. Must not be called from an async context that isn’t allowed to block.

Source

pub fn delete_persisted( self: &Arc<Self>, tracked: &Arc<TrackedPath<B::PersistPath>>, key: Uuid, ) -> JoinHandle<()>

Asynchronously triggers the underlying BackingStoreT::delete_persisted operation for the given key at the tracked path. Returns a JoinHandle that completes when the deletion is done.

Source

pub fn blocking_delete_persisted( &self, tracked: &TrackedPath<B::PersistPath>, key: Uuid, )

Blocking version of delete_persisted. Calls BackingStoreT::delete_persisted and waits for completion. Must not be called from an async context that isn’t allowed to block.

Auto Trait Implementations§

§

impl<B> Freeze for BackingStore<B>
where B: Freeze,

§

impl<B> !RefUnwindSafe for BackingStore<B>

§

impl<B> Send for BackingStore<B>

§

impl<B> Sync for BackingStore<B>

§

impl<B> Unpin for BackingStore<B>
where B: Unpin,

§

impl<B> !UnwindSafe for BackingStore<B>

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.