Skip to main content

VortexNetwork

Trait VortexNetwork 

Source
pub trait VortexNetwork {
    // Required methods
    fn send(&mut self, to: NodeId, payload: Vec<u8>) -> Result<()>;
    fn recv(&mut self) -> Option<(NodeId, Vec<u8>)>;

    // Provided method
    fn broadcast(&mut self, nodes: &[NodeId], payload: Vec<u8>) -> Result<()> { ... }
}
Expand description

Network I/O boundary trait.

In production: real TCP/UDP sockets. In simulation: SimNetwork with configurable latency, drops, partitions.

Required Methods§

Source

fn send(&mut self, to: NodeId, payload: Vec<u8>) -> Result<()>

Send a message to a specific node.

Source

fn recv(&mut self) -> Option<(NodeId, Vec<u8>)>

Receive the next pending message, if any.

Provided Methods§

Source

fn broadcast(&mut self, nodes: &[NodeId], payload: Vec<u8>) -> Result<()>

Broadcast a message to all known nodes.

Implementors§