Trait hotshot::traits::networking::NetworkReliability
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 = ()> + Send + Sync>> + Send + Sync>
) -> Pin<Box<dyn Future<Output = ()> + Send + Sync>> { ... }
}
Expand description
interface describing how reliable the network is
Provided Methods§
fn sample_keep(&self) -> bool
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
fn sample_delay(&self) -> Duration
fn sample_delay(&self) -> Duration
sample from uniform distribution to decide whether or not to keep a packet
fn sample_repeat(&self) -> usize
fn sample_repeat(&self) -> usize
number of times to repeat the packet
fn chaos_send_msg(
&self,
msg: Vec<u8>,
send_fn: Arc<dyn Fn(Vec<u8>) -> Pin<Box<dyn Future<Output = ()> + Send + Sync>> + Send + Sync>
) -> Pin<Box<dyn Future<Output = ()> + Send + Sync>>
fn chaos_send_msg( &self, msg: Vec<u8>, send_fn: Arc<dyn Fn(Vec<u8>) -> Pin<Box<dyn Future<Output = ()> + Send + Sync>> + Send + Sync> ) -> Pin<Box<dyn Future<Output = ()> + Send + Sync>>
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