Skip to main content

MailboxStore

Struct MailboxStore 

Source
pub struct MailboxStore { /* private fields */ }

Implementations§

Source§

impl MailboxStore

Source

pub fn default_root() -> Result<PathBuf>

Source

pub fn open(root: impl Into<PathBuf>) -> Result<Self>

Source

pub fn from_config(cfg: &MessagesConfig) -> Result<Self>

Open from the messaging config — the single place that resolves the directory override and the limits, so the CLI (mecha msg) and the agents it talks to can never drift on which store or which caps.

Source

pub fn with_keep(self, keep_resolved: usize) -> Self

Source

pub fn with_limits(self, pending_cap: usize, max_body_bytes: usize) -> Self

Source

pub fn root(&self) -> &Path

Source

pub fn send( &self, to: &str, from: &str, from_session: Option<String>, body: &str, reply_to: Option<String>, taint: Taint, ) -> Result<SendOutcome>

Leave a message for to.

The lock makes the duplicate and cap checks atomic against concurrent senders; see the module doc for why this store locks on send where the outbox does not.

Source

pub fn messages_for(&self, recipient: &str) -> Result<Vec<MailboxMessage>>

Every message for recipient, oldest first, quarantining what cannot be read. Missing directory means an empty mailbox, not an error.

Source

pub fn pending_for(&self, recipient: &str) -> Result<Vec<MailboxMessage>>

Pending messages for recipient, oldest first.

Source

pub fn claim_pending( &self, recipient: &str, session_id: &str, ) -> Result<Vec<MailboxMessage>>

Claim everything pending for recipient: mark it delivered to session_id and return it, under the recipient’s lock so two live runs of one producer cannot both fold the same message.

Marked before the caller folds, and that ordering is a decision (see docs/MESSAGING-RESEARCH.md §6): the fold is a synchronous in-memory push in the same thread, so the window where a crash loses the fold is microseconds wide — and even then the full body sits here in the store, delivered_to naming the run that died. Nothing is ever only in a transcript.

A write failure partway through returns the messages already marked delivered rather than an error, and stops there. Those are on disk as delivered, so the caller must fold them or they are lost; the ones after the failure stay pending and are re-claimed next poll. Returning an error (and an empty batch from the route) would strand the already-marked ones — delivered in the store, folded into nothing.

Source

pub fn dismiss(&self, id: &str) -> Result<MailboxMessage>

Set a pending message aside unread. This is the human’s verb — a full mailbox refuses new sends, so there has to be a way to clear a backlog no run is coming to claim that is not deleting files by hand. The file stays as its own record, like a rejected outbox item.

Source

pub fn message(&self, id: &str) -> Result<MailboxMessage>

Find one message by id or unique prefix, across all recipients.

Source

pub fn recipients(&self) -> Result<Vec<String>>

Every recipient that has a mailbox directory.

Source

pub fn announce(&self, producer: &str, session_id: &str) -> Result<()>

Announce a live session, so mecha msg agents can answer “who is running”. One marker per session, grouped by producer — several live sessions of one producer is the normal worktree workflow, and a single per-producer file would make them fight over it. Advisory, like the trigger marker it generalises: the mailbox works without it.

Source

pub fn depart(&self, session_id: &str)

Remove a session’s marker. Best-effort: a marker whose pid is dead reads as absent anyway, so a hard kill costs nothing but tidiness.

Source

pub fn agents(&self) -> Result<Vec<AgentMarker>>

Live sessions, liveness-checked; stale markers are cleaned as found.

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

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

Source§

type Error = !

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

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more