Skip to main content

MemoryRegistry

Struct MemoryRegistry 

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

An in-memory synchronous registry seeded with a fixed set of pacts.

Implementations§

Source§

impl MemoryRegistry

Source

pub fn new(lease_millis: u64) -> Self

Create an empty registry that leases claims for lease_millis.

Source

pub fn seeded(pacts: Vec<Pact>, lease_millis: u64) -> Self

Create a registry holding pacts, each available to claim, leasing claims for lease_millis.

Trait Implementations§

Source§

impl Registry for MemoryRegistry

Source§

type Error = NotHeld

Error returned by the registry implementation.
Source§

fn claim( &self, dockets: &[&str], now: Timestamp, ) -> Result<Option<Claim>, Self::Error>

Claim a pact for execution from one of the requested dockets, using now to set the new lease and to reclaim any pact whose lease already expired without settlement — a lapse, realized through this normal claim path. Reclaiming rotates the retainer, so the prior holder can no longer settle.
Source§

fn lease_millis(&self) -> u64

The backend’s lease duration in milliseconds, used by heartbeat to compute the extended lease. Lease sizing is the backend’s; the contract supplies the mechanism, not a constant.
Source§

fn apply( &self, _retainer: &Retainer, transition: &Transition<'_>, ) -> Result<(), Self::Error>

Apply a lifecycle transition to the pact held by retainer, within the backend’s own atomic scope. transition is the pure kernel decision (a lifecycle on_X): the backend loads the held state, computes the next state through transition, and applies it atomically — it never decides the transition itself, so the lifecycle semantics stay single-sourced in the kernel and cannot drift. A transition applied against a pact the retainer no longer holds resolves to a not-current-holder error (the kernel’s NotCurrentHolder surfaces through transition). This is the one transition port; the four transition operations below are provided over it. Read more
Source§

fn heartbeat( &self, retainer: &Retainer, now: Timestamp, ) -> Result<(), Self::Error>

Extend the retainer’s lease using now. A heartbeat presented after the lease already expired is rejected: the holder must claim again rather than revive a lapsed lease, so two holders never both hold settlement authority.
Source§

fn fulfill(&self, retainer: &Retainer) -> Result<(), Self::Error>

Mark the pact as successfully fulfilled. Rejected when the retainer is not the current holder.
Source§

fn breach(&self, retainer: &Retainer) -> Result<(), Self::Error>

Mark the pact as breached. Rejected when the retainer is not the current holder. Shares the settlement transition with fulfill — the lifecycle records that the obligation concluded, not which outcome concluded it.
Source§

fn release( &self, retainer: &Retainer, reclaimable_at: Timestamp, ) -> Result<(), Self::Error>

Release the claim without concluding the obligation, making the pact reclaimable again only at or after reclaimable_at. Read more

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.