pub trait Reactor: Sized {
type Peer: ToSocketAddrs;
type Message: Serialize + DeserializeOwned;
type Config;
type Error;
const PERIODIC_INTERVAL: Option<Duration> = None;
// Required methods
fn start(config: Self::Config) -> Result<Self, Self::Error>;
fn receive(
&mut self,
from: Self::Peer,
msg: Self::Message,
) -> Vec<(Self::Peer, Self::Message)>;
// Provided method
fn periodic(&mut self) -> Vec<(Self::Peer, Self::Message)> { ... }
}Expand description
A trait for building networked systems that can be plugged into simulated networks and partition tested in accelerated time.
Provided Associated Constants§
const PERIODIC_INTERVAL: Option<Duration> = None
Required Associated Types§
type Peer: ToSocketAddrs
type Message: Serialize + DeserializeOwned
type Config
type Error
Required Methods§
fn start(config: Self::Config) -> Result<Self, Self::Error>
fn receive( &mut self, from: Self::Peer, msg: Self::Message, ) -> Vec<(Self::Peer, Self::Message)>
Provided Methods§
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.