Struct ntp_proto::NtpDuration

source ·
pub struct NtpDuration { /* private fields */ }
Expand description

NtpDuration is used to represent signed intervals between NtpTimestamps. A negative duration interval is interpreted to mean that the first timestamp used to define the interval represents a point in time after the second timestamp.

Implementations§

source§

impl NtpDuration

source

pub const ZERO: Self = _

source

pub fn to_seconds(self) -> f64

Convert to an f64; required for statistical calculations (e.g. in clock filtering)

source

pub fn from_seconds(seconds: f64) -> Self

source

pub const fn abs(self) -> Self

Interval of same length, but positive direction

source

pub const fn as_seconds_nanos(self) -> (i32, u32)

Get the number of seconds (first return value) and nanoseconds (second return value) representing the length of this duration. The number of nanoseconds is guaranteed to be positiv and less than 10^9

source

pub fn from_exponent(input: i8) -> Self

Interpret an exponent k as 2^k seconds, expressed as an NtpDuration

source

pub fn log2(self) -> i8

calculate the log2 (floored) of the duration in seconds (i8::MIN if 0)

source

pub fn from_system_duration(duration: Duration) -> Self

Trait Implementations§

source§

impl Add<NtpDuration> for NtpDuration

§

type Output = NtpDuration

The resulting type after applying the + operator.
source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
source§

impl Add<NtpDuration> for NtpTimestamp

§

type Output = NtpTimestamp

The resulting type after applying the + operator.
source§

fn add(self, rhs: NtpDuration) -> Self::Output

Performs the + operation. Read more
source§

impl AddAssign<NtpDuration> for NtpDuration

source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
source§

impl AddAssign<NtpDuration> for NtpTimestamp

source§

fn add_assign(&mut self, rhs: NtpDuration)

Performs the += operation. Read more
source§

impl Clone for NtpDuration

source§

fn clone(&self) -> NtpDuration

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for NtpDuration

source§

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

Formats the value using the given formatter. Read more
source§

impl Default for NtpDuration

source§

fn default() -> NtpDuration

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for NtpDuration

source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Div<i16> for NtpDuration

§

type Output = NtpDuration

The resulting type after applying the / operator.
source§

fn div(self, rhs: i16) -> NtpDuration

Performs the / operation. Read more
source§

impl Div<i32> for NtpDuration

§

type Output = NtpDuration

The resulting type after applying the / operator.
source§

fn div(self, rhs: i32) -> NtpDuration

Performs the / operation. Read more
source§

impl Div<i64> for NtpDuration

§

type Output = NtpDuration

The resulting type after applying the / operator.
source§

fn div(self, rhs: i64) -> NtpDuration

Performs the / operation. Read more
source§

impl Div<i8> for NtpDuration

§

type Output = NtpDuration

The resulting type after applying the / operator.
source§

fn div(self, rhs: i8) -> NtpDuration

Performs the / operation. Read more
source§

impl Div<isize> for NtpDuration

§

type Output = NtpDuration

The resulting type after applying the / operator.
source§

fn div(self, rhs: isize) -> NtpDuration

Performs the / operation. Read more
source§

impl Div<u16> for NtpDuration

§

type Output = NtpDuration

The resulting type after applying the / operator.
source§

fn div(self, rhs: u16) -> NtpDuration

Performs the / operation. Read more
source§

impl Div<u32> for NtpDuration

§

type Output = NtpDuration

The resulting type after applying the / operator.
source§

fn div(self, rhs: u32) -> NtpDuration

Performs the / operation. Read more
source§

impl Div<u8> for NtpDuration

§

type Output = NtpDuration

The resulting type after applying the / operator.
source§

fn div(self, rhs: u8) -> NtpDuration

Performs the / operation. Read more
source§

impl DivAssign<i16> for NtpDuration

source§

fn div_assign(&mut self, rhs: i16)

Performs the /= operation. Read more
source§

impl DivAssign<i32> for NtpDuration

source§

fn div_assign(&mut self, rhs: i32)

Performs the /= operation. Read more
source§

impl DivAssign<i64> for NtpDuration

source§

fn div_assign(&mut self, rhs: i64)

Performs the /= operation. Read more
source§

impl DivAssign<i8> for NtpDuration

source§

fn div_assign(&mut self, rhs: i8)

Performs the /= operation. Read more
source§

impl DivAssign<isize> for NtpDuration

source§

fn div_assign(&mut self, rhs: isize)

Performs the /= operation. Read more
source§

impl DivAssign<u16> for NtpDuration

source§

fn div_assign(&mut self, rhs: u16)

Performs the /= operation. Read more
source§

impl DivAssign<u32> for NtpDuration

source§

fn div_assign(&mut self, rhs: u32)

Performs the /= operation. Read more
source§

impl DivAssign<u8> for NtpDuration

source§

fn div_assign(&mut self, rhs: u8)

Performs the /= operation. Read more
source§

impl Mul<FrequencyTolerance> for NtpDuration

§

type Output = NtpDuration

The resulting type after applying the * operator.
source§

fn mul(self, rhs: FrequencyTolerance) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<NtpDuration> for i16

§

type Output = NtpDuration

The resulting type after applying the * operator.
source§

fn mul(self, rhs: NtpDuration) -> NtpDuration

Performs the * operation. Read more
source§

impl Mul<NtpDuration> for i32

§

type Output = NtpDuration

The resulting type after applying the * operator.
source§

fn mul(self, rhs: NtpDuration) -> NtpDuration

Performs the * operation. Read more
source§

impl Mul<NtpDuration> for i64

§

type Output = NtpDuration

The resulting type after applying the * operator.
source§

fn mul(self, rhs: NtpDuration) -> NtpDuration

Performs the * operation. Read more
source§

impl Mul<NtpDuration> for i8

§

type Output = NtpDuration

The resulting type after applying the * operator.
source§

fn mul(self, rhs: NtpDuration) -> NtpDuration

Performs the * operation. Read more
source§

impl Mul<NtpDuration> for isize

§

type Output = NtpDuration

The resulting type after applying the * operator.
source§

fn mul(self, rhs: NtpDuration) -> NtpDuration

Performs the * operation. Read more
source§

impl Mul<NtpDuration> for u16

§

type Output = NtpDuration

The resulting type after applying the * operator.
source§

fn mul(self, rhs: NtpDuration) -> NtpDuration

Performs the * operation. Read more
source§

impl Mul<NtpDuration> for u32

§

type Output = NtpDuration

The resulting type after applying the * operator.
source§

fn mul(self, rhs: NtpDuration) -> NtpDuration

Performs the * operation. Read more
source§

impl Mul<NtpDuration> for u8

§

type Output = NtpDuration

The resulting type after applying the * operator.
source§

fn mul(self, rhs: NtpDuration) -> NtpDuration

Performs the * operation. Read more
source§

impl Mul<i16> for NtpDuration

§

type Output = NtpDuration

The resulting type after applying the * operator.
source§

fn mul(self, rhs: i16) -> NtpDuration

Performs the * operation. Read more
source§

impl Mul<i32> for NtpDuration

§

type Output = NtpDuration

The resulting type after applying the * operator.
source§

fn mul(self, rhs: i32) -> NtpDuration

Performs the * operation. Read more
source§

impl Mul<i64> for NtpDuration

§

type Output = NtpDuration

The resulting type after applying the * operator.
source§

fn mul(self, rhs: i64) -> NtpDuration

Performs the * operation. Read more
source§

impl Mul<i8> for NtpDuration

§

type Output = NtpDuration

The resulting type after applying the * operator.
source§

fn mul(self, rhs: i8) -> NtpDuration

Performs the * operation. Read more
source§

impl Mul<isize> for NtpDuration

§

type Output = NtpDuration

The resulting type after applying the * operator.
source§

fn mul(self, rhs: isize) -> NtpDuration

Performs the * operation. Read more
source§

impl Mul<u16> for NtpDuration

§

type Output = NtpDuration

The resulting type after applying the * operator.
source§

fn mul(self, rhs: u16) -> NtpDuration

Performs the * operation. Read more
source§

impl Mul<u32> for NtpDuration

§

type Output = NtpDuration

The resulting type after applying the * operator.
source§

fn mul(self, rhs: u32) -> NtpDuration

Performs the * operation. Read more
source§

impl Mul<u8> for NtpDuration

§

type Output = NtpDuration

The resulting type after applying the * operator.
source§

fn mul(self, rhs: u8) -> NtpDuration

Performs the * operation. Read more
source§

impl MulAssign<i16> for NtpDuration

source§

fn mul_assign(&mut self, rhs: i16)

Performs the *= operation. Read more
source§

impl MulAssign<i32> for NtpDuration

source§

fn mul_assign(&mut self, rhs: i32)

Performs the *= operation. Read more
source§

impl MulAssign<i64> for NtpDuration

source§

fn mul_assign(&mut self, rhs: i64)

Performs the *= operation. Read more
source§

impl MulAssign<i8> for NtpDuration

source§

fn mul_assign(&mut self, rhs: i8)

Performs the *= operation. Read more
source§

impl MulAssign<isize> for NtpDuration

source§

fn mul_assign(&mut self, rhs: isize)

Performs the *= operation. Read more
source§

impl MulAssign<u16> for NtpDuration

source§

fn mul_assign(&mut self, rhs: u16)

Performs the *= operation. Read more
source§

impl MulAssign<u32> for NtpDuration

source§

fn mul_assign(&mut self, rhs: u32)

Performs the *= operation. Read more
source§

impl MulAssign<u8> for NtpDuration

source§

fn mul_assign(&mut self, rhs: u8)

Performs the *= operation. Read more
source§

impl Neg for NtpDuration

§

type Output = NtpDuration

The resulting type after applying the - operator.
source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
source§

impl Ord for NtpDuration

source§

fn cmp(&self, other: &NtpDuration) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl PartialEq<NtpDuration> for NtpDuration

source§

fn eq(&self, other: &NtpDuration) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd<NtpDuration> for NtpDuration

source§

fn partial_cmp(&self, other: &NtpDuration) -> Option<Ordering>

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

fn lt(&self, other: &Rhs) -> bool

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

fn le(&self, other: &Rhs) -> bool

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

fn gt(&self, other: &Rhs) -> bool

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

fn ge(&self, other: &Rhs) -> bool

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

impl Serialize for NtpDuration

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Sub<NtpDuration> for NtpDuration

§

type Output = NtpDuration

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<NtpDuration> for NtpTimestamp

§

type Output = NtpTimestamp

The resulting type after applying the - operator.
source§

fn sub(self, rhs: NtpDuration) -> Self::Output

Performs the - operation. Read more
source§

impl SubAssign<NtpDuration> for NtpDuration

source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
source§

impl SubAssign<NtpDuration> for NtpTimestamp

source§

fn sub_assign(&mut self, rhs: NtpDuration)

Performs the -= operation. Read more
source§

impl Copy for NtpDuration

source§

impl Eq for NtpDuration

source§

impl StructuralEq for NtpDuration

source§

impl StructuralPartialEq for NtpDuration

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,