Skip to main content

SqliteMailboxStore

Struct SqliteMailboxStore 

Source
pub struct SqliteMailboxStore { /* private fields */ }
Expand description

A MailboxStore backed by a SQLite database.

Thread safety: a Mutex<Connection> serialises all writes, which is sufficient for the atomic-claim guarantee (the UPDATE WHERE state='unread' rowcount test).

Implementations§

Source§

impl SqliteMailboxStore

Source

pub fn open(path: &str) -> Result<Self, StoreError>

Open (or create) a store at the given file path.

Source

pub fn open_in_memory() -> Result<Self, StoreError>

Open a transient in-memory store (useful in tests).

Trait Implementations§

Source§

impl MailboxStore for SqliteMailboxStore

Source§

type Msg = Message

The message type stored by this implementation.
Source§

type Task = Task

The task type stored by this implementation.
Source§

type Error = StoreError

The error type returned by store operations.
Source§

fn post(&self, msg: &Message) -> Result<(), StoreError>

Post a message into the mailbox.
Source§

fn inbox(&self, team_id: &str, to: &str) -> Result<Vec<Message>, StoreError>

Return all unread messages addressed to to in team_id.
Source§

fn claim(&self, message_id: Uuid) -> Result<bool, StoreError>

Atomic claim: transition message state from Unread to Delivered. Read more
Source§

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

Mark a message as Consumed.
Source§

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

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

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

Insert a new task.
Source§

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

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

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

Return all tasks for a team.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.