Struct surrealdb_sql::Duration

source ·
pub struct Duration(pub Duration);

Tuple Fields§

§0: Duration

Implementations§

source§

impl Duration

source

pub fn to_raw(&self) -> String

Convert the Duration to a raw String

source

pub fn nanos(&self) -> u128

Get the total number of nanoseconds

source

pub fn micros(&self) -> u128

Get the total number of microseconds

source

pub fn millis(&self) -> u128

Get the total number of milliseconds

source

pub fn secs(&self) -> u64

Get the total number of seconds

source

pub fn mins(&self) -> u64

Get the total number of minutes

source

pub fn hours(&self) -> u64

Get the total number of hours

source

pub fn days(&self) -> u64

Get the total number of dats

source

pub fn weeks(&self) -> u64

Get the total number of months

source

pub fn years(&self) -> u64

Get the total number of years

source

pub fn from_nanos(nanos: u64) -> Duration

Create a duration from nanoseconds

source

pub fn from_micros(micros: u64) -> Duration

Create a duration from microseconds

source

pub fn from_millis(millis: u64) -> Duration

Create a duration from milliseconds

source

pub fn from_secs(secs: u64) -> Duration

Create a duration from seconds

source

pub fn from_mins(mins: u64) -> Duration

Create a duration from minutes

source

pub fn from_hours(hours: u64) -> Duration

Create a duration from hours

source

pub fn from_days(days: u64) -> Duration

Create a duration from days

source

pub fn from_weeks(days: u64) -> Duration

Create a duration from weeks

Methods from Deref<Target = Duration>§

source

pub const SECOND: Duration = _

source

pub const MILLISECOND: Duration = _

source

pub const MICROSECOND: Duration = _

source

pub const NANOSECOND: Duration = _

1.53.0 · source

pub const ZERO: Duration = _

1.53.0 · source

pub const MAX: Duration = _

1.53.0 · source

pub fn is_zero(&self) -> bool

Returns true if this Duration spans no time.

Examples
use std::time::Duration;

assert!(Duration::ZERO.is_zero());
assert!(Duration::new(0, 0).is_zero());
assert!(Duration::from_nanos(0).is_zero());
assert!(Duration::from_secs(0).is_zero());

assert!(!Duration::new(1, 1).is_zero());
assert!(!Duration::from_nanos(1).is_zero());
assert!(!Duration::from_secs(1).is_zero());
1.3.0 · source

pub fn as_secs(&self) -> u64

Returns the number of whole seconds contained by this Duration.

The returned value does not include the fractional (nanosecond) part of the duration, which can be obtained using subsec_nanos.

Examples
use std::time::Duration;

let duration = Duration::new(5, 730023852);
assert_eq!(duration.as_secs(), 5);

To determine the total number of seconds represented by the Duration including the fractional part, use as_secs_f64 or as_secs_f32

1.27.0 · source

pub fn subsec_millis(&self) -> u32

Returns the fractional part of this Duration, in whole milliseconds.

This method does not return the length of the duration when represented by milliseconds. The returned number always represents a fractional portion of a second (i.e., it is less than one thousand).

Examples
use std::time::Duration;

let duration = Duration::from_millis(5432);
assert_eq!(duration.as_secs(), 5);
assert_eq!(duration.subsec_millis(), 432);
1.27.0 · source

pub fn subsec_micros(&self) -> u32

Returns the fractional part of this Duration, in whole microseconds.

This method does not return the length of the duration when represented by microseconds. The returned number always represents a fractional portion of a second (i.e., it is less than one million).

Examples
use std::time::Duration;

let duration = Duration::from_micros(1_234_567);
assert_eq!(duration.as_secs(), 1);
assert_eq!(duration.subsec_micros(), 234_567);
1.3.0 · source

pub fn subsec_nanos(&self) -> u32

Returns the fractional part of this Duration, in nanoseconds.

This method does not return the length of the duration when represented by nanoseconds. The returned number always represents a fractional portion of a second (i.e., it is less than one billion).

Examples
use std::time::Duration;

let duration = Duration::from_millis(5010);
assert_eq!(duration.as_secs(), 5);
assert_eq!(duration.subsec_nanos(), 10_000_000);
1.33.0 · source

pub fn as_millis(&self) -> u128

Returns the total number of whole milliseconds contained by this Duration.

Examples
use std::time::Duration;

let duration = Duration::new(5, 730023852);
assert_eq!(duration.as_millis(), 5730);
1.33.0 · source

pub fn as_micros(&self) -> u128

Returns the total number of whole microseconds contained by this Duration.

Examples
use std::time::Duration;

let duration = Duration::new(5, 730023852);
assert_eq!(duration.as_micros(), 5730023);
1.33.0 · source

pub fn as_nanos(&self) -> u128

Returns the total number of nanoseconds contained by this Duration.

Examples
use std::time::Duration;

let duration = Duration::new(5, 730023852);
assert_eq!(duration.as_nanos(), 5730023852);
1.38.0 · source

pub fn as_secs_f64(&self) -> f64

Returns the number of seconds contained by this Duration as f64.

The returned value does include the fractional (nanosecond) part of the duration.

Examples
use std::time::Duration;

let dur = Duration::new(2, 700_000_000);
assert_eq!(dur.as_secs_f64(), 2.7);
1.38.0 · source

pub fn as_secs_f32(&self) -> f32

Returns the number of seconds contained by this Duration as f32.

The returned value does include the fractional (nanosecond) part of the duration.

Examples
use std::time::Duration;

let dur = Duration::new(2, 700_000_000);
assert_eq!(dur.as_secs_f32(), 2.7);

Trait Implementations§

source§

impl<'a, 'b> Add<&'b Duration> for &'a Duration

§

type Output = Duration

The resulting type after applying the + operator.
source§

fn add(self, other: &'b Duration) -> Duration

Performs the + operation. Read more
source§

impl Add<Datetime> for Duration

§

type Output = Datetime

The resulting type after applying the + operator.
source§

fn add(self, other: Datetime) -> Datetime

Performs the + operation. Read more
source§

impl Add for Duration

§

type Output = Duration

The resulting type after applying the + operator.
source§

fn add(self, other: Self) -> Self

Performs the + operation. Read more
source§

impl Clone for Duration

source§

fn clone(&self) -> Duration

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 Duration

source§

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

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

impl Default for Duration

source§

fn default() -> Duration

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

impl Deref for Duration

§

type Target = Duration

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<'de> Deserialize<'de> for Duration

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 Display for Duration

source§

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

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

impl From<Duration> for Duration

source§

fn from(v: Duration) -> Self

Converts to this type from the input type.
source§

impl From<Duration> for Duration

source§

fn from(s: Duration) -> Self

Converts to this type from the input type.
source§

impl From<Duration> for Value

source§

fn from(v: Duration) -> Self

Converts to this type from the input type.
source§

impl FromStr for Duration

§

type Err = ()

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
source§

impl Hash for Duration

source§

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

Feeds this value into the given Hasher. Read more
1.3.0 · source§

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

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

impl PartialEq for Duration

source§

fn eq(&self, other: &Duration) -> 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 for Duration

source§

fn partial_cmp(&self, other: &Duration) -> 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 Revisioned for Duration

source§

fn revision() -> u16

Returns the current revision of this type.

source§

fn serialize_revisioned<W: Write>(&self, writer: &mut W) -> Result<(), Error>

Serializes the struct using the specficifed writer.

source§

fn deserialize_revisioned<R: Read>(reader: &mut R) -> Result<Self, Error>

Deserializes a new instance of the struct from the specficifed reader.

source§

fn type_id() -> TypeId
where Self: 'static,

Returns the type id of this type.
source§

impl Serialize for Duration

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<'a, 'b> Sub<&'b Duration> for &'a Duration

§

type Output = Duration

The resulting type after applying the - operator.
source§

fn sub(self, other: &'b Duration) -> Duration

Performs the - operation. Read more
source§

impl Sub<Datetime> for Duration

§

type Output = Datetime

The resulting type after applying the - operator.
source§

fn sub(self, other: Datetime) -> Datetime

Performs the - operation. Read more
source§

impl Sub for Duration

§

type Output = Duration

The resulting type after applying the - operator.
source§

fn sub(self, other: Self) -> Self

Performs the - operation. Read more
source§

impl<'a> Sum<&'a Duration> for Duration

source§

fn sum<I>(iter: I) -> Duration
where I: Iterator<Item = &'a Self>,

Method which takes an iterator and generates Self from the elements by “summing up” the items.
source§

impl Sum for Duration

source§

fn sum<I>(iter: I) -> Duration
where I: Iterator<Item = Self>,

Method which takes an iterator and generates Self from the elements by “summing up” the items.
source§

impl TryFrom<&str> for Duration

§

type Error = ()

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

fn try_from(v: &str) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Strand> for Duration

§

type Error = ()

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

fn try_from(v: Strand) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<String> for Duration

§

type Error = ()

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

fn try_from(v: String) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl Copy for Duration

source§

impl Eq for Duration

source§

impl StructuralEq for Duration

source§

impl StructuralPartialEq for Duration

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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 T
where 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 for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where 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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where 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 T
where 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 T
where 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<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

source§

fn is_within(&self, b: &G2) -> bool

source§

impl<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

source§

fn is_within(&self, b: &G2) -> bool

source§

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

§

impl<T> ParallelSend for T
where T: Send,