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) -> Rate
pub const fn from_bps(bps: u64) -> Rate
A rate in bits per second, the unit every wire and codec API here uses.
Sourcepub const fn from_kbps(kbps: u64) -> Rate
pub const fn from_kbps(kbps: u64) -> Rate
A rate in kilobits (1000 bits) per second, saturating.
Sourcepub const fn from_mbps(mbps: u64) -> Rate
pub const fn from_mbps(mbps: u64) -> Rate
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.
Trait Implementations§
impl Copy for Rate
impl Eq for Rate
Source§impl Ord for Rate
impl Ord for Rate
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Rate
impl PartialOrd for Rate
impl StructuralPartialEq for Rate
Auto Trait Implementations§
impl Freeze for Rate
impl RefUnwindSafe for Rate
impl Send for Rate
impl Sync for Rate
impl Unpin for Rate
impl UnsafeUnpin for Rate
impl UnwindSafe for Rate
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.