Trait LocalLogStore

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

    // Required methods
    async fn get_log(
        &self,
        public_key: &PublicKey,
        log_id: &LogId,
        from: Option<u64>,
    ) -> Result<Option<Vec<(Header<Extensions>, Option<Body>)>>, Self::Error>;
    async fn get_raw_log(
        &self,
        public_key: &PublicKey,
        log_id: &LogId,
        from: Option<u64>,
    ) -> Result<Option<Vec<RawOperation>>, Self::Error>;
    async fn get_log_heights(
        &self,
        log_id: &LogId,
    ) -> Result<Vec<(PublicKey, u64)>, Self::Error>;
    async fn latest_operation(
        &self,
        public_key: &PublicKey,
        log_id: &LogId,
    ) -> Result<Option<(Header<Extensions>, Option<Body>)>, Self::Error>;
    async fn delete_operations(
        &mut self,
        public_key: &PublicKey,
        log_id: &LogId,
        before: u64,
    ) -> Result<bool, Self::Error>;
    async fn delete_payloads(
        &mut self,
        public_key: &PublicKey,
        log_id: &LogId,
        from: u64,
        to: u64,
    ) -> Result<bool, Self::Error>;
}
Expand description

Interface for storing, deleting and querying logs.

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 get_log( &self, public_key: &PublicKey, log_id: &LogId, from: Option<u64>, ) -> Result<Option<Vec<(Header<Extensions>, Option<Body>)>>, Self::Error>

Get operations from an authors’ log ordered by sequence number.

The from value will be used as the starting index for log retrieval, if supplied, otherwise all operations will be returned.

Returns None when either the author or a log with the requested id was not found.

Source

async fn get_raw_log( &self, public_key: &PublicKey, log_id: &LogId, from: Option<u64>, ) -> Result<Option<Vec<RawOperation>>, Self::Error>

Get “raw” header and body bytes from an authors’ log ordered by sequence number.

The from value will be used as the starting index for log retrieval, if supplied, otherwise all operations will be returned.

Returns None when either the author or a log with the requested id was not found.

Source

async fn get_log_heights( &self, log_id: &LogId, ) -> Result<Vec<(PublicKey, u64)>, Self::Error>

Get the log heights of all logs, by any author, which are stored under the passed log id.

Source

async fn latest_operation( &self, public_key: &PublicKey, log_id: &LogId, ) -> Result<Option<(Header<Extensions>, Option<Body>)>, Self::Error>

Get only the latest operation from an authors’ log.

Returns None when the author or a log with the requested id was not found.

Source

async fn delete_operations( &mut self, public_key: &PublicKey, log_id: &LogId, before: u64, ) -> Result<bool, Self::Error>

Delete all operations in a log before the given sequence number.

Returns true when any operations were deleted, returns false when the author or log could not be found, or no operations were deleted.

Source

async fn delete_payloads( &mut self, public_key: &PublicKey, log_id: &LogId, from: u64, to: u64, ) -> Result<bool, Self::Error>

Delete a range of operation payloads in an authors’ log.

The range of deleted payloads includes it’s lower bound from but excludes the upper bound to.

Returns true when operations within the requested range were deleted, or false when the author or log could not be found, or no operations were 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: LogStore<LogId, Extensions>> LocalLogStore<LogId, Extensions> for TraitVariantBlanketType

Source§

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