Struct dcbor::Date

source ·
pub struct Date(_);
Expand description

A CBOR-friendly representation of a date and time.

Implementations§

source§

impl Date

source

pub fn from_datetime(date_time: DateTime<Utc>) -> Self

Creates a new Date from the given chrono DateTime.

source

pub fn from_timestamp(seconds_since_unix_epoch: i64) -> Self

Creates a new Date from seconds since (or before) the Unix epoch.

source

pub fn now() -> Self

Creates a new Date containing the current date and time.

source

pub fn datetime(&self) -> DateTime<Utc>

Returns the underlying chrono DateTime struct.

source

pub fn timestamp(&self) -> i64

Returns the Date as the number of seconds since the Unix epoch.

source

pub fn to_string(&self) -> String

Returns a string with the ISO-8601 (RFC-3339) representation of the date.

Trait Implementations§

source§

impl CBORDecodable for Date

source§

fn from_cbor(cbor: &CBOR) -> Result<Box<Self>, DecodeError>

Creates an instance of this type from CBOR symbolic representation.
source§

fn from_cbor_data(cbor_data: &[u8]) -> Result<Box<Self>, DecodeError>

Creates an instance of this type from encoded CBOR binary data.
source§

impl CBOREncodable for Date

source§

fn cbor(&self) -> CBOR

Returns the value in CBOR symbolic representation.
source§

fn cbor_data(&self) -> Vec<u8>

Returns the value in CBOR binary representation.
source§

impl CBORTaggedDecodable for Date

source§

const CBOR_TAG: Tag = _

The CBOR tag associated with this type.
source§

fn from_untagged_cbor(cbor: &CBOR) -> Result<Box<Self>, DecodeError>

Creates an instance of this type by decoding it from untagged CBOR.
source§

fn from_tagged_cbor(cbor: &CBOR) -> Result<Box<Self>, DecodeError>

Creates an instance of this type by decoding it from tagged CBOR.
source§

fn from_tagged_cbor_data(data: &[u8]) -> Result<Box<Self>, DecodeError>

Creates an instance of this type by decoding it from binary encoded tagged CBOR.
source§

fn from_untagged_cbor_data(data: &[u8]) -> Result<Box<Self>, DecodeError>

Creates an instance of this type by decoding it from binary encoded untagged CBOR.
source§

impl CBORTaggedEncodable for Date

source§

const CBOR_TAG: Tag = _

The CBOR tag assocated with this type.
source§

fn untagged_cbor(&self) -> CBOR

Returns the untagged CBOR encoding of this instance.
source§

fn tagged_cbor(&self) -> CBOR

Returns the tagged CBOR encoding of this instance.
source§

impl Clone for Date

source§

fn clone(&self) -> Date

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 Date

source§

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

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

impl Display for Date

source§

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

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

impl CBORCodable for Date

source§

impl CBORTaggedCodable for Date

Auto Trait Implementations§

§

impl RefUnwindSafe for Date

§

impl Send for Date

§

impl Sync for Date

§

impl Unpin for Date

§

impl UnwindSafe for Date

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,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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> 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> ToString for Twhere 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · 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.
const: unstable · source§

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

Performs the conversion.