pub trait Store<const MCL: usize, const MCC: usize, const MPL: usize, N, S, PD, AT>: Clone {
type InternalError;
// Required methods
async fn create_entry<Data, P, H>(
&mut self,
data: &Data,
payload_producer: P,
payload_length: u64,
ingredients: &AT::Ingredients,
) -> Result<Option<AuthorisedEntry<MCL, MCC, MPL, N, S, PD, AT>>, CreateEntryError<Self::InternalError, P::Error, AT::CreationError>>
where Data: ?Sized + Namespaced<N> + Coordinatelike<MCL, MCC, MPL, S>,
P: BulkProducer<Item = u8, Final = ()>,
H: Default + Hasher<PD>,
AT: AuthorisationToken<MCL, MCC, MPL, N, S, PD> + Debug,
N: Debug,
S: Debug,
PD: Debug;
async fn create_entry_nondestructive<Data, P, H>(
&mut self,
data: &Data,
payload_producer: P,
payload_length: u64,
ingredients: &AT::Ingredients,
) -> Result<NondestructiveInsert<MCL, MCC, MPL, N, S, PD, AT>, CreateEntryError<Self::InternalError, P::Error, AT::CreationError>>
where Data: ?Sized + Namespaced<N> + Coordinatelike<MCL, MCC, MPL, S>,
P: BulkProducer<Item = u8, Final = ()>,
H: Default + Hasher<PD>,
AT: AuthorisationToken<MCL, MCC, MPL, N, S, PD> + Debug,
N: Debug,
S: Debug,
PD: Debug;
async fn insert_entry(
&mut self,
entry: AuthorisedEntry<MCL, MCC, MPL, N, S, PD, AT>,
) -> Result<bool, Self::InternalError>;
async fn forget_entry<K>(
&mut self,
namespace_id: &N,
key: &K,
expected_digest: Option<PD>,
) -> Result<bool, Self::InternalError>
where K: Keylike<MCL, MCC, MPL, S>,
PD: PartialEq;
async fn forget_area(
&mut self,
namespace_id: &N,
area: &Area<MCL, MCC, MPL, S>,
) -> Result<(), Self::InternalError>;
async fn forget_namespace(
&mut self,
namespace_id: &N,
) -> Result<(), Self::InternalError>;
async fn get_entry<K, Slice>(
&mut self,
namespace_id: &N,
key: &K,
expected_digest: Option<PD>,
payload_slice: &Slice,
) -> Result<Option<(AuthorisedEntry<MCL, MCC, MPL, N, S, PD, AT>, impl BulkProducer<Item = u8, Final = (), Error = PayloadProducerError<Self::InternalError>>)>, Self::InternalError>
where K: Keylike<MCL, MCC, MPL, S>,
Slice: RangeBounds<u64>;
async fn get_area(
&mut self,
namespace_id: N,
area: Area<MCL, MCC, MPL, S>,
) -> impl Producer<Item = AuthorisedEntry<MCL, MCC, MPL, N, S, PD, AT>, Final = (), Error = Self::InternalError>;
async fn flush(&mut self) -> Result<(), Self::InternalError>;
}Expand description
The most basic trait describing storage for Entry.
A Store is a collection of entries such that none of them would prefix-prune.
This trait provides only a very basic set of operations: creation of new entries, querying individual entries and all entries within an Area, local deletion, and accessing (subslices of) payloads. More specialised operations are provided by subtraits.
Stores must implement Clone, and the expectation is that cloning is cheap and that changes on one clone also affect all other clones. You perform concurrent operations on a store by cloning it and then performing the operations on different clones.
Important: persistent stores are not required to persist mutations immediately. Call the Store::flush method to ensure that an operation is persisted.
Required Associated Types§
Sourcetype InternalError
type InternalError
The type of errors the store implementation might yield on any operation.
Required Methods§
Sourceasync fn create_entry<Data, P, H>(
&mut self,
data: &Data,
payload_producer: P,
payload_length: u64,
ingredients: &AT::Ingredients,
) -> Result<Option<AuthorisedEntry<MCL, MCC, MPL, N, S, PD, AT>>, CreateEntryError<Self::InternalError, P::Error, AT::CreationError>>where
Data: ?Sized + Namespaced<N> + Coordinatelike<MCL, MCC, MPL, S>,
P: BulkProducer<Item = u8, Final = ()>,
H: Default + Hasher<PD>,
AT: AuthorisationToken<MCL, MCC, MPL, N, S, PD> + Debug,
N: Debug,
S: Debug,
PD: Debug,
async fn create_entry<Data, P, H>(
&mut self,
data: &Data,
payload_producer: P,
payload_length: u64,
ingredients: &AT::Ingredients,
) -> Result<Option<AuthorisedEntry<MCL, MCC, MPL, N, S, PD, AT>>, CreateEntryError<Self::InternalError, P::Error, AT::CreationError>>where
Data: ?Sized + Namespaced<N> + Coordinatelike<MCL, MCC, MPL, S>,
P: BulkProducer<Item = u8, Final = ()>,
H: Default + Hasher<PD>,
AT: AuthorisationToken<MCL, MCC, MPL, N, S, PD> + Debug,
N: Debug,
S: Debug,
PD: Debug,
Creates an AuthorisedEntry with the given data and payload, and atomically inserts the payload and entry into the store.
If the new entry would be prefix-pruned immediately by a newer entry already in the store, this method returns Ok(None). If the new entry prefix-prunes older entries in the store, those older entries are automatically removed.
If the producer does not error, it must yield exactly payload_length many items and then the final () — otherwise, this method panics.
Sourceasync fn create_entry_nondestructive<Data, P, H>(
&mut self,
data: &Data,
payload_producer: P,
payload_length: u64,
ingredients: &AT::Ingredients,
) -> Result<NondestructiveInsert<MCL, MCC, MPL, N, S, PD, AT>, CreateEntryError<Self::InternalError, P::Error, AT::CreationError>>where
Data: ?Sized + Namespaced<N> + Coordinatelike<MCL, MCC, MPL, S>,
P: BulkProducer<Item = u8, Final = ()>,
H: Default + Hasher<PD>,
AT: AuthorisationToken<MCL, MCC, MPL, N, S, PD> + Debug,
N: Debug,
S: Debug,
PD: Debug,
async fn create_entry_nondestructive<Data, P, H>(
&mut self,
data: &Data,
payload_producer: P,
payload_length: u64,
ingredients: &AT::Ingredients,
) -> Result<NondestructiveInsert<MCL, MCC, MPL, N, S, PD, AT>, CreateEntryError<Self::InternalError, P::Error, AT::CreationError>>where
Data: ?Sized + Namespaced<N> + Coordinatelike<MCL, MCC, MPL, S>,
P: BulkProducer<Item = u8, Final = ()>,
H: Default + Hasher<PD>,
AT: AuthorisationToken<MCL, MCC, MPL, N, S, PD> + Debug,
N: Debug,
S: Debug,
PD: Debug,
Creates an Entry with the given data and payload, and atomically inserts the payload and entry into the store, unless it would prune one or more older entries.
If the new entry would be prefix-pruned immediately by a newer entry already in the store, this method returns Ok(None). If the new entry prefix-prunes older entries in the store, the store remains unchanged
If the producer does not error, it must yield exactly payload_length many items and then the final () — otherwise, this method panics.
Sourceasync fn insert_entry(
&mut self,
entry: AuthorisedEntry<MCL, MCC, MPL, N, S, PD, AT>,
) -> Result<bool, Self::InternalError>
async fn insert_entry( &mut self, entry: AuthorisedEntry<MCL, MCC, MPL, N, S, PD, AT>, ) -> Result<bool, Self::InternalError>
Inserts a given AuthorisedEntry into the store.
If the new entry would be prefix-pruned immediately by a newer entry already in the store, this method returns Ok(false), otherwise Ok(true). If the new entry prefix-prunes older entries in the store, those older entries are automatically removed.
Sourceasync fn forget_entry<K>(
&mut self,
namespace_id: &N,
key: &K,
expected_digest: Option<PD>,
) -> Result<bool, Self::InternalError>
async fn forget_entry<K>( &mut self, namespace_id: &N, key: &K, expected_digest: Option<PD>, ) -> Result<bool, Self::InternalError>
Removes an entry and its payload from the store. Return Ok(true) if data was actually removed, and Ok(false) if there was no matching entry in the first place.
If the expected_digest is Some(pd), then the addressed entry is only forgotten if its payload digest is pd. If the payload digest does not match, the method returns Ok(false).
Forgetting is not the same as pruning! Subsequent joins with other Stores may bring the forgotten entry back.
Sourceasync fn forget_area(
&mut self,
namespace_id: &N,
area: &Area<MCL, MCC, MPL, S>,
) -> Result<(), Self::InternalError>
async fn forget_area( &mut self, namespace_id: &N, area: &Area<MCL, MCC, MPL, S>, ) -> Result<(), Self::InternalError>
Sourceasync fn forget_namespace(
&mut self,
namespace_id: &N,
) -> Result<(), Self::InternalError>
async fn forget_namespace( &mut self, namespace_id: &N, ) -> Result<(), Self::InternalError>
Sourceasync fn get_entry<K, Slice>(
&mut self,
namespace_id: &N,
key: &K,
expected_digest: Option<PD>,
payload_slice: &Slice,
) -> Result<Option<(AuthorisedEntry<MCL, MCC, MPL, N, S, PD, AT>, impl BulkProducer<Item = u8, Final = (), Error = PayloadProducerError<Self::InternalError>>)>, Self::InternalError>
async fn get_entry<K, Slice>( &mut self, namespace_id: &N, key: &K, expected_digest: Option<PD>, payload_slice: &Slice, ) -> Result<Option<(AuthorisedEntry<MCL, MCC, MPL, N, S, PD, AT>, impl BulkProducer<Item = u8, Final = (), Error = PayloadProducerError<Self::InternalError>>)>, Self::InternalError>
Gets an entry (or None if there is none) together with a producer its payload (more specifically, the indicated payload_slice).
If the expected_digest is Some(pd), then the addressed entry is only returned if its payload digest is pd. If the payload digest does not match, the method returns Ok(None).
If the start of the indicated payload slice is strictly greater than its end, or if its start is strictly greater than the length of the stored payload, the behaviour of this method is unspecified.
Sourceasync fn get_area(
&mut self,
namespace_id: N,
area: Area<MCL, MCC, MPL, S>,
) -> impl Producer<Item = AuthorisedEntry<MCL, MCC, MPL, N, S, PD, AT>, Final = (), Error = Self::InternalError>
async fn get_area( &mut self, namespace_id: N, area: Area<MCL, MCC, MPL, S>, ) -> impl Producer<Item = AuthorisedEntry<MCL, MCC, MPL, N, S, PD, AT>, Final = (), Error = Self::InternalError>
Returns a producer of all entries in some Area from the store.
Sourceasync fn flush(&mut self) -> Result<(), Self::InternalError>
async fn flush(&mut self) -> Result<(), Self::InternalError>
Flushes all prior operations. If the backing storage is persistent, all mutations up to that point will have been successfully persisted after a successful flush.
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.