libpulse_binding/time/mod.rs
1// Copyright 2017 Lyndon Brown
2//
3// This file is part of the PulseAudio Rust language binding.
4//
5// Licensed under the MIT license or the Apache license (version 2.0), at your option. You may not
6// copy, modify, or distribute this file except in compliance with said license. You can find copies
7// of these licenses either in the LICENSE-MIT and LICENSE-APACHE files, or alternatively at
8// <http://opensource.org/licenses/MIT> and <http://www.apache.org/licenses/LICENSE-2.0>
9// respectively.
10//
11// Portions of documentation are copied from the LGPL 2.1+ licensed PulseAudio C headers on a
12// fair-use basis, as discussed in the overall project readme (available in the git repository).
13
14//! Time handling functionality.
15
16mod convert; //private!
17mod microseconds;
18mod monotonic;
19mod timeval;
20mod unix;
21
22use std::time::Duration;
23
24pub use self::microseconds::*;
25pub use self::monotonic::*;
26pub use self::timeval::*;
27pub use self::unix::*;
28
29// (Copied constants from rust’s std/time/duration.rs)
30/// Nanoseconds per second.
31pub const NANOS_PER_SEC: u32 = 1_000_000_000;
32/// Nanoseconds per millisecond.
33pub const NANOS_PER_MILLI: u32 = 1_000_000;
34/// Nanoseconds per microsecond.
35pub const NANOS_PER_MICRO: u32 = 1_000;
36/// Microseconds per second.
37pub const MICROS_PER_SEC: u64 = 1_000_000;
38/// Microseconds per millisecond.
39pub const MICROS_PER_MILLI: u64 = 1_000;
40/// Milliseconds per second.
41pub const MILLIS_PER_SEC: u64 = 1_000;
42
43/// Basic math operation errors.
44mod op_err {
45 pub const ADD: &str = "attempt to add with overflow";
46 pub const SUB: &str = "attempt to subtract with overflow";
47 pub const MUL: &str = "attempt to multiply with overflow";
48 pub const DIV: &str = "attempt to divide by zero";
49 pub const REM: &str = DIV;
50}