Skip to main content

Lifecycle

Struct Lifecycle 

Source
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

Source

pub fn instance(&self) -> &InstanceId

Which offer this is the state of.

Source

pub fn state(&self) -> LifecycleState

The current state.

Source

pub fn is_terminal(&self) -> bool

Whether this state accepts any further transition.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for Lifecycle

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Lifecycle

Source§

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

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

impl Eq for Lifecycle

Source§

impl PartialEq for Lifecycle

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Lifecycle

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.