Trait VersionedDataSource

Source
pub trait VersionedDataSource: Send + Sync {
    type Transaction<'a>: Transaction
       where Self: 'a;
    type ReadOnly<'a>: Transaction
       where Self: 'a;

    // Required methods
    fn write(
        &self,
    ) -> impl Future<Output = Result<Self::Transaction<'_>>> + Send;
    fn read(&self) -> impl Future<Output = Result<Self::ReadOnly<'_>>> + Send;
}
Expand description

A data source with an atomic transaction-based synchronization interface.

Changes are made to a versioned data source through a Transaction. Any changes made in a Transaction are initially visible only when queried through that same Transaction. They are not immediately written back to storage, which means that a new data source object opened against the same persistent storage will not reflect the changes. In particular, this means that if the process restarts and reopens its storage, uncommitted changes will be lost.

Only when a Transaction is committed are changes written back to storage, synchronized with any concurrent changes, and made visible to other connections to the same data source.

Required Associated Types§

Source

type Transaction<'a>: Transaction where Self: 'a

A transaction which can read and modify the data source.

Source

type ReadOnly<'a>: Transaction where Self: 'a

Required Methods§

Source

fn write(&self) -> impl Future<Output = Result<Self::Transaction<'_>>> + Send

Start an atomic transaction on the data source.

Source

fn read(&self) -> impl Future<Output = Result<Self::ReadOnly<'_>>> + Send

Start a read-only transaction on the data source.

A read-only transaction allows the owner to string together multiple queries of the data source, which otherwise would not be atomic with respect to concurrent writes, in an atomic fashion. Upon returning, read locks in a fully consistent snapshot of the data source, and any read operations performed upon the transaction thereafter read from the same consistent snapshot. Concurrent modifications to the data source may occur (for example, from concurrent write transactions being committed), but their results will not be reflected in a successful read-only transaction which was opened before the write was committed.

Read-only transactions do not need to be committed, and reverting has no effect.

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§

Source§

impl VersionedDataSource for SqlStorage

Source§

type Transaction<'a> = Transaction<Write> where Self: 'a

Source§

type ReadOnly<'a> = Transaction<Read> where Self: 'a

Source§

impl<D, U> VersionedDataSource for ExtensibleDataSource<D, U>
where D: VersionedDataSource + Send, U: Send + Sync,

Source§

type Transaction<'a> = <D as VersionedDataSource>::Transaction<'a> where Self: 'a

Source§

type ReadOnly<'a> = <D as VersionedDataSource>::ReadOnly<'a> where Self: 'a

Source§

impl<Types, S, P> VersionedDataSource for Fetcher<Types, S, P>
where Types: NodeType, S: VersionedDataSource + Send + Sync, P: Send + Sync,

Source§

type Transaction<'a> = <S as VersionedDataSource>::Transaction<'a> where Self: 'a

Source§

type ReadOnly<'a> = <S as VersionedDataSource>::ReadOnly<'a> where Self: 'a

Source§

impl<Types, S, P> VersionedDataSource for FetchingDataSource<Types, S, P>
where Types: NodeType, S: VersionedDataSource + Send + Sync, P: Send + Sync,

Source§

type Transaction<'a> = <S as VersionedDataSource>::Transaction<'a> where Self: 'a

Source§

type ReadOnly<'a> = <S as VersionedDataSource>::ReadOnly<'a> where Self: 'a

Source§

impl<Types: NodeType> VersionedDataSource for FileSystemStorage<Types>
where Header<Types>: QueryableHeader<Types>, Payload<Types>: QueryablePayload<Types>,

Source§

type Transaction<'a> = Transaction<RwLockWriteGuard<'a, FileSystemStorageInner<Types>>> where Self: 'a

Source§

type ReadOnly<'a> = Transaction<RwLockReadGuard<'a, FileSystemStorageInner<Types>>> where Self: 'a