pub struct TrafficShaper { /* private fields */ }Expand description
Main traffic shaper combining bandwidth throttling and burst loss
Implementations§
Source§impl TrafficShaper
impl TrafficShaper
Sourcepub fn new(config: TrafficShapingConfig) -> Self
pub fn new(config: TrafficShapingConfig) -> Self
Create a new traffic shaper
Sourcepub async fn throttle_bandwidth(
&self,
data_size: u64,
tags: &[String],
) -> Result<()>
pub async fn throttle_bandwidth( &self, data_size: u64, tags: &[String], ) -> Result<()>
Apply bandwidth throttling to a data transfer
Sourcepub async fn should_drop_packet(&self, tags: &[String]) -> bool
pub async fn should_drop_packet(&self, tags: &[String]) -> bool
Check if a packet should be dropped due to burst loss
Sourcepub async fn process_transfer(
&self,
data_size: u64,
tags: &[String],
) -> Result<Option<Duration>>
pub async fn process_transfer( &self, data_size: u64, tags: &[String], ) -> Result<Option<Duration>>
Process a data transfer with both bandwidth throttling and burst loss
Sourcepub async fn get_bandwidth_stats(&self) -> BandwidthStats
pub async fn get_bandwidth_stats(&self) -> BandwidthStats
Get current bandwidth usage statistics
Sourcepub async fn get_burst_loss_stats(&self) -> BurstLossStats
pub async fn get_burst_loss_stats(&self) -> BurstLossStats
Get current burst loss state
Trait Implementations§
Source§impl Clone for TrafficShaper
impl Clone for TrafficShaper
Source§fn clone(&self) -> TrafficShaper
fn clone(&self) -> TrafficShaper
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for TrafficShaper
impl !RefUnwindSafe for TrafficShaper
impl Send for TrafficShaper
impl Sync for TrafficShaper
impl Unpin for TrafficShaper
impl !UnwindSafe for TrafficShaper
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more