Trait 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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§