-
Notifications
You must be signed in to change notification settings - Fork 94
/
Copy pathmod.rs
26 lines (19 loc) · 972 Bytes
/
mod.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use std::future::Future;
use crate::envelope::Envelope;
pub mod memory;
pub mod sqlite;
/// A stack-like data structure that holds [`Envelope`]s.
pub trait EnvelopeStack: Send + std::fmt::Debug {
/// The error type that is returned when an error is encountered during reading or writing the
/// [`EnvelopeStack`].
type Error: std::fmt::Debug;
/// Pushes an [`Envelope`] on top of the stack.
fn push(&mut self, envelope: Box<Envelope>) -> impl Future<Output = Result<(), Self::Error>>;
/// Peeks the [`Envelope`] on top of the stack.
fn peek(&mut self) -> impl Future<Output = Result<Option<&Envelope>, Self::Error>>;
/// Pops the [`Envelope`] on top of the stack.
fn pop(&mut self) -> impl Future<Output = Result<Option<Box<Envelope>>, Self::Error>>;
/// Persists all envelopes in the [`EnvelopeStack`]s to external storage, if possible,
/// and consume the [`StackProvider`].
fn flush(self) -> Vec<Box<Envelope>>;
}