pub trait Node:
Send
+ Sized
+ 'static {
type Builder: NodeBuilder<Self>;
type Backend: StorageBackend;
type Error: Error;
// Required methods
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>;
// Provided methods
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§
Sourcetype Builder: NodeBuilder<Self>
type Builder: NodeBuilder<Self>
The builder type used to create instances of this node.
Sourcetype Backend: StorageBackend
type Backend: StorageBackend
The storage backend used by this node.
Required Methods§
Sourcefn stop<'async_trait>(
self,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
fn stop<'async_trait>(
self,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
Stop the node, ending the execution of all workers in a timely manner.
Sourcefn spawn<W, G, F>(&mut self, g: G)
fn spawn<W, G, F>(&mut self, g: G)
Spawn a new node task associated with the given worker.
The task will be shut down with the worker to preserve topological worker ordering.
Sourcefn register_resource<R: Any + Send + Sync>(&mut self, res: R)
fn register_resource<R: Any + Send + Sync>(&mut self, res: R)
Register a new resource with the node such that other workers may access it via Node::resource
.
Provided Methods§
Sourcefn info(&self) -> ResourceHandle<NodeInfo>
fn info(&self) -> ResourceHandle<NodeInfo>
Obtain an owning handle to the node’s info.
Sourcefn storage(&self) -> ResourceHandle<Self::Backend>
fn storage(&self) -> ResourceHandle<Self::Backend>
Obtain an owning handle to the node’s storage backend.
Sourcefn bus(&self) -> ResourceHandle<Bus<'static>>
fn bus(&self) -> ResourceHandle<Bus<'static>>
Obtain an owning handle to the node’s event bus.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.