Struct MemoryStore

Source
pub struct MemoryStore<L, E = ()> { /* private fields */ }
Expand description

An in-memory store for core p2panda data types: Operation and log.

MemoryStore supports usage in asynchronous and multi-threaded contexts by wrapping an InnerMemoryStore with an RwLock and Arc. Convenience methods are provided to obtain a read- or write-lock on the underlying store.

Implementations§

Source§

impl<L, E> MemoryStore<L, E>

Source

pub fn new() -> Self

Create a new in-memory store.

Source§

impl<T, E> MemoryStore<T, E>

Source

pub fn read_store(&self) -> RwLockReadGuard<'_, InnerMemoryStore<T, E>>

Obtain a read-lock on the store.

Source

pub fn write_store(&self) -> RwLockWriteGuard<'_, InnerMemoryStore<T, E>>

Obtain a write-lock on the store.

Trait Implementations§

Source§

impl<L: Clone, E: Clone> Clone for MemoryStore<L, E>

Source§

fn clone(&self) -> MemoryStore<L, E>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<L: Debug, E: Debug> Debug for MemoryStore<L, E>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Default for MemoryStore<T, ()>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<L, E> LogStore<L, E> for MemoryStore<L, E>
where L: LogId + Send + Sync, E: Extensions + Send + Sync,

Source§

type Error = Infallible

Source§

async fn get_log( &self, public_key: &PublicKey, log_id: &L, from: Option<u64>, ) -> Result<Option<Vec<(Header<E>, Option<Body>)>>, Self::Error>

Get operations from an authors’ log ordered by sequence number. Read more
Source§

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

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

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

Get only the latest operation from an authors’ log. Read more
Source§

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

Delete all operations in a log before the given sequence number. Read more
Source§

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

Delete a range of operation payloads in an authors’ log. Read more
Source§

async fn get_log_heights( &self, log_id: &L, ) -> 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§

impl<L, E> OperationStore<L, E> for MemoryStore<L, E>
where L: LogId + Send + Sync, E: Extensions + Send + Sync,

Source§

type Error = Infallible

Source§

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

Insert an operation. Read more
Source§

async fn get_operation( &self, hash: Hash, ) -> Result<Option<(Header<E>, 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. Read more
Source§

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

Delete an operation. Read more
Source§

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

Delete the payload of an operation. Read more

Auto Trait Implementations§

§

impl<L, E> Freeze for MemoryStore<L, E>

§

impl<L, E> RefUnwindSafe for MemoryStore<L, E>

§

impl<L, E> Send for MemoryStore<L, E>
where L: Send + Sync, E: Send + Sync,

§

impl<L, E> Sync for MemoryStore<L, E>
where L: Send + Sync, E: Send + Sync,

§

impl<L, E> Unpin for MemoryStore<L, E>

§

impl<L, E> UnwindSafe for MemoryStore<L, E>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<LogId, Extensions, TraitVariantBlanketType> LocalLogStore<LogId, Extensions> for TraitVariantBlanketType
where TraitVariantBlanketType: LogStore<LogId, Extensions>,

Source§

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

Source§

async fn get_log( &self, public_key: &PublicKey, log_id: &LogId, from: Option<u64>, ) -> Result<Option<Vec<(Header<Extensions>, Option<Body>)>>, <TraitVariantBlanketType as LocalLogStore<LogId, Extensions>>::Error>

Get operations from an authors’ log ordered by sequence number. Read more
Source§

async fn get_raw_log( &self, public_key: &PublicKey, log_id: &LogId, from: Option<u64>, ) -> Result<Option<Vec<(Vec<u8>, Option<Vec<u8>>)>>, <TraitVariantBlanketType as LocalLogStore<LogId, Extensions>>::Error>

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

async fn get_log_heights( &self, log_id: &LogId, ) -> Result<Vec<(PublicKey, u64)>, <TraitVariantBlanketType as LocalLogStore<LogId, Extensions>>::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>)>, <TraitVariantBlanketType as LocalLogStore<LogId, Extensions>>::Error>

Get only the latest operation from an authors’ log. Read more
Source§

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

Delete all operations in a log before the given sequence number. Read more
Source§

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

Delete a range of operation payloads in an authors’ log. Read more
Source§

impl<LogId, Extensions, TraitVariantBlanketType> LocalOperationStore<LogId, Extensions> for TraitVariantBlanketType
where TraitVariantBlanketType: OperationStore<LogId, Extensions>,

Source§

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

Source§

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

Insert an operation. Read more
Source§

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

Get an operation.
Source§

async fn get_raw_operation( &self, hash: Hash, ) -> Result<Option<(Vec<u8>, Option<Vec<u8>>)>, <TraitVariantBlanketType as LocalOperationStore<LogId, Extensions>>::Error>

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

async fn has_operation( &self, hash: Hash, ) -> Result<bool, <TraitVariantBlanketType as LocalOperationStore<LogId, Extensions>>::Error>

Query the existence of an operation. Read more
Source§

async fn delete_operation( &mut self, hash: Hash, ) -> Result<bool, <TraitVariantBlanketType as LocalOperationStore<LogId, Extensions>>::Error>

Delete an operation. Read more
Source§

async fn delete_payload( &mut self, hash: Hash, ) -> Result<bool, <TraitVariantBlanketType as LocalOperationStore<LogId, Extensions>>::Error>

Delete the payload of an operation. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more