Trait NodeBuilder

Source
pub trait NodeBuilder<N: Node>: Sized {
    type Error: Error;
    type Config;

    // Required methods
    fn new(config: Self::Config) -> Result<Self, Self::Error>;
    fn with_worker<W: Worker<N> + 'static>(self) -> Self
       where W::Config: Default;
    fn with_worker_cfg<W: Worker<N> + 'static>(self, config: W::Config) -> Self;
    fn with_resource<R: Any + Send + Sync>(self, res: R) -> Self;
    fn finish<'async_trait>(
        self,
    ) -> Pin<Box<dyn Future<Output = Result<N, Self::Error>> + 'async_trait>>
       where Self: 'async_trait;
}
Expand description

A trait that provides generic build configuration capabilities for a node.

Required Associated Types§

Source

type Error: Error

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

Source

type Config

Global configuration provided to the node on creation.

Required Methods§

Source

fn new(config: Self::Config) -> Result<Self, Self::Error>

Begin building a new node with the provided configuration state.

Source

fn with_worker<W: Worker<N> + 'static>(self) -> Self
where W::Config: Default,

Register a worker, with default configuration state, that should be started with the node.

Source

fn with_worker_cfg<W: Worker<N> + 'static>(self, config: W::Config) -> Self

Register a worker, with the given configuration state, that should be started with the node.

Source

fn with_resource<R: Any + Send + Sync>(self, res: R) -> Self

Provide a resource that should be registered with the node upon start.

Source

fn finish<'async_trait>( self, ) -> Pin<Box<dyn Future<Output = Result<N, Self::Error>> + 'async_trait>>
where Self: 'async_trait,

Finish building the node, returning the final node.

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.

Implementors§