Trait tc_transact::fs::Persist

source ·
pub trait Persist<FE: ThreadSafe + Clone>: Sized {
    type Txn: Transaction<FE>;
    type Schema: Clone + Send + Sync;

    // Required methods
    fn create<'async_trait>(
        txn_id: TxnId,
        schema: Self::Schema,
        store: Dir<FE>
    ) -> Pin<Box<dyn Future<Output = TCResult<Self>> + Send + 'async_trait>>
       where Self: 'async_trait;
    fn load<'async_trait>(
        txn_id: TxnId,
        schema: Self::Schema,
        store: Dir<FE>
    ) -> Pin<Box<dyn Future<Output = TCResult<Self>> + Send + 'async_trait>>
       where Self: 'async_trait;
    fn dir(&self) -> Inner<FE>;

    // Provided method
    fn load_or_create<'async_trait>(
        txn_id: TxnId,
        schema: Self::Schema,
        store: Dir<FE>
    ) -> Pin<Box<dyn Future<Output = TCResult<Self>> + Send + 'async_trait>>
       where Self: Send + 'async_trait { ... }
}
Expand description

Defines how to load a persistent data structure from the filesystem.

Required Associated Types§

Required Methods§

source

fn create<'async_trait>( txn_id: TxnId, schema: Self::Schema, store: Dir<FE> ) -> Pin<Box<dyn Future<Output = TCResult<Self>> + Send + 'async_trait>>
where Self: 'async_trait,

Create a new instance of Self from an empty Store.

source

fn load<'async_trait>( txn_id: TxnId, schema: Self::Schema, store: Dir<FE> ) -> Pin<Box<dyn Future<Output = TCResult<Self>> + Send + 'async_trait>>
where Self: 'async_trait,

Load a saved instance of Self from persistent storage. Should only be invoked at startup time.

source

fn dir(&self) -> Inner<FE>

Access the filesystem directory backing this persistent data structure.

Provided Methods§

source

fn load_or_create<'async_trait>( txn_id: TxnId, schema: Self::Schema, store: Dir<FE> ) -> Pin<Box<dyn Future<Output = TCResult<Self>> + Send + 'async_trait>>
where Self: Send + 'async_trait,

Load a saved instance of Self from persistent storage if present, or create a new one.

Object Safety§

This trait is not object safe.

Implementors§