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§
Sourcefn capabilities(&self) -> &[Capability]
fn capabilities(&self) -> &[Capability]
Capabilities this node can provide.
Sourcefn 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 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.
Sourcefn health(&self) -> NodeHealth
fn health(&self) -> NodeHealth
Current health of this node.
Sourcefn heartbeat<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<NodeHealth, RustantError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
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§
Sourcefn rich_capabilities(&self) -> Vec<NodeCapability>
fn rich_capabilities(&self) -> Vec<NodeCapability>
Rich capability descriptions. Default wraps each Capability into a basic NodeCapability.
Sourcefn 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,
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.