pub struct NetworkPressure { /* private fields */ }Expand description
Pressure source based on network bandwidth utilization.
Reads EWMA-smoothed RX+TX throughput from a ResourceReader and
returns (rx + tx) / max_bandwidth_bps clamped to [0.0, 1.0].
§Example
ⓘ
use taskmill::resource::network_pressure::NetworkPressure;
let pressure = NetworkPressure::new(reader, 100_000_000.0); // 100 MB/s cap
assert!(pressure.pressure() >= 0.0);Implementations§
Source§impl NetworkPressure
impl NetworkPressure
Sourcepub fn new(reader: Arc<dyn ResourceReader>, max_bandwidth_bps: f64) -> Self
pub fn new(reader: Arc<dyn ResourceReader>, max_bandwidth_bps: f64) -> Self
Create a new NetworkPressure source.
max_bandwidth_bps is the combined (RX + TX) bandwidth cap in
bytes per second. When observed throughput reaches this value,
pressure reports 1.0 (fully saturated).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for NetworkPressure
impl !RefUnwindSafe for NetworkPressure
impl Send for NetworkPressure
impl Sync for NetworkPressure
impl Unpin for NetworkPressure
impl UnsafeUnpin for NetworkPressure
impl !UnwindSafe for NetworkPressure
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> 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