pub struct Duration {
pub seconds: i32,
pub fraction: u32,
}Expand description
Duration_t (Spec §9.4.2.2): seconds + nanoseconds.
Canonical definition lives in zerodds_qos::Duration; RTPS
re-exports the type here for backward compatibility. All call sites
use the qos type.
DDS Duration (signed seconds + unsigned 2^-32-fractions).
The spec defines two special values:
DURATION_INFINITE:{ seconds: 0x7FFFFFFF, fraction: 0xFFFFFFFF }.DURATION_ZERO:{ seconds: 0, fraction: 0 }.
Fields§
§seconds: i32Sekundenanteil (signed 32 bit).
fraction: u32Bruchteil-Anteil (2^-32-Sekunden).
Implementations§
Source§impl Duration
impl Duration
Sourcepub const fn from_millis(ms: i32) -> Duration
pub const fn from_millis(ms: i32) -> Duration
Creates a Duration from a number of milliseconds.
Time is represented as { seconds: i32, fraction: u32 (2^-32 s) }
— fraction is unsigned. Negative durations describe the time
via negative seconds + positive fraction, so that
(seconds + fraction*2^-32) runs continuously across 0. With
div_euclid/rem_euclid the remainder always stays [0, 1000).
Examples:
from_millis(1500)={1, 2^31}(1.5 s).from_millis(-500)={-1, 2^31}(= -1 + 0.5 = -0.5 s).from_millis(-1500)={-2, 2^31}(= -2 + 0.5 = -1.5 s).
Sourcepub const fn from_micros(us: i32) -> Duration
pub const fn from_micros(us: i32) -> Duration
Creates a Duration from a number of microseconds. Sub-millisecond
precision is preserved via the RTPS fraction field (latency budgets,
deadlines, time-based filters routinely use µs). Same negative-value
convention as Self::from_millis.
Sourcepub const fn is_infinite(self) -> bool
pub const fn is_infinite(self) -> bool
true if self == INFINITE.
Sourcepub const fn to_nanos(self) -> u128
pub const fn to_nanos(self) -> u128
Converts into nanoseconds. INFINITE and negative durations
return u128::MAX or saturate to 0 (the caller treats
u128::MAX as “never expires”).
Sourcepub fn encode_into(self, w: &mut BufferWriter) -> Result<(), EncodeError>
pub fn encode_into(self, w: &mut BufferWriter) -> Result<(), EncodeError>
Sourcepub fn decode_from(r: &mut BufferReader<'_>) -> Result<Duration, DecodeError>
pub fn decode_from(r: &mut BufferReader<'_>) -> Result<Duration, DecodeError>
Sourcepub fn to_bytes_le(self) -> [u8; 8]
pub fn to_bytes_le(self) -> [u8; 8]
8-byte array (LE) — useful for in-place copies in PL_CDR values.
Sourcepub fn to_bytes_be(self) -> [u8; 8]
pub fn to_bytes_be(self) -> [u8; 8]
8-byte array (BE) — for PL_CDR_BE payloads like the handshake c.pdata.
Sourcepub fn from_bytes_le(bytes: [u8; 8]) -> Duration
pub fn from_bytes_le(bytes: [u8; 8]) -> Duration
Aus 8-byte-LE-Array.