Trait LocalOperationStore

Source
pub trait LocalOperationStore<LogId, Extensions>: Clone {
    type Error: Display + Debug;

    // Required methods
    async fn insert_operation(
        &mut self,
        hash: Hash,
        header: &Header<Extensions>,
        body: Option<&Body>,
        header_bytes: &[u8],
        log_id: &LogId,
    ) -> Result<bool, Self::Error>;
    async fn get_operation(
        &self,
        hash: Hash,
    ) -> Result<Option<(Header<Extensions>, Option<Body>)>, Self::Error>;
    async fn get_raw_operation(
        &self,
        hash: Hash,
    ) -> Result<Option<RawOperation>, Self::Error>;
    async fn has_operation(&self, hash: Hash) -> Result<bool, Self::Error>;
    async fn delete_operation(
        &mut self,
        hash: Hash,
    ) -> Result<bool, Self::Error>;
    async fn delete_payload(&mut self, hash: Hash) -> Result<bool, Self::Error>;
}
Expand description

Interface for storing, deleting and querying operations.

Two variants of the trait are provided: one which is thread-safe (implementing Sync) and one which is purely intended for single-threaded execution contexts.

Required Associated Types§

Required Methods§

Source

async fn insert_operation( &mut self, hash: Hash, header: &Header<Extensions>, body: Option<&Body>, header_bytes: &[u8], log_id: &LogId, ) -> Result<bool, Self::Error>

Insert an operation.

Returns true when the insert occurred, or false when the operation already existed and no insertion occurred.

Source

async fn get_operation( &self, hash: Hash, ) -> Result<Option<(Header<Extensions>, Option<Body>)>, Self::Error>

Get an operation.

Source

async fn get_raw_operation( &self, hash: Hash, ) -> Result<Option<RawOperation>, Self::Error>

Get the “raw” header and body bytes of an operation.

Source

async fn has_operation(&self, hash: Hash) -> Result<bool, Self::Error>

Query the existence of an operation.

Returns true if the operation was found in the store and false if not.

Source

async fn delete_operation(&mut self, hash: Hash) -> Result<bool, Self::Error>

Delete an operation.

Returns true when the removal occurred and false when the operation was not found in the store.

Source

async fn delete_payload(&mut self, hash: Hash) -> Result<bool, Self::Error>

Delete the payload of an operation.

Returns true when the removal occurred and false when the operation was not found in the store or the payload was already deleted.

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<LogId, Extensions, TraitVariantBlanketType: OperationStore<LogId, Extensions>> LocalOperationStore<LogId, Extensions> for TraitVariantBlanketType

Source§

type Error = <TraitVariantBlanketType as OperationStore<LogId, Extensions>>::Error