Struct libpulse_binding::time::MicroSeconds [−][src]
Microseconds. Represents a span of time like std::time::Duration.
This is an unsigned 64-bit type, and thus represents absolute values only.
Implementations
impl MicroSeconds[src]
pub const INVALID: Self[src]
MicroSeconds value representing an ‘invalid’ time.
Examples
assert_eq!(MicroSeconds::INVALID, MicroSeconds(std::u64::MAX));
pub const SECOND: Self[src]
pub const MILLISECOND: Self[src]
One millisecond in microseconds.
Examples
assert_eq!(MicroSeconds::MILLISECOND, MicroSeconds(1_000));
pub const ZERO: Self[src]
pub const MIN: Self[src]
pub const MAX: Self[src]
Largest valid time value (largest integer value is reserved for representing ‘invalid’).
Roughly equal to 5,124,095,576 hours, 213,503,982 days, or 584,542 years.
Examples
assert_eq!(MicroSeconds::MAX, MicroSeconds(std::u64::MAX - 1));
pub const fn inner(&self) -> u64[src]
pub const fn is_valid(&self) -> bool[src]
Returns true so long as inner value is not Self::INVALID.
Examples
assert_eq!(MicroSeconds::MIN.is_valid(), true); assert_eq!(MicroSeconds::MAX.is_valid(), true); assert_eq!(MicroSeconds::INVALID.is_valid(), false); assert_eq!(MicroSeconds::ZERO.is_valid(), true); assert_eq!(MicroSeconds(60 * MICROS_PER_SEC).is_valid(), true);
pub const fn is_zero(&self) -> bool[src]
Returns true so long as inner value is zero.
Examples
assert_eq!(MicroSeconds::ZERO.is_zero(), true); assert_eq!(MicroSeconds(0).is_zero(), true); assert_eq!(MicroSeconds(1).is_zero(), false);
pub fn from_secs(secs: u64) -> Option<Self>[src]
Creates a new MicroSeconds from the specified number of whole seconds. Returns None on
overflow.
Examples
assert_eq!(MicroSeconds::from_secs(2), Some(MicroSeconds(2_000_000))); assert_eq!(MicroSeconds::from_secs(0xffff_ffff_0000_0000), None);
pub fn from_millis(millis: u64) -> Option<Self>[src]
Creates a new MicroSeconds from the specified number of whole milliseconds. Returns None
on overflow.
Examples
assert_eq!(MicroSeconds::from_millis(23), Some(MicroSeconds(23_000))); assert_eq!(MicroSeconds::from_millis(0xffff_ffff_0000_0000), None);
pub fn diff(self, other: Self) -> Self[src]
Returns the absolute difference with other.
Examples
assert_eq!(MicroSeconds(0).diff(MicroSeconds(0)), MicroSeconds(0)); assert_eq!(MicroSeconds(100).diff(MicroSeconds(100)), MicroSeconds(0)); assert_eq!(MicroSeconds(200).diff(MicroSeconds(150)), MicroSeconds(50)); assert_eq!(MicroSeconds(150).diff(MicroSeconds(200)), MicroSeconds(50));
pub const fn as_secs(&self) -> u64[src]
Returns the total number of whole seconds.
Examples
assert_eq!(MicroSeconds(2_300_000).as_secs(), 2); assert_eq!(MicroSeconds(2_800_000).as_secs(), 2);
pub const fn as_millis(&self) -> u64[src]
Returns the total number of whole milliseconds.
Examples
assert_eq!(MicroSeconds(23_000_300).as_millis(), 23_000); assert_eq!(MicroSeconds(23_000_800).as_millis(), 23_000);
pub fn from_secs_f64(secs: f64) -> Self[src]
Creates a new MicroSeconds from the specified number of seconds represented as f64.
Panics if secs is not finite, is negative, or the value overflows.
Examples
assert_eq!(MicroSeconds::from_secs_f64(0.5), MicroSeconds(500_000)); assert_eq!(MicroSeconds::from_secs_f64(2.3), MicroSeconds(2_300_000));
These should panic.
MicroSeconds::from_secs_f64(std::f64::INFINITY);
MicroSeconds::from_secs_f64(-0.5);
MicroSeconds::from_secs_f64(std::f64::MAX);
MicroSeconds::from_secs_f64(std::f64::NAN);
pub fn from_secs_f32(secs: f32) -> Self[src]
Creates a new MicroSeconds from the specified number of seconds represented as f32.
Panics if secs is not finite, is negative, or the value overflows.
Examples
assert_eq!(MicroSeconds::from_secs_f32(0.5), MicroSeconds(500_000)); assert_eq!(MicroSeconds::from_secs_f32(2.3), MicroSeconds(2_300_000));
These should panic.
MicroSeconds::from_secs_f32(std::f32::INFINITY);
MicroSeconds::from_secs_f32(-0.5);
MicroSeconds::from_secs_f32(std::f32::MAX);
MicroSeconds::from_secs_f32(std::f32::NAN);
pub fn as_secs_f64(&self) -> f64[src]
Returns the number of seconds as f64.
Examples
assert_eq!(MicroSeconds(2_300_000).as_secs_f64(), 2.3); assert_eq!(MicroSeconds(500_000).as_secs_f64(), 0.5);
pub fn as_secs_f32(&self) -> f32[src]
Returns the number of seconds as f32.
Examples
assert_eq!(MicroSeconds(2_300_000).as_secs_f32(), 2.3); assert_eq!(MicroSeconds(500_000).as_secs_f32(), 0.5);
pub fn checked_add(self, other: Self) -> Option<Self>[src]
Checked integer addition. Computes self + rhs, returning None if overflow occurred,
using the inner integer’s checked_add() method.
Examples
let quater_minute = MicroSeconds(15 * MICROS_PER_SEC); let half_minute = MicroSeconds(30 * MICROS_PER_SEC); let three_quater_minute = MicroSeconds(45 * MICROS_PER_SEC); assert_eq!(half_minute.checked_add(quater_minute), Some(three_quater_minute)); assert_eq!(MicroSeconds::MAX.checked_add(half_minute), None);
pub fn checked_add_duration(self, rhs: Duration) -> Option<Self>[src]
Checked integer addition. Computes self + rhs, returning None if overflow occurred,
using the inner integer’s checked_add() method.
Examples
let half_minute = MicroSeconds(30 * MICROS_PER_SEC); let duration1 = Duration::new(2, 5 * NANOS_PER_MICRO + 20); // 2s + 5us + 20ns let duration2 = Duration::new(MicroSeconds::MAX.inner() / MICROS_PER_SEC, 0); assert_eq!(half_minute.checked_add_duration(duration1), Some(MicroSeconds(32_000_005))); assert_eq!(half_minute.checked_add_duration(duration2), None);
pub fn checked_sub(self, other: Self) -> Option<Self>[src]
Checked integer subtraction. Computes self - rhs, returning None if overflow occurred,
using the inner integer’s checked_sub() method.
Examples
let quater_minute = MicroSeconds(15 * MICROS_PER_SEC); let three_quater_minute = MicroSeconds(45 * MICROS_PER_SEC); let whole_minute = MicroSeconds(60 * MICROS_PER_SEC); assert_eq!(whole_minute.checked_sub(quater_minute), Some(three_quater_minute)); assert_eq!(quater_minute.checked_sub(whole_minute), None);
pub fn checked_sub_duration(self, rhs: Duration) -> Option<Self>[src]
Checked integer subtraction. Computes self - rhs, returning None if overflow occurred,
using the inner integer’s checked_sub() method.
Examples
let half_minute = MicroSeconds(30 * MICROS_PER_SEC); let duration1 = Duration::new(2, 5 * NANOS_PER_MICRO + 20); // 2s + 5us + 20ns let duration2 = Duration::new(45, 0); assert_eq!(half_minute.checked_sub_duration(duration1), Some(MicroSeconds(27_999_995))); assert_eq!(half_minute.checked_sub_duration(duration2), None);
pub fn checked_mul(self, rhs: u32) -> Option<Self>[src]
Checked integer multiplication. Computes self * rhs, returning None if overflow
occurred, using the inner integer’s checked_mul() method.
Examples
let quater_minute = MicroSeconds(15 * MICROS_PER_SEC); let whole_minute = MicroSeconds(60 * MICROS_PER_SEC); assert_eq!(quater_minute.checked_mul(4), Some(whole_minute)); assert_eq!(MicroSeconds::MAX.checked_mul(2), None);
pub fn checked_div(self, rhs: u32) -> Option<Self>[src]
Checked integer division. Computes self / rhs, returning None if rhs == 0, using the
inner integer’s checked_div() method.
Examples
let quater_minute = MicroSeconds(15 * MICROS_PER_SEC); let whole_minute = MicroSeconds(60 * MICROS_PER_SEC); assert_eq!(whole_minute.checked_div(4), Some(quater_minute)); assert_eq!(whole_minute.checked_div(0), None);
pub fn checked_rem(self, rhs: u32) -> Option<Self>[src]
Checked integer remainder. Computes self % rhs, returning None if rhs == 0, using the
inner integer’s checked_rem() method.
Examples
let quater_minute = MicroSeconds(15 * MICROS_PER_SEC); let whole_minute = MicroSeconds(60 * MICROS_PER_SEC); assert_eq!(whole_minute.checked_rem(4), Some(MicroSeconds::ZERO)); assert_eq!(whole_minute.checked_rem(7), Some(MicroSeconds(4))); assert_eq!(whole_minute.checked_rem(0), None);
pub fn mul_f64(self, rhs: f64) -> Self[src]
Multiplies MicroSeconds by f64.
Converts to an f64 representing seconds, multiplies by the given factor, then converts
back to microseconds.
Panics if rhs is not finite, is negative, or the value overflows.
Examples
let micros = MicroSeconds(2_700_000_000); assert_eq!(micros.mul_f64(3.14), MicroSeconds(8_478_000_000)); assert_eq!(micros.mul_f64(3.14e5), MicroSeconds(847_800_000_000_000));
These should panic.
MicroSeconds::SECOND.mul_f64(std::f64::INFINITY);
MicroSeconds::SECOND.mul_f64(-0.5);
MicroSeconds(2 * MICROS_PER_SEC).mul_f64(std::f64::MAX / 10.0);
MicroSeconds::SECOND.mul_f64(std::f64::NAN);
pub fn mul_f32(self, rhs: f32) -> Self[src]
Multiplies MicroSeconds by f32.
Converts to an f32 representing seconds, multiplies by the given factor, then converts
back to microseconds.
Panics if rhs is not finite, is negative, or the value overflows.
Examples
let micros = MicroSeconds(2_700_000_000); // Note the rounding errors that are clear here. assert_eq!(micros.mul_f32(3.14), MicroSeconds(8_478_000_152)); assert_eq!(micros.mul_f32(3.14e5), MicroSeconds(847_800_018_512_379));
These should panic.
MicroSeconds::SECOND.mul_f32(std::f32::INFINITY);
MicroSeconds::SECOND.mul_f32(-0.5);
MicroSeconds(2 * MICROS_PER_SEC).mul_f32(std::f32::MAX / 10.0);
MicroSeconds::SECOND.mul_f32(std::f32::NAN);
pub fn div_f64(self, rhs: f64) -> Self[src]
Divides MicroSeconds by f64.
Converts to an f64 representing seconds, divides by the given factor, then converts back
to microseconds.
Panics if rhs is not finite, is negative, or the value overflows.
Examples
let micros = MicroSeconds(2_700_000_000); assert_eq!(micros.div_f64(3.14), MicroSeconds(859_872_611)); assert_eq!(micros.div_f64(3.14e5), MicroSeconds(8_598));
These should panic.
MicroSeconds::SECOND.div_f64(-2.0);
MicroSeconds::MAX.div_f64(0.5);
MicroSeconds::SECOND.div_f64(std::f64::NAN);
pub fn div_f32(self, rhs: f32) -> Self[src]
Divides MicroSeconds by f32.
Converts to an f32 representing seconds, divides by the given factor, then converts back
to microseconds.
Panics if rhs is not finite, is negative, or the value overflows.
Examples
let micros = MicroSeconds(2_700_000_000); assert_eq!(micros.div_f32(3.14), MicroSeconds(859_872_559)); assert_eq!(micros.div_f32(3.14e5), MicroSeconds(8_598));
These should panic.
MicroSeconds::SECOND.div_f32(-2.0);
MicroSeconds::MAX.div_f32(0.5);
MicroSeconds::SECOND.div_f32(std::f32::NAN);
Trait Implementations
impl Add<Duration> for MicroSeconds[src]
type Output = Self
The resulting type after applying the + operator.
fn add(self, rhs: Duration) -> Self[src]
impl Add<MicroSeconds> for MicroSeconds[src]
type Output = Self
The resulting type after applying the + operator.
fn add(self, other: Self) -> Self[src]
impl Add<MicroSeconds> for MonotonicTs[src]
type Output = Self
The resulting type after applying the + operator.
fn add(self, rhs: MicroSeconds) -> Self[src]
impl Add<MicroSeconds> for Timeval[src]
type Output = Self
The resulting type after applying the + operator.
fn add(self, rhs: MicroSeconds) -> Self[src]
impl Add<MicroSeconds> for UnixTs[src]
type Output = Self
The resulting type after applying the + operator.
fn add(self, rhs: MicroSeconds) -> Self[src]
impl AddAssign<Duration> for MicroSeconds[src]
fn add_assign(&mut self, rhs: Duration)[src]
impl AddAssign<MicroSeconds> for MicroSeconds[src]
fn add_assign(&mut self, rhs: Self)[src]
impl AddAssign<MicroSeconds> for MonotonicTs[src]
fn add_assign(&mut self, rhs: MicroSeconds)[src]
impl AddAssign<MicroSeconds> for Timeval[src]
fn add_assign(&mut self, rhs: MicroSeconds)[src]
impl AddAssign<MicroSeconds> for UnixTs[src]
fn add_assign(&mut self, rhs: MicroSeconds)[src]
impl Clone for MicroSeconds[src]
fn clone(&self) -> MicroSeconds[src]
pub fn clone_from(&mut self, source: &Self)1.0.0[src]
impl Copy for MicroSeconds[src]
impl Debug for MicroSeconds[src]
impl Default for MicroSeconds[src]
fn default() -> MicroSeconds[src]
impl Display for MicroSeconds[src]
impl Div<u32> for MicroSeconds[src]
type Output = Self
The resulting type after applying the / operator.
fn div(self, rhs: u32) -> Self[src]
impl DivAssign<u32> for MicroSeconds[src]
fn div_assign(&mut self, rhs: u32)[src]
impl Eq for MicroSeconds[src]
impl From<MicroSeconds> for Timeval[src]
fn from(t: MicroSeconds) -> Self[src]
impl From<Timeval> for MicroSeconds[src]
impl Mul<u32> for MicroSeconds[src]
type Output = Self
The resulting type after applying the * operator.
fn mul(self, rhs: u32) -> Self[src]
impl MulAssign<u32> for MicroSeconds[src]
fn mul_assign(&mut self, rhs: u32)[src]
impl Ord for MicroSeconds[src]
fn cmp(&self, other: &MicroSeconds) -> Ordering[src]
#[must_use]pub fn max(self, other: Self) -> Self1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self1.50.0[src]
impl PartialEq<MicroSeconds> for MicroSeconds[src]
fn eq(&self, other: &MicroSeconds) -> bool[src]
fn ne(&self, other: &MicroSeconds) -> bool[src]
impl PartialOrd<MicroSeconds> for MicroSeconds[src]
fn partial_cmp(&self, other: &MicroSeconds) -> Option<Ordering>[src]
fn lt(&self, other: &MicroSeconds) -> bool[src]
fn le(&self, other: &MicroSeconds) -> bool[src]
fn gt(&self, other: &MicroSeconds) -> bool[src]
fn ge(&self, other: &MicroSeconds) -> bool[src]
impl Rem<u32> for MicroSeconds[src]
type Output = Self
The resulting type after applying the % operator.
fn rem(self, rhs: u32) -> Self[src]
impl RemAssign<u32> for MicroSeconds[src]
fn rem_assign(&mut self, rhs: u32)[src]
impl StructuralEq for MicroSeconds[src]
impl StructuralPartialEq for MicroSeconds[src]
impl Sub<Duration> for MicroSeconds[src]
type Output = Self
The resulting type after applying the - operator.
fn sub(self, rhs: Duration) -> Self[src]
impl Sub<MicroSeconds> for MicroSeconds[src]
type Output = Self
The resulting type after applying the - operator.
fn sub(self, other: Self) -> Self[src]
impl Sub<MicroSeconds> for MonotonicTs[src]
type Output = Self
The resulting type after applying the - operator.
fn sub(self, rhs: MicroSeconds) -> Self[src]
impl Sub<MicroSeconds> for Timeval[src]
type Output = Self
The resulting type after applying the - operator.
fn sub(self, rhs: MicroSeconds) -> Self[src]
impl Sub<MicroSeconds> for UnixTs[src]
type Output = Self
The resulting type after applying the - operator.
fn sub(self, rhs: MicroSeconds) -> Self[src]
impl SubAssign<Duration> for MicroSeconds[src]
fn sub_assign(&mut self, rhs: Duration)[src]
impl SubAssign<MicroSeconds> for MicroSeconds[src]
fn sub_assign(&mut self, rhs: Self)[src]
impl SubAssign<MicroSeconds> for MonotonicTs[src]
fn sub_assign(&mut self, rhs: MicroSeconds)[src]
impl SubAssign<MicroSeconds> for Timeval[src]
fn sub_assign(&mut self, rhs: MicroSeconds)[src]
impl SubAssign<MicroSeconds> for UnixTs[src]
fn sub_assign(&mut self, rhs: MicroSeconds)[src]
impl TryFrom<Duration> for MicroSeconds[src]
Auto Trait Implementations
impl RefUnwindSafe for MicroSeconds[src]
impl Send for MicroSeconds[src]
impl Sync for MicroSeconds[src]
impl Unpin for MicroSeconds[src]
impl UnwindSafe for MicroSeconds[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, Rhs> NumAssignOps<Rhs> for T where
T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs> + RemAssign<Rhs>, [src]
T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs> + RemAssign<Rhs>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn clone_into(&self, target: &mut T)[src]
impl<T> ToString for T where
T: Display + ?Sized, [src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
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]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,