Struct rosc::OscTime[][src]

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

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::UNIX_EPOCH};

assert_eq!(
    OscTime::try_from(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.

Although any time since the OSC epoch (1900-01-01 00:00:00 UTC) can be represented using the OSC timestamp format, this crate only allows conversions between times greater than or equal to the UNIX_EPOCH. This allows the math used in the conversions to work on 32-bit systems which cannot represent times that far back.

Fields

seconds: u32fractional: u32

Trait Implementations

impl Clone for OscTime[src]

fn clone(&self) -> OscTime[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for OscTime[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

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

fn from(time: (u32, u32)) -> OscTime[src]

Performs the conversion.

impl Hash for OscTime[src]

fn hash<__H: Hasher>(&self, state: &mut __H)[src]

Feeds this value into the given Hasher. Read more

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

Feeds a slice of this type into the given Hasher. Read more

impl Ord for OscTime[src]

fn cmp(&self, other: &OscTime) -> Ordering[src]

This method returns an Ordering between self and other. Read more

#[must_use]
fn max(self, other: Self) -> Self
1.21.0[src]

Compares and returns the maximum of two values. Read more

#[must_use]
fn min(self, other: Self) -> Self
1.21.0[src]

Compares and returns the minimum of two values. Read more

#[must_use]
fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]

Restrict a value to a certain interval. Read more

impl PartialEq<OscTime> for OscTime[src]

fn eq(&self, other: &OscTime) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &OscTime) -> bool[src]

This method tests for !=.

impl PartialOrd<OscTime> for OscTime[src]

fn partial_cmp(&self, other: &OscTime) -> Option<Ordering>[src]

This method returns an ordering between self and other values if one exists. Read more

#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests less than (for self and other) and is used by the < operator. Read more

#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl TryFrom<SystemTime> for OscTime[src]

type Error = OscTimeError

The type returned in the event of a conversion error.

fn try_from(time: SystemTime) -> Result<OscTime, OscTimeError>[src]

Performs the conversion.

impl Copy for OscTime[src]

impl Eq for OscTime[src]

impl StructuralEq for OscTime[src]

impl StructuralPartialEq for OscTime[src]

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]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

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

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.