Skip to main content

PointDecl

Struct PointDecl 

Source
pub struct PointDecl {
    pub id: PointId,
    pub kind: PointKind,
    pub description: &'static str,
    pub deadline: Option<Duration>,
    pub fail_closed: bool,
    pub needs: &'static [&'static Contract],
    pub facets: &'static [Facet],
    pub budget: Option<Duration>,
    pub version: u32,
    /* private fields */
}
Expand description

One line of a library’s contract table: a point it declares, built from the point’s type in a const (PointDecl::of::<DocClose>(…)), so the application can read what a library will host before building anything. declare_all declares a table on a bus.

What a point needs from a capability contract is data of that contract, made by its crate in a const: a Contract in PointDecl::needs, a Facet in PointDecl::facets:

ⓘ
const CODEC: Codec = Codec::of::<DocChanged>();
const TABLE: &[PointDecl] = &[
    PointDecl::of::<DocAsk>("asked after the frame").needs(&[&bus_contract_defer::CONTRACT]),
    PointDecl::of::<DocChanged>("a document changed")
        .facets(&[bus_contract_journal::JOURNALED, bus_contract_crossing::relayable(&CODEC)]),
];

Fields§

§id: PointId

The point’s id.

§kind: PointKind

What it is for.

§description: &'static str

What it does, for people and agents reading introspection.

§deadline: Option<Duration>

The deadline of its listeners that set none; None takes the bus’s.

§fail_closed: bool

Whether a listener failure refuses the request (PointSpec::fail_closed).

§needs: &'static [&'static Contract]

The contracts the point needs from the bus, besides those of its facets: declare_all refuses it on a bus without them.

§facets: &'static [Facet]

What its declaration says for capability contracts (PointSpec::facets); each needs its contract.

§budget: Option<Duration>

The time one pass of its listeners should take (PointSpec::budget).

§version: u32

Its version, from 1 (PointSpec::version).

Implementations§

Source§

impl PointDecl

Source

pub const fn of<P: Point>(description: &'static str) -> PointDecl

The declaration of the point P, described by description.

Source

pub const fn deadline(self, deadline: Duration) -> PointDecl

The deadline of its listeners that set none.

Source

pub const fn fail_closed(self) -> PointDecl

A listener failure refuses the request (PointSpec::fail_closed).

Source

pub const fn needs(self, needs: &'static [&'static Contract]) -> PointDecl

The contracts the point needs from the bus (.needs(&[&bus_contract_defer::CONTRACT])).

Source

pub const fn facets(self, facets: &'static [Facet]) -> PointDecl

What its declaration says for capability contracts (.facets(&[bus_contract_journal::JOURNALED])); each facet’s contract is needed.

Source

pub const fn budget(self, budget: Duration) -> PointDecl

The time one pass of its listeners should take (PointSpec::budget); reported when over, never failed. It needs no capability: on a bus without the timings contract it is only shown.

Source

pub const fn version(self, version: u32) -> PointDecl

Its version, from 1 (PointSpec::version): raise it when the payload changes in a way an older reader cannot use. Two processes cross the point only at the same version.

Source

pub fn required(&self) -> Vec<&'static Contract>

The contracts the point needs: those it names (PointDecl::needs), then those of its facets, each once.

Source

pub fn key(&self) -> PointKey

The point’s key.

Source

pub fn spec(&self) -> PointSpec

The point’s spec, as Bus::declare_point takes it.

Trait Implementations§

Source§

impl Clone for PointDecl

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 Copy for PointDecl

Source§

impl Debug for PointDecl

Source§

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

Formats the value using the given formatter. 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> 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.