Skip to main content

LifeloopReceiptEmitter

Struct LifeloopReceiptEmitter 

Source
pub struct LifeloopReceiptEmitter<S: IdempotencyStore = InMemoryIdempotencyStore> { /* private fields */ }
Expand description

Concrete ReceiptEmitter for issue #14.

Holds a sequence generator and an idempotency store. The ReceiptEmitter::emit trait method takes a fully-built LifecycleReceipt (the seam from issue #7) and validates + idempotency-checks it. The richer Self::synthesize_and_emit entry point consumes a NegotiatedPlan + CallbackResponse + ReceiptContext and builds the receipt before storing it — that is the path issue #14 is delivering.

Implementations§

Source§

impl LifeloopReceiptEmitter<InMemoryIdempotencyStore>

Source

pub fn in_memory() -> Self

Construct an emitter backed by an in-memory idempotency store.

Source§

impl<S: IdempotencyStore> LifeloopReceiptEmitter<S>

Source

pub fn with_store(store: S) -> Self

Construct an emitter with a caller-supplied store (e.g. a database-backed implementation in production).

Source

pub fn store(&self) -> &S

Source

pub fn sequencer(&self) -> &SequenceGenerator

Source

pub fn synthesize_and_emit( &self, negotiated: &NegotiatedPlan, response: &CallbackResponse, ctx: &ReceiptContext, ) -> Result<LifecycleReceipt, ReceiptError>

Build, validate, and idempotency-check a receipt from a negotiation result + the client’s response.

Returns the canonical receipt (newly inserted, or the prior replay value when the same idempotency key is reused with the same content).

Trait Implementations§

Source§

impl<S: Debug + IdempotencyStore> Debug for LifeloopReceiptEmitter<S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<S: IdempotencyStore> ReceiptEmitter for LifeloopReceiptEmitter<S>

Source§

fn emit(&self, receipt: &LifecycleReceipt) -> Result<(), Self::Error>

Validate + idempotency-check an externally-built LifecycleReceipt. The richer Self::synthesize_and_emit is the path issue #14 is delivering; this trait method exists to satisfy the issue #7 seam contract for callers that already hold a built receipt.

Source§

type Error = ReceiptError

Error produced by the receipt sink.

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.