Debian Codegraph @

debian/rust-vendor/time/src/format_description/mod.rs

raw
1 //! Description of how types should be formatted and parsed.
2 //!
3 //! The formatted value will be output to the provided writer. Format descriptions can be
4 //! [well-known](crate::format_description::well_known) or obtained by using the
5 //! [`format_description!`](crate::macros::format_description) macro or a function listed below.
6 //!
7 //! For examples, see the implementors of [Formattable](crate::formatting::Formattable),
8 //! e.g. [`well_known::Rfc3339`].
9
10 mod borrowed_format_item;
11 mod component;
12 pub(crate) mod format_description_v3;
13 pub mod modifier;
14 #[cfg(feature = "alloc")]
15 mod owned_format_item;
16 #[cfg(feature = "alloc")]
17 mod parse;
18
19 /// Well-known formats, typically standards.
20 pub mod well_known {
21 pub mod iso8601;
22 mod rfc2822;
23 mod rfc3339;
24
25 #[doc(inline)]
26 pub use iso8601::Iso8601;
27 pub use rfc2822::Rfc2822;
28 pub use rfc3339::Rfc3339;
29 }
30
31 /// Re-exports of internal types for use in macros.
32 ///
33 /// Do not rely on the existence of this module for any reason. It, in its entirety, is not
34 /// considered public API, is not subject to semantic versioning, and may be changed or removed at
35 /// any point.
36 #[doc(hidden)]
37 pub mod __private {
38 pub use super::format_description_v3::{Component, FormatDescriptionV3Inner};
39 }
40
41 pub use borrowed_format_item::BorrowedFormatItem;
42 #[doc(hidden)]
43 #[deprecated(since = "0.3.37", note = "use `BorrowedFormatItem` for clarity")]
44 pub use borrowed_format_item::BorrowedFormatItem as FormatItem;
45 #[cfg(feature = "alloc")]
46 pub use owned_format_item::OwnedFormatItem;
47
48 pub use self::component::Component;
49 pub use self::format_description_v3::FormatDescriptionV3;
50 #[cfg(feature = "alloc")]
51 #[expect(deprecated, reason = "backwards compatibility")]
52 pub use self::parse::parse;
53 #[cfg(feature = "alloc")]
54 pub use self::parse::{parse_borrowed, parse_owned, parse_strftime_borrowed, parse_strftime_owned};
55
56 /// The type output by the [`format_description!`](crate::macros::format_description) macro.
57 pub type StaticFormatDescription = &'static [BorrowedFormatItem<'static>];
58
59 /// Indicate whether the hour is "am" or "pm".
60 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
61 pub(crate) enum Period {
62 #[allow(clippy::missing_docs_in_private_items)]
63 Am,
64 #[allow(clippy::missing_docs_in_private_items)]
65 Pm,
66 }