Struct rosc::OscTime[][src]

pub struct OscTime {
    pub seconds: u32,
    pub fractional: u32,
}

A time tag in OSC message consists of two 32-bit integers where the first one denotes the number of seconds since 1900-01-01 and the second the fractions of a second. For details on its semantics see http://opensoundcontrol.org/node/3/#timetags

Examples

use rosc::OscTime;
use std::{convert::TryFrom, time::SystemTime};

assert_eq!(
    OscTime::try_from(SystemTime::UNIX_EPOCH).unwrap(),
    OscTime::from((2_208_988_800, 0))
);

Conversions between (u32, u32)

Prior to version 0.5.0 of this crate, OscTime was defined as a type alias to (u32, u32). If you are upgrading from one of these older versions, you can use .into() to convert between (u32, u32) and OscTime in either direction.

Conversions between std::time::SystemTime

The traits in std::convert are implemented for converting between SystemTime and OscTime in both directions. An OscTime can be converted into a SystemTime using From/Into. A SystemTime can be converted into an OscTime using TryFrom/TryInto. The fallible variants of the conversion traits are used this case because not every SystemTime can be represented as an OscTime.

These conversions are lossy, but are tested to have a deviation within 5 nanoseconds when converted back and forth in either direction.

Fields

seconds: u32fractional: u32

Trait Implementations

impl Clone for OscTime[src]

impl Copy for OscTime[src]

impl Debug for OscTime[src]

impl Eq for OscTime[src]

impl From<(u32, u32)> for OscTime[src]

impl Hash for OscTime[src]

impl Ord for OscTime[src]

impl PartialEq<OscTime> for OscTime[src]

impl PartialOrd<OscTime> for OscTime[src]

impl StructuralEq for OscTime[src]

impl StructuralPartialEq for OscTime[src]

impl TryFrom<SystemTime> for OscTime[src]

type Error = OscTimeError

The type returned in the event of a conversion error.

Auto Trait Implementations

impl RefUnwindSafe for OscTime

impl Send for OscTime

impl Sync for OscTime

impl Unpin for OscTime

impl UnwindSafe for OscTime

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.