pub struct Frontdoor { /* private fields */ }Expand description
The directory of inbound requests.
Implementations§
Source§impl Frontdoor
impl Frontdoor
pub fn open(root: impl Into<PathBuf>) -> Result<Self>
Sourcepub fn open_default() -> Result<Self>
pub fn open_default() -> Result<Self>
~/.mecha/requests, where the drain writes.
pub fn root(&self) -> &Path
pub fn records(&self) -> Result<Vec<Record>>
pub fn record(&self, seq: i64) -> Result<Record>
Sourcepub fn write(&self, record: &Record) -> Result<()>
pub fn write(&self, record: &Record) -> Result<()>
Rewrite one record, atomically.
The recorded outbox ids are append-only, and the store enforces it.
outbox exists so “this was answered” outlives the draft that answered
it — but a re-triage builds its id list from its own session and would
overwrite the earlier drafts’ ids, losing the only durable record that
a first reply was ever staged. Same idiom as for_privileged_run: a
boundary that is a function, not a rule every caller must remember —
any id already on disk is merged back in rather than trusted to the
caller’s copy.
Sourcepub fn reconcile(&self, outbox: &OutboxStore) -> Result<Vec<Transition>>
pub fn reconcile(&self, outbox: &OutboxStore) -> Result<Vec<Transition>>
Advance anything whose draft has since been released or rejected.
The outbox is the truth about a draft, and this store is the truth
about a request. Neither writes into the other; this reads the first
and updates the second, which is why releasing a draft with
mecha outbox send — a different process, hours later, knowing nothing
about requests — still closes the loop. The alternative was a callback
from the outbox, which would have made every sink in the system learn
what a request is.
Called before list and next rather than only on demand: a state
that is only correct after you remember to run a verb is a state nobody
can trust, and the whole point of awaiting_me is that it answers
“what is on me right now”.