Skip to main content

Crate printobserver_store_api

Crate printobserver_store_api 

Source
Expand description

printobserver-store-api.

Owns: the port durable state speaks through: the trait for recording and replaying observations, decisions and job history, the shapes its methods carry, the two constants and the one resolution the history read is specified by, plus that port’s own error type.

May depend on: printobserver-types only. A port that named an implementation would stop being a port.

§The history read has four behavioural facts, and they are settled here

A signature carries none of them, and a trait that is structurally exact with all four unstated is an incomplete port, so this crate leaves an implementation exactly one answer to take for each rather than leaving them to whoever implements the trait:

  1. The default history window is DEFAULT_HISTORY_WINDOW.
  2. The maximum history limit is MAX_HISTORY_LIMIT, and it is above the default.
  3. StorePort::history answers newest first.
  4. An empty kinds in a HistoryQuery means every kind, not no kinds.

The limit rule has one implementation here too — resolve_history_limit — so that refusing rather than clamping is a property of this contract and not of whoever implemented the trait. There is exactly one exported constant of each kind and exactly one exported resolution, so a consumer has one thing to import and no choice to make.

Whether an implementation obeys the four is proven where the implementations are, by one conformance suite driving both of them.

§Minting an identifier

StorePort::record_action is the only method that takes an ActionRequest or a PolicyDecision at all, and it takes them only together, so this surface offers no way to ask for a fresh ActionId for a request whose decision was not recorded beside it. Other methods answer records that may carry an identifier an earlier record_action minted — StorePort::append_event answers an EventRecord whose action-event payloads carry one — and that is stated rather than forbidden. That no method but record_action mints one is a property of an implementation’s bodies rather than of a signature, and is established by the store implementation’s own conformance suite.

§Why the methods answer a boxed future

Every method is asynchronous, and the trait is dyn-compatible and shareable across threads, because the supervision core holds all four ports behind Arc<dyn Port>. An async fn in a trait is not dyn-compatible, so each method answers a BoxFuture instead.

Structs§

AuditPage
One page of a print’s whole history, and the cursor that follows it.
EventDraft
One event on its way into the store, before the store mints its identifier.
HistoryQuery
Which of a print’s events to read.

Enums§

ImageLookup
What the store found when asked for an image.
SettleOutcome
What settling an intervention did.
StoreError
Why the store did not do what it was asked.

Constants§

DEFAULT_HISTORY_WINDOW
How many events a history read answers when the caller asks for no limit.
MAX_HISTORY_LIMIT
The most events a history read will answer, however many are asked for.

Traits§

StorePort
The port durable state speaks through.

Functions§

resolve_history_limit
Resolve the limit a history read asks for, refusing one above the maximum.

Type Aliases§

BoxFuture
A future this port’s methods answer with, in the one shape a trait object can carry.