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>
impl<L, E> MemoryStore<L, E>
Source§impl<T, E> MemoryStore<T, E>
impl<T, E> MemoryStore<T, E>
Sourcepub fn read_store(&self) -> RwLockReadGuard<'_, InnerMemoryStore<T, E>>
pub fn read_store(&self) -> RwLockReadGuard<'_, InnerMemoryStore<T, E>>
Obtain a read-lock on the store.
Sourcepub fn write_store(&self) -> RwLockWriteGuard<'_, InnerMemoryStore<T, E>>
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>
impl<L: Clone, E: Clone> Clone for MemoryStore<L, E>
Source§fn clone(&self) -> MemoryStore<L, E>
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)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T> Default for MemoryStore<T, ()>
impl<T> Default for MemoryStore<T, ()>
Source§impl<L, E> LogStore<L, E> for MemoryStore<L, E>
impl<L, E> LogStore<L, E> for MemoryStore<L, E>
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>
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>
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>
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>
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§impl<L, E> OperationStore<L, E> for MemoryStore<L, E>
impl<L, E> OperationStore<L, E> for MemoryStore<L, E>
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>
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>
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>
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>
async fn has_operation(&self, hash: Hash) -> Result<bool, Self::Error>
Query the existence 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>
impl<L, E> Sync for MemoryStore<L, E>
impl<L, E> Unpin for MemoryStore<L, E>
impl<L, E> UnwindSafe for MemoryStore<L, E>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<LogId, Extensions, TraitVariantBlanketType> LocalLogStore<LogId, Extensions> for TraitVariantBlanketTypewhere
TraitVariantBlanketType: LogStore<LogId, Extensions>,
impl<LogId, Extensions, TraitVariantBlanketType> LocalLogStore<LogId, Extensions> for TraitVariantBlanketTypewhere
TraitVariantBlanketType: LogStore<LogId, Extensions>,
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>
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>
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>
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>
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§impl<LogId, Extensions, TraitVariantBlanketType> LocalOperationStore<LogId, Extensions> for TraitVariantBlanketTypewhere
TraitVariantBlanketType: OperationStore<LogId, Extensions>,
impl<LogId, Extensions, TraitVariantBlanketType> LocalOperationStore<LogId, Extensions> for TraitVariantBlanketTypewhere
TraitVariantBlanketType: OperationStore<LogId, Extensions>,
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>
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>
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>
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>
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>
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>
async fn delete_payload( &mut self, hash: Hash, ) -> Result<bool, <TraitVariantBlanketType as LocalOperationStore<LogId, Extensions>>::Error>
Delete the payload of an operation. Read more