Skip to main content

Peer

Trait Peer 

Source
pub trait Peer: Send + Sync {
    // Required methods
    fn db_name(&self) -> &str;
    fn db<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Db, ClientError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn transact<'life0, 'async_trait>(
        &'life0 self,
        tx: TxData,
    ) -> Pin<Box<dyn Future<Output = Result<TxReport, ClientError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn sync<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Db, ClientError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

A live connection to a database, backed either by the local peer library or a remote peer server.

Both LocalPeer and RemotePeer implement this trait, so code can be written once against impl Peer and run against either backend.

Required Methods§

Source

fn db_name(&self) -> &str

The connected database name.

Source

fn db<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Db, ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

The current database value.

§Errors

Returns ClientError on transport failure.

Source

fn transact<'life0, 'async_trait>( &'life0 self, tx: TxData, ) -> Pin<Box<dyn Future<Output = Result<TxReport, ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Submits a transaction and waits until it is applied, returning a report whose db_after observes it.

§Errors

Returns ClientError for rejected transactions or transport failure.

Source

fn sync<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Db, ClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Waits until the local view reaches the transactor’s current basis and returns the resulting database value.

§Errors

Returns ClientError on transport failure.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§