Trait hotshot::traits::networking::NetworkReliability

source ·
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 Fn(Vec<u8>) -> Pin<Box<dyn Future<Output = ()> + Sync + Send>> + Sync + Send>,
    ) -> Pin<Box<dyn Future<Output = ()> + Sync + Send>> { ... }
}
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 Fn(Vec<u8>) -> Pin<Box<dyn Future<Output = ()> + Sync + Send>> + Sync + Send>, ) -> Pin<Box<dyn Future<Output = ()> + Sync + Send>>

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

Trait Implementations§

source§

impl<'clone> Clone for Box<dyn NetworkReliability + 'clone>

source§

fn clone(&self) -> Box<dyn NetworkReliability + 'clone>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'clone> Clone for Box<dyn NetworkReliability + Send + 'clone>

source§

fn clone(&self) -> Box<dyn NetworkReliability + Send + 'clone>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'clone> Clone for Box<dyn NetworkReliability + Sync + Send + 'clone>

source§

fn clone(&self) -> Box<dyn NetworkReliability + Sync + Send + 'clone>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'clone> Clone for Box<dyn NetworkReliability + Sync + 'clone>

source§

fn clone(&self) -> Box<dyn NetworkReliability + Sync + 'clone>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Implementors§