pub trait BatchStore {
type Error: Error;
// Required methods
fn get(
&self,
id: &BatchId,
) -> impl Future<Output = Result<Option<Batch>, Self::Error>> + Send;
fn put(
&self,
batch: Batch,
) -> impl Future<Output = Result<(), Self::Error>> + Send;
fn remove(
&self,
id: &BatchId,
) -> impl Future<Output = Result<bool, Self::Error>> + Send;
fn contains(
&self,
id: &BatchId,
) -> impl Future<Output = Result<bool, Self::Error>> + Send;
fn context(
&self,
) -> impl Future<Output = Result<PostageContext, Self::Error>> + Send;
fn set_context(
&self,
state: PostageContext,
) -> impl Future<Output = Result<(), Self::Error>> + Send;
fn batch_ids(
&self,
) -> impl Future<Output = Result<Vec<BatchId>, Self::Error>> + Send;
fn count(&self) -> impl Future<Output = Result<usize, Self::Error>> + Send;
}Available on crate feature
std only.Expand description
A trait for storing and retrieving batches.
Implementations may persist batches in memory, on disk, or retrieve them from a remote source such as a blockchain node.
§Async Design
This trait uses async methods to support both local (fast) and remote (potentially slow) storage backends without blocking.
Required Associated Types§
Required Methods§
Sourcefn get(
&self,
id: &BatchId,
) -> impl Future<Output = Result<Option<Batch>, Self::Error>> + Send
fn get( &self, id: &BatchId, ) -> impl Future<Output = Result<Option<Batch>, Self::Error>> + Send
Retrieves a batch by its ID.
Returns None if the batch doesn’t exist.
Sourcefn put(
&self,
batch: Batch,
) -> impl Future<Output = Result<(), Self::Error>> + Send
fn put( &self, batch: Batch, ) -> impl Future<Output = Result<(), Self::Error>> + Send
Stores or updates a batch.
Sourcefn remove(
&self,
id: &BatchId,
) -> impl Future<Output = Result<bool, Self::Error>> + Send
fn remove( &self, id: &BatchId, ) -> impl Future<Output = Result<bool, Self::Error>> + Send
Removes a batch from the store.
Returns true if the batch existed and was removed.
Sourcefn contains(
&self,
id: &BatchId,
) -> impl Future<Output = Result<bool, Self::Error>> + Send
fn contains( &self, id: &BatchId, ) -> impl Future<Output = Result<bool, Self::Error>> + Send
Checks if a batch exists in the store.
Sourcefn context(
&self,
) -> impl Future<Output = Result<PostageContext, Self::Error>> + Send
fn context( &self, ) -> impl Future<Output = Result<PostageContext, Self::Error>> + Send
Returns the current postage context.
Sourcefn set_context(
&self,
state: PostageContext,
) -> impl Future<Output = Result<(), Self::Error>> + Send
fn set_context( &self, state: PostageContext, ) -> impl Future<Output = Result<(), Self::Error>> + Send
Updates the postage context.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".