pub struct Rate(/* private fields */);Expand description
A rate, in bits per second.
A newtype rather than a bare integer because everything that meets in an
Allocator is the same quantity measured the same way: a congestion
controller’s estimate, a track’s reservation, an encoder’s ceiling. One of them
reading bytes per second, or kilobits, is off by a factor of eight or a thousand
and still typechecks, which is the kind of wrong that reaches production.
Named for what it measures rather than for the module: Session::stats has called
this quantity a rate all along (estimated_send_rate).
Implementations§
Source§impl Rate
impl Rate
Sourcepub const fn from_bps(bps: u64) -> Self
pub const fn from_bps(bps: u64) -> Self
A rate in bits per second, the unit every wire and codec API here uses.
Sourcepub const fn from_kbps(kbps: u64) -> Self
pub const fn from_kbps(kbps: u64) -> Self
A rate in kilobits (1000 bits) per second, saturating.
Sourcepub const fn from_mbps(mbps: u64) -> Self
pub const fn from_mbps(mbps: u64) -> Self
A rate in megabits (1000 kilobits) per second, saturating.
Sourcepub const fn as_bps(self) -> u64
pub const fn as_bps(self) -> u64
This rate in bits per second, for handing to a codec or FFI that wants a plain integer.