Skip to main content

BackendObserver

Trait BackendObserver 

Source
pub trait BackendObserver: Send + Sync {
    // Provided methods
    fn link_fact(&self, _fact: LinkFact) { ... }
    fn e2e_message(&self, _message: &ApplicationMessage) { ... }
    fn custom_envelope(&self, _from: Did, _bytes: &[u8]) { ... }
}
Expand description

Observer of what the Backend reads from the application inbox but does not act on itself: the peer facts, and the E2E messages it routes to no protocol.

The backend hands the observer each item in inbox order, before it reads the next. Facts are the swarm’s logical conclusions, never a physical connection state. The observer must not block: it runs on the inbox’s one reader.

A fact reaches the observer as soon as it is read, while the custom messages read before it may still wait in their namespace’s queue: facts keep their order among themselves and with E2E messages, but may overtake custom messages.

Provided Methods§

A fact about this node’s link to one peer, the same fact every namespace’s queue is given: LinkFact::Admitted when the peer’s transport is ready and it joined the local DHT, LinkFact::Retired when it left, whichever physical event or local decision caused it, and LinkFact::Dropped when the core’s inbox dropped a message from it.

Source

fn e2e_message(&self, _message: &ApplicationMessage)

An E2E message (handshake or stream frame) addressed to this node.

Source

fn custom_envelope(&self, _from: Did, _bytes: &[u8])

An inbound serialized extension Envelope received from from before it is queued onto its namespace worker.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§