pub struct Duration {
pub sec: i32,
pub nsec: i32,
}
Expand description
ROS representation of duration, with nanosecond precision
Fields§
§sec: i32
Number of seconds. Negative for negative durations.
nsec: i32
Number of nanoseconds inside the current second. Negative for negative durations.
Implementations§
source§impl Duration
impl Duration
sourcepub fn new() -> Duration
pub fn new() -> Duration
Creates a new duration of zero value.
Examples
assert_eq!(Duration::new(), Duration { sec: 0, nsec: 0 });
sourcepub fn from_nanos(t: i64) -> Duration
pub fn from_nanos(t: i64) -> Duration
Creates a duration of the given number of nanoseconds.
Examples
assert_eq!(Duration::from_nanos(0), Duration { sec: 0, nsec: 0 });
assert_eq!(Duration::from_nanos(12_000_000_123), Duration { sec: 12, nsec: 123 });
assert_eq!(Duration::from_nanos(-12_000_000_123), Duration { sec: -12, nsec: -123 });
sourcepub fn from_seconds(sec: i32) -> Duration
pub fn from_seconds(sec: i32) -> Duration
Creates a duration of the given number of seconds.
Examples
assert_eq!(Duration::from_seconds(0), Duration { sec: 0, nsec: 0 });
assert_eq!(Duration::from_seconds(12), Duration { sec: 12, nsec: 0 });
assert_eq!(Duration::from_seconds(-12), Duration { sec: -12, nsec: 0 });
Trait Implementations§
source§impl<'de> Deserialize<'de> for Duration
impl<'de> Deserialize<'de> for Duration
source§fn deserialize<__D>(
__deserializer: __D
) -> Result<Duration, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>( __deserializer: __D ) -> Result<Duration, <__D as Deserializer<'de>>::Error>where __D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Ord for Duration
impl Ord for Duration
source§impl PartialEq<Duration> for Duration
impl PartialEq<Duration> for Duration
source§impl PartialOrd<Duration> for Duration
impl PartialOrd<Duration> for Duration
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl Serialize for Duration
impl Serialize for Duration
source§fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>( &self, __serializer: __S ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where __S: Serializer,
Serialize this value into the given Serde serializer. Read more