pub enum DateOrDateTime {
Date(Date),
DateTime(OffsetDateTime),
}
Expand description
Represents either a Date
(YYYY-MM-DD
) or a full OffsetDateTime
(RFC 3339
) value.
This enum is useful when the input format can vary between:
- A date-only string, like
"2024-05-01"
- A full datetime string with offset, like
"2024-05-01T00:00:00Z"
When deserializing, the format determines which variant is used:
"YYYY-MM-DD"
→DateOrDateTime::Date
- RFC 3339 datetime →
DateOrDateTime::DateTime
§Examples
"2024-05-01" // => Date(...)
"2024-05-01T00:00:00+00:00" // => DateTime(...)
This enum uses custom (de)serializers to support both formats.
Variants§
Date(Date)
A date-only value (e.g. "2024-05-01"
).
DateTime(OffsetDateTime)
A full date-time with offset (RFC 3339 format).
Trait Implementations§
Source§impl Clone for DateOrDateTime
impl Clone for DateOrDateTime
Source§fn clone(&self) -> DateOrDateTime
fn clone(&self) -> DateOrDateTime
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for DateOrDateTime
impl Debug for DateOrDateTime
Source§impl Default for DateOrDateTime
impl Default for DateOrDateTime
Source§impl<'de> Deserialize<'de> for DateOrDateTime
impl<'de> Deserialize<'de> for DateOrDateTime
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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 DateOrDateTime
impl Display for DateOrDateTime
Source§impl From<DateOrDateTime> for PageDateProperty
impl From<DateOrDateTime> for PageDateProperty
Source§fn from(value: DateOrDateTime) -> Self
fn from(value: DateOrDateTime) -> Self
Converts to this type from the input type.
Source§impl PartialEq for DateOrDateTime
impl PartialEq for DateOrDateTime
Source§impl Serialize for DateOrDateTime
impl Serialize for DateOrDateTime
impl Copy for DateOrDateTime
impl Eq for DateOrDateTime
impl StructuralPartialEq for DateOrDateTime
Auto Trait Implementations§
impl Freeze for DateOrDateTime
impl RefUnwindSafe for DateOrDateTime
impl Send for DateOrDateTime
impl Sync for DateOrDateTime
impl Unpin for DateOrDateTime
impl UnwindSafe for DateOrDateTime
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more