#[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 RFC2822 format. #[cfg(feature = "formatting")] pubfn serialize<S: Serializer>(
datetime: &OffsetDateTime,
serializer: S,
) -> Result<S::Ok, S::Error> {
datetime
.format(&Rfc2822)
.map_err(S::Error::custom)?
.serialize(serializer)
}
/// Deserialize an [`OffsetDateTime`] from its RFC2822 representation. #[cfg(feature = "parsing")] pubfn deserialize<'a, D: Deserializer<'a>>(deserializer: D) -> Result<OffsetDateTime, D::Error> {
deserializer.deserialize_str(Visitor::<Rfc2822>(PhantomData))
}
/// Use the well-known [RFC2822 format] when serializing and deserializing an /// [`Option<OffsetDateTime>`]. /// /// Use this module in combination with serde's [`#[with]`][with] attribute. /// /// [RFC2822 format]: https://tools.ietf.org/html/rfc2822#section-3.3 /// [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.