Struct nippy::Instant[][src]

pub struct Instant { /* fields omitted */ }

Describes an instant relative to the UNIX_EPOCH - 00:00:00 Coordinated Universal Time (UTC), Thursay, 1 January 1970 in seconds with the fractional part in nanoseconds.

If the Instant describes some moment prior to UNIX_EPOCH, both the secs and subsec_nanos components will be negative.

The sole purpose of this type is for retrieving the “current” time using the std::time module and for converting between the ntp timestamp formats. If you are interested in converting from unix time to some other more human readable format, perhaps see the chrono crate.

Example

Here is a demonstration of displaying the Instant in local time using the chrono crate:

extern crate chrono;
extern crate nippy;

use chrono::TimeZone;

fn main() {
    let unix_time = nippy::Instant::now();
    let local_time = chrono::Local.timestamp(unix_time.secs(), unix_time.subsec_nanos() as _);
    println!("{}", local_time);
}

Implementations

impl Instant[src]

pub fn new(secs: i64, subsec_nanos: i32) -> Instant[src]

Create a new Instant given its secs and subsec_nanos components.

To indicate a time following UNIX_EPOCH, both secs and subsec_nanos must be positive. To indicate a time prior to UNIX_EPOCH, both secs and subsec_nanos must be negative. Violating these invariants will result in a panic!.

pub fn now() -> Self[src]

Uses std::time::SystemTime::now and std::time::UNIX_EPOCH to determine the current Instant.

Example

extern crate nippy;

fn main() {
    println!("{:?}", nippy::Instant::now());
}

pub fn secs(&self) -> i64[src]

The “seconds” component of the Instant.

pub fn subsec_nanos(&self) -> i32[src]

The fractional component of the Instant in nanoseconds.

Trait Implementations

impl Clone for Instant[src]

impl Copy for Instant[src]

impl Debug for Instant[src]

impl From<Instant> for ShortFormat[src]

impl From<Instant> for TimestampFormat[src]

impl From<ShortFormat> for Instant[src]

impl From<TimestampFormat> for Instant[src]

Auto Trait Implementations

impl RefUnwindSafe for Instant

impl Send for Instant

impl Sync for Instant

impl Unpin for Instant

impl UnwindSafe for Instant

Blanket Implementations

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

impl<Src, Scheme> ApproxFrom<Src, Scheme> for Src where
    Scheme: ApproxScheme
[src]

type Err = NoError

The error type produced by a failed conversion.

impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Src where
    Scheme: ApproxScheme,
    Dst: ApproxFrom<Src, Scheme>, 
[src]

type Err = <Dst as ApproxFrom<Src, Scheme>>::Err

The error type produced by a failed conversion.

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

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

impl<T, Dst> ConvAsUtil<Dst> for T[src]

impl<T> ConvUtil for T[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<Src> TryFrom<Src> for Src[src]

type Err = NoError

The error type produced by a failed conversion.

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<Src, Dst> TryInto<Dst> for Src where
    Dst: TryFrom<Src>, 
[src]

type Err = <Dst as TryFrom<Src>>::Err

The error type produced by a failed 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.

impl<Src> ValueFrom<Src> for Src[src]

type Err = NoError

The error type produced by a failed conversion.

impl<Src, Dst> ValueInto<Dst> for Src where
    Dst: ValueFrom<Src>, 
[src]

type Err = <Dst as ValueFrom<Src>>::Err

The error type produced by a failed conversion.