pub trait SinkStreamExt<T>: Stream + Sink<T> {
// Provided methods
fn with_delay(
self,
min_delay: Duration,
mean_additional_delay: Duration,
) -> Delay<Self, T>
where Self: Sized { ... }
fn with_loss(self, loss_rate: f64, jitter_period: Duration) -> Loss<Self>
where Self: Sized { ... }
}
Expand description
Extension trait for types which are both Sink
s and Stream
s.
Provided Methods§
Sourcefn with_delay(
self,
min_delay: Duration,
mean_additional_delay: Duration,
) -> Delay<Self, T>where
Self: Sized,
fn with_delay(
self,
min_delay: Duration,
mean_additional_delay: Duration,
) -> Delay<Self, T>where
Self: Sized,
Delays items sent/received through this Sink
/Stream
.
min_delay
is the minimum delay which is applied to all items.mean_additional_delay
is the average randomized delay applied to all items in addition tomin_delay
. Setting this to zero disables delay randomization and guarantees that items are recieved in the order they’re sent.
Sourcefn with_loss(self, loss_rate: f64, jitter_period: Duration) -> Loss<Self>where
Self: Sized,
fn with_loss(self, loss_rate: f64, jitter_period: Duration) -> Loss<Self>where
Self: Sized,
Randomly drops items sent through this Sink
/Stream
.
loss_rate
is what proportion of the items to drop. Setting to1.0
will drop everything, setting to0.0
will drop nothing.jitter_period
controls the average rate of switching between dropping and not dropping items. Setting this to zero disables jitter so that each item has an independent probability of getting dropped.