diff --git a/data-model/src/store.rs b/data-model/src/store.rs index b04abc6..da7effb 100644 --- a/data-model/src/store.rs +++ b/data-model/src/store.rs @@ -9,7 +9,7 @@ use crate::{ LengthyEntry, Path, }; -/// Returned when an entry is successfully ingested into a [`Store`]. +/// Returned when an entry could be ingested into a [`Store`]. pub enum EntryIngestionSuccess< const MCL: usize, const MCC: usize, @@ -32,6 +32,7 @@ pub enum EntryIngestionSuccess< }, } +/// Returned when an entry cannot be ingested into a [`Store`]. pub enum EntryIngestionError< const MCL: usize, const MCC: usize, @@ -45,6 +46,31 @@ pub enum EntryIngestionError< WrongNamespace(AuthorisedEntry), } +/// Returned when an entry failed to be ingested during a bulk ingestion. +pub enum BulkIngestionError< + const MCL: usize, + const MCC: usize, + const MPL: usize, + N: NamespaceId, + S: SubspaceId, + PD: PayloadDigest, + AT, +> { + /// The entry belonged to another namespace. + WrongNamespace(AuthorisedEntry), + /// The consumer failed for some reason. + ConsumerFailure, +} + +/// A tuple of an [`AuthorisedEntry`] and how a [`Store`] responded to its ingestion. +pub type BulkIngestionResult = ( + AuthorisedEntry, + Result< + EntryIngestionSuccess, + BulkIngestionError, + >, +); + /// Return when a payload is successfully appended to the [`Store`]. pub enum PayloadAppendSuccess where @@ -83,6 +109,8 @@ where PD: PayloadDigest, AT: AuthorisationToken, { + type FlushError; + /// The [namespace](https://willowprotocol.org/specs/data-model/index.html#namespace) which all of this store's [`AuthorisedEntry`] belong to. fn namespace_id() -> N; @@ -99,6 +127,12 @@ where >; // TODO: Bulk ingestion entry. The annoying there is it needs its own success / error types. We could get around this by exposing a BulkConsumer from the Store, but [then we need to support multi-writer consumption](https://github.com/earthstar-project/willow-rs/pull/21#issuecomment-2192393204). + /// Attempt to store an [`AuthorisedEntry`] in the [`Store`]. + /// Will fail if the entry belonged to a different namespace than the store's. + fn bulk_ingest_entry( + &self, + authorised_entries: &[AuthorisedEntry], + ) -> impl Future>>; /// Attempt to append part of a payload for a given [`AuthorisedEntry`]. /// @@ -181,5 +215,5 @@ where ) -> impl Future>; /// Force persistence of all previous mutations - fn flush() -> impl Future; + fn flush() -> impl Future>; }