Skip to main content

MailboxStore

Trait MailboxStore 

Source
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§

Source

type Msg

The message type stored by this implementation.

Source

type Task

The task type stored by this implementation.

Source

type Error: Error + Send + Sync + 'static

The error type returned by store operations.

Required Methods§

Source

fn post(&self, msg: &Self::Msg) -> Result<(), Self::Error>

Post a message into the mailbox.

Source

fn inbox(&self, team_id: &str, to: &str) -> Result<Vec<Self::Msg>, Self::Error>

Return all unread messages addressed to to in team_id.

Source

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).

Source

fn consume(&self, message_id: Uuid) -> Result<(), Self::Error>

Mark a message as Consumed.

Source

fn unclaim(&self, message_id: Uuid) -> Result<(), Self::Error>

Roll back a claim: transition message state from Delivered to Unread.

Source

fn task_create(&self, task: &Self::Task) -> Result<(), Self::Error>

Insert a new task.

Source

fn task_update( &self, id: Uuid, state: MailboxTaskState, note: Option<&str>, ) -> Result<(), Self::Error>

Advance a task’s state, optionally recording a note.

Source

fn task_list(&self, team_id: &str) -> Result<Vec<Self::Task>, Self::Error>

Return all tasks for a team.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§