Skip to main content

Node

Trait Node 

Source
pub trait Node: Send + Sync {
    // Required methods
    fn node_id(&self) -> &NodeId;
    fn info(&self) -> &NodeInfo;
    fn capabilities(&self) -> &[Capability];
    fn execute<'life0, 'async_trait>(
        &'life0 self,
        task: NodeTask,
    ) -> Pin<Box<dyn Future<Output = Result<NodeResult, RustantError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn health(&self) -> NodeHealth;
    fn heartbeat<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<NodeHealth, RustantError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn rich_capabilities(&self) -> Vec<NodeCapability> { ... }
    fn handle_message<'life0, 'async_trait>(
        &'life0 self,
        msg: NodeMessage,
    ) -> Pin<Box<dyn Future<Output = Result<Option<NodeMessage>, RustantError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

Core trait for node implementations.

Required Methods§

Source

fn node_id(&self) -> &NodeId

Unique identifier for this node.

Source

fn info(&self) -> &NodeInfo

Descriptive info about this node.

Source

fn capabilities(&self) -> &[Capability]

Capabilities this node can provide.

Source

fn execute<'life0, 'async_trait>( &'life0 self, task: NodeTask, ) -> Pin<Box<dyn Future<Output = Result<NodeResult, RustantError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Execute a task on this node.

Source

fn health(&self) -> NodeHealth

Current health of this node.

Source

fn heartbeat<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<NodeHealth, RustantError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Perform a heartbeat check.

Provided Methods§

Source

fn rich_capabilities(&self) -> Vec<NodeCapability>

Rich capability descriptions. Default wraps each Capability into a basic NodeCapability.

Source

fn handle_message<'life0, 'async_trait>( &'life0 self, msg: NodeMessage, ) -> Pin<Box<dyn Future<Output = Result<Option<NodeMessage>, RustantError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Handle an inter-node protocol message. Default: responds to Ping and CapabilityQuery.

Implementors§