pub struct Lifecycle { /* private fields */ }Expand description
Where one offer is in its life.
Cheap and Clone, because it is a fact ABOUT an offer rather than the
offer itself. Constructing one in LifecycleState::Published is
possible only through publish, which is what makes “host-minted”
mean something.
Implementations§
Source§impl Lifecycle
impl Lifecycle
Sourcepub fn instance(&self) -> &InstanceId
pub fn instance(&self) -> &InstanceId
Which offer this is the state of.
Sourcepub fn state(&self) -> LifecycleState
pub fn state(&self) -> LifecycleState
The current state.
Sourcepub fn is_terminal(&self) -> bool
pub fn is_terminal(&self) -> bool
Whether this state accepts any further transition.
Sourcepub fn transition(&self, to: LifecycleState) -> Result<Self, LifecycleError>
pub fn transition(&self, to: LifecycleState) -> Result<Self, LifecycleError>
Move to to, refusing anything the machine does not allow.
§Errors
LifecycleError::AlreadyTerminal from any terminal state, and
LifecycleError::IllegalTransition for a move this machine does
not define.
Sourcepub fn expire(&self) -> Result<Self, LifecycleError>
pub fn expire(&self) -> Result<Self, LifecycleError>
Expire this offer.
Synthesizes no Response and authorizes
nothing. The return type carries a state and an id, and there is
no field or method through which a decision could arrive — which
is the point: an expiry default read out of an author-supplied
role would let a document decide what failing closed means.
§Errors
LifecycleError::AlreadyTerminal if it has already resolved.
Sourcepub fn has_elapsed(instance: &InteractionInstance, now_tick: i64) -> bool
pub fn has_elapsed(instance: &InteractionInstance, now_tick: i64) -> bool
Whether this offer’s TTL has elapsed at now_tick.
A pure comparison against the offer’s own minting tick and TTL. It
reads no clock: newt-interaction has no ambient authority, and
the caller’s clock is the one that matters.