pub trait MailboxStore: Send + Sync {
type Msg;
type Task;
type Error: Error + Send + Sync + 'static;
// Required methods
fn post(&self, msg: &Self::Msg) -> Result<(), Self::Error>;
fn inbox(
&self,
team_id: &str,
to: &str,
) -> Result<Vec<Self::Msg>, Self::Error>;
fn claim(&self, message_id: Uuid) -> Result<bool, Self::Error>;
fn consume(&self, message_id: Uuid) -> Result<(), Self::Error>;
fn unclaim(&self, message_id: Uuid) -> Result<(), Self::Error>;
fn task_create(&self, task: &Self::Task) -> Result<(), Self::Error>;
fn task_update(
&self,
id: Uuid,
state: MailboxTaskState,
note: Option<&str>,
) -> Result<(), Self::Error>;
fn task_list(&self, team_id: &str) -> Result<Vec<Self::Task>, Self::Error>;
}Expand description
The MailboxStore port: durable mailbox + task list.
Implementations MUST guarantee atomic claim semantics: at most one caller
wins the race to claim a given message (i.e. Unread → Delivered is
exclusive).
Required Associated Types§
Required Methods§
Sourcefn inbox(&self, team_id: &str, to: &str) -> Result<Vec<Self::Msg>, Self::Error>
fn inbox(&self, team_id: &str, to: &str) -> Result<Vec<Self::Msg>, Self::Error>
Return all unread messages addressed to to in team_id.
Sourcefn claim(&self, message_id: Uuid) -> Result<bool, Self::Error>
fn claim(&self, message_id: Uuid) -> Result<bool, Self::Error>
Atomic claim: transition message state from Unread to Delivered.
Returns true iff this caller won the race (SQLite rowcount == 1).
Sourcefn unclaim(&self, message_id: Uuid) -> Result<(), Self::Error>
fn unclaim(&self, message_id: Uuid) -> Result<(), Self::Error>
Roll back a claim: transition message state from Delivered to Unread.
Sourcefn task_update(
&self,
id: Uuid,
state: MailboxTaskState,
note: Option<&str>,
) -> Result<(), Self::Error>
fn task_update( &self, id: Uuid, state: MailboxTaskState, note: Option<&str>, ) -> Result<(), Self::Error>
Advance a task’s state, optionally recording a note.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".