Skip to main content

Module peer

Module peer 

Source
Expand description

NEST-7: the primitive — an activation returns an activation. NEST-7 — the primitive: an activation returns an activation.

A peer is an activation found by name, in this process or across the network; the caller cannot tell which. An activation returns one from a #[plexus_macros::peer] method:

ⓘ
#[plexus_macros::peer(list = "integrations")]
async fn integration(&self, name: &str) -> Result<Box<dyn forge::ForgePeer>, PeerError>; // typed
#[plexus_macros::peer(list = "dendrites", search = "find")]
async fn dendrite(&self, name: &str) -> Result<Box<dyn Peer>, PeerError>;               // untyped
  • Peer is the erased activation (dyn Activation cannot be written: Activation has an associated type). Every Activation + ChildRouter is one (the blanket impl below), RemoteChild included.
  • Interface is a peer’s shape, named and content-addressed: the IR of what it serves, its hash, and each method’s own hash; two peers with one hash serve one shape, and Interface::satisfies is the shape check.
  • PeerError is why a peer could not be returned, typed on the wire as an error item whose error_kind is the variant (not_grafted, shape_mismatch, …), never “method not found”.
  • A contract (a bodiless activation every method of which answers Result<T, E>) is a typed slot’s interface: the macro emits trait ForgePeer: Forge + Peer, its Contract (the interface and the Stamp its client was generated from), and ForgePeer for the client over a PeerTransport, which checks the backend’s interface against the stamp — equal, go; it still satisfies the stamp, say drift once and go; else PeerError::ShapeMismatch — and again whenever an item’s plexus_hash moves.

Structs§

Drift
The backend’s interface moved but still serves every method the stamp has: said once.
Interface
A peer’s shape, named and content-addressed: what <ns>.ir answers for it, its hash, and each method’s own hash. Two interfaces with one hash serve one shape (descriptions, grants and the name aside).
PeerRouter
A peer as a child router: what a #[peer] slot hands routing. Calls go to the peer’s call; its own peers are its children.
PeerSlot
A #[peer] slot as routing holds it: reached as <parent>.<slot>, its children are the peers the slot’s function returns by name — a typed slot’s checked against its interface first (ShapeMismatch by interface hash). <parent>.<slot>.<name>.<method> is a peer’s method.
PeerTransport
A transport for a contract’s client that checks the backend against the client’s Stamp: the backend’s interface is asked once (and again when an item’s plexus_hash moves); every item is watched for that.
RouterPeer
A child router (what routing holds) as a peer.
Stamp
What a generated client was built against: the interface’s name, the backend crate’s version, the interface hash and each method’s hash.

Enums§

PeerError
Why a peer could not be returned — each failure typed, on the wire as an error item whose error_kind is the variant’s snake_case name, its fields beside it.

Traits§

Contract
A contract’s shape, as a typed slot names it: implemented by the macro for dyn ForgePeer (a contract’s peer trait).
Peer
What a peer is: an activation, erased — dyn Activation cannot be written (the associated Methods type), so this is the object-safe form. Every Activation + ChildRouter is one.

Type Aliases§

FindPeer
How a #[peer] slot finds a peer by name: the slot’s function, with its activation.
ListPeers
How a #[peer] slot lists its names: its list sibling, collected.