#[cfg(feature = "parsing")] use core::marker::PhantomData;
#[cfg(feature = "formatting")] use serde::ser::Error as _; #[cfg(feature = "parsing")] use serde::Deserializer; #[cfg(feature = "formatting")] use serde::{Serialize, Serializer};
/// Serialize an [`OffsetDateTime`] using the well-known RFC3339 format. #[cfg(feature = "formatting")] pubfn serialize<S: Serializer>(
datetime: &OffsetDateTime,
serializer: S,
) -> Result<S::Ok, S::Error> {
datetime
.format(&Rfc3339)
.map_err(S::Error::custom)?
.serialize(serializer)
}
/// Deserialize an [`OffsetDateTime`] from its RFC3339 representation. #[cfg(feature = "parsing")] pubfn deserialize<'a, D: Deserializer<'a>>(deserializer: D) -> Result<OffsetDateTime, D::Error> {
deserializer.deserialize_str(Visitor::<Rfc3339>(PhantomData))
}
/// Use the well-known [RFC3339 format] when serializing and deserializing an /// [`Option<OffsetDateTime>`]. /// /// Use this module in combination with serde's [`#[with]`][with] attribute. /// /// [RFC3339 format]: https://tools.ietf.org/html/rfc3339#section-5.6 /// [with]: https://serde.rs/field-attrs.html#with pubmod option { #[allow(clippy::wildcard_imports)] usesuper::*;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.