pub trait NetworkReliability: Debug + Sync + Send + DynClone + 'static {
    // Provided methods
    fn sample_keep(&self) -> bool { ... }
    fn sample_delay(&self) -> Duration { ... }
    fn scramble(&self, msg: Vec<u8>) -> Vec<u8>  { ... }
    fn sample_repeat(&self) -> usize { ... }
    fn chaos_send_msg(
        &self,
        msg: Vec<u8>,
        send_fn: Arc<dyn Send + Sync + Fn(Vec<u8>) -> BoxSyncFuture<'static, ()> + 'static>
    ) -> BoxSyncFuture<'static, ()> { ... }
}
Expand description

interface describing how reliable the network is

Provided Methods§

source

fn sample_keep(&self) -> bool

Sample from bernoulli distribution to decide whether or not to keep a packet

§Panics

Panics if self.keep_numerator > self.keep_denominator

source

fn sample_delay(&self) -> Duration

sample from uniform distribution to decide whether or not to keep a packet

source

fn scramble(&self, msg: Vec<u8>) -> Vec<u8>

scramble the packet

source

fn sample_repeat(&self) -> usize

number of times to repeat the packet

source

fn chaos_send_msg( &self, msg: Vec<u8>, send_fn: Arc<dyn Send + Sync + Fn(Vec<u8>) -> BoxSyncFuture<'static, ()> + 'static> ) -> BoxSyncFuture<'static, ()>

given a message and a way to send the message, decide whether or not to send the message how long to delay the message whether or not to send duplicates and whether or not to include noise with the message then send the message note: usually self is stored in a rwlock so instead of doing the sending part, we just fiddle with the message then return a future that does the sending and delaying

Implementors§