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: PointIdThe point’s id.
kind: PointKindWhat it is for.
description: &'static strWhat 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: boolWhether 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: u32Its version, from 1 (PointSpec::version).
Implementations§
Source§impl PointDecl
impl PointDecl
Sourcepub const fn of<P: Point>(description: &'static str) -> PointDecl
pub const fn of<P: Point>(description: &'static str) -> PointDecl
The declaration of the point P, described by description.
Sourcepub const fn deadline(self, deadline: Duration) -> PointDecl
pub const fn deadline(self, deadline: Duration) -> PointDecl
The deadline of its listeners that set none.
Sourcepub const fn fail_closed(self) -> PointDecl
pub const fn fail_closed(self) -> PointDecl
A listener failure refuses the request
(PointSpec::fail_closed).
Sourcepub const fn needs(self, needs: &'static [&'static Contract]) -> PointDecl
pub const fn needs(self, needs: &'static [&'static Contract]) -> PointDecl
The contracts the point needs from the bus
(.needs(&[&bus_contract_defer::CONTRACT])).
Sourcepub const fn facets(self, facets: &'static [Facet]) -> PointDecl
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.
Sourcepub const fn budget(self, budget: Duration) -> PointDecl
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.
Sourcepub const fn version(self, version: u32) -> PointDecl
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.
Sourcepub fn required(&self) -> Vec<&'static Contract>
pub fn required(&self) -> Vec<&'static Contract>
The contracts the point needs: those it names
(PointDecl::needs), then those of its facets, each once.
Sourcepub fn spec(&self) -> PointSpec
pub fn spec(&self) -> PointSpec
The point’s spec, as Bus::declare_point takes it.