pub struct Timescale(/* private fields */);Expand description
Units per second used by a track for frame timestamps.
Newtype around NonZero<u64>. Zero is structurally impossible, so the
arithmetic on Timestamp can divide by self.scale without ever risking
a divide by zero. Use the named constants (Self::SECOND, Self::MILLI,
Self::MICRO, Self::NANO) instead of writing raw integers at call sites;
for runtime values, use Self::new or TryFrom, which return TimeOverflow
for 0 or for values past the QUIC varint range.
Implementations§
Source§impl Timescale
impl Timescale
Sourcepub const MICRO: Self
pub const MICRO: Self
1,000,000 units per second (1_000_000). Widely used by container formats;
this crate’s own default is Self::MILLI.
Sourcepub const fn new(units_per_second: u64) -> Result<Self, TimeOverflow>
pub const fn new(units_per_second: u64) -> Result<Self, TimeOverflow>
Construct a timescale from a raw value (units per second).
Returns TimeOverflow if units_per_second is 0 (would divide by zero)
or exceeds 2^62 - 1 (the QUIC varint range, matching Timestamp values).
Every runtime constructor, including TryFrom, goes through this check.
Trait Implementations§
impl Copy for Timescale
Source§impl Default for Timescale
impl Default for Timescale
Source§fn default() -> Self
fn default() -> Self
Milliseconds (Self::MILLI). Every track has a timescale; this is the one
used when a producer doesn’t pick one and the fallback for protocols whose wire
can’t carry a timescale (pre-Lite05 moq-lite, IETF moq-transport).