pub trait Node: Send + Sized + 'static {
    type Builder: NodeBuilder<Self>;
    type Backend: StorageBackend;
    type Error: Error;

    fn stop<'async_trait>(
        self
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
    where
        Self: 'async_trait
; fn spawn<W, G, F>(&mut self, g: G)
    where
        W: Worker<Self>,
        G: FnOnce(Receiver<()>) -> F,
        F: Future<Output = ()> + Send + 'static
; fn worker<W>(&self) -> Option<&W>
    where
        W: Worker<Self> + Send + Sync
; fn register_resource<R: Any + Send + Sync>(&mut self, res: R); fn remove_resource<R: Any + Send + Sync>(&mut self) -> Option<R>; fn resource<R: Any + Send + Sync>(&self) -> ResourceHandle<R>; fn info(&self) -> ResourceHandle<NodeInfo> { ... } fn storage(&self) -> ResourceHandle<Self::Backend> { ... } fn bus(&self) -> ResourceHandle<Bus<'static>> { ... } }
Expand description

A trait representing a node framework through which node workers may communicate.

Required Associated Types

The builder type used to create instances of this node.

The storage backend used by this node.

The type of errors that may be emitted as a result of the build process.

Required Methods

Stop the node, ending the execution of all workers in a timely manner.

Spawn a new node task associated with the given worker.

The task will be shut down with the worker to preserve topological worker ordering.

Get a reference to the state of a worker.

Register a new resource with the node such that other workers may access it via Node::resource.

Attempt to remove a resource from the node, returning None if no such resource was registered with the node.

Obtain an owning handle to a node resource.

Provided Methods

Obtain an owning handle to the node’s info.

Obtain an owning handle to the node’s storage backend.

Obtain an owning handle to the node’s event bus.

Implementors