Debian Codegraph @

debian/rust-vendor/time/src/lib.rs

raw
1 //! # Feature flags
2 //!
3 //! This crate exposes a number of features. These can be enabled or disabled as shown
4 //! [in Cargo's documentation](https://doc.rust-lang.org/cargo/reference/features.html). Features
5 //! are _disabled_ by default unless otherwise noted.
6 //!
7 //! Reliance on a given feature is always indicated alongside the item definition.
8 //!
9 //! - `std` (_enabled by default, implicitly enables `alloc`_)
10 //!
11 //! This enables a number of features that depend on the standard library.
12 //!
13 //! - `alloc` (_enabled by default via `std`_)
14 //!
15 //! Enables a number of features that require the ability to dynamically allocate memory.
16 //!
17 //! - `macros`
18 //!
19 //! Enables macros that provide compile-time verification of values and intuitive syntax.
20 //!
21 //! - `formatting` (_implicitly enables `std`_)
22 //!
23 //! Enables formatting of most structs.
24 //!
25 //! - `parsing`
26 //!
27 //! Enables parsing of most structs.
28 //!
29 //! - `local-offset` (_implicitly enables `std`_)
30 //!
31 //! This feature enables a number of methods that allow obtaining the system's UTC offset.
32 //!
33 //! - `large-dates`
34 //!
35 //! By default, only years within the ±9999 range (inclusive) are supported. If you need support
36 //! for years outside this range, consider enabling this feature; the supported range will be
37 //! increased to ±999,999.
38 //!
39 //! Note that enabling this feature has some costs, as it means forgoing some optimizations.
40 //! Ambiguities may be introduced when parsing that would not otherwise exist.
41 //!
42 //! - `serde`
43 //!
44 //! Enables [`serde`](https://docs.rs/serde) support for all types.
45 //!
46 //! - `serde-human-readable` (_implicitly enables `serde`, `formatting`, and `parsing`_)
47 //!
48 //! Allows `serde` representations to use a human-readable format. This is determined by the
49 //! serializer, not the user. If this feature is not enabled or if the serializer requests a
50 //! non-human-readable format, a format optimized for binary representation will be used.
51 //!
52 //! Libraries should never enable this feature, as the decision of what format to use should be up
53 //! to the user.
54 //!
55 //! - `rand` (_implicitly enables `rand08`, `rand09`, and `rand010`_)
56 //!
57 //! Previously, this would enable support for `rand` 0.8. Since the release of `rand` 0.9, the
58 //! feature has been split into `rand08` and `rand09` to allow support for both versions. `rand`
59 //! 0.10 has since been added. For backwards compatibility and simplicity, this feature enables
60 //! support for _all_ series.
61 //!
62 //! It is strongly recommended to enable the version you need directly, as enabling `rand` will
63 //! needlessly pull in all versions.
64 //!
65 //! - `rand08`, `rand09`, `rand010`
66 //!
67 //! Enables [`rand` 0.8](https://docs.rs/rand/0.8), [`rand` 0.9](https://docs.rs/rand/0.9), and
68 //! [`rand` 0.10](https://docs.rs/rand/0.10) support for all types, respectively.
69 //!
70 //! - `quickcheck` (_implicitly enables `alloc`_)
71 //!
72 //! Enables [quickcheck](https://docs.rs/quickcheck) support for all types.
73 //!
74 //! - `wasm-bindgen`
75 //!
76 //! Enables [`wasm-bindgen`](https://github.com/rustwasm/wasm-bindgen) support for converting
77 //! [JavaScript dates](https://rustwasm.github.io/wasm-bindgen/api/js_sys/struct.Date.html), as
78 //! well as obtaining the UTC offset from JavaScript.
79
80 #![doc(html_playground_url = "https://play.rust-lang.org")]
81 #![cfg_attr(docsrs, feature(doc_cfg, doc_notable_trait))]
82 #![no_std]
83 #![doc(html_favicon_url = "https://avatars0.githubusercontent.com/u/55999857")]
84 #![doc(html_logo_url = "https://avatars0.githubusercontent.com/u/55999857")]
85 #![doc(test(attr(deny(warnings))))]
86
87 #[allow(unused_extern_crates)]
88 #[cfg(feature = "alloc")]
89 extern crate alloc;
90
91 #[cfg(feature = "std")]
92 extern crate std;
93
94 /// Deprecated module for units of time.
95 #[deprecated(note = "import from `time::unit` instead")]
96 pub mod convert {
97 pub use time_core::unit::*;
98 }
99 mod date;
100 pub mod error;
101 pub mod ext;
102 #[cfg(any(feature = "formatting", feature = "parsing"))]
103 pub mod format_description;
104 #[cfg(feature = "formatting")]
105 pub mod formatting;
106 mod hint;
107 #[cfg(feature = "std")]
108 mod instant;
109 mod internal_macros;
110 mod interop;
111 pub mod iter;
112 #[cfg(feature = "macros")]
113 pub mod macros;
114 mod month;
115 mod num_fmt;
116 mod offset_date_time;
117 #[cfg(feature = "parsing")]
118 pub mod parsing;
119 mod plain_date_time;
120 #[cfg(feature = "quickcheck")]
121 mod quickcheck;
122 #[cfg(feature = "rand010")]
123 mod rand010;
124 #[cfg(feature = "rand08")]
125 mod rand08;
126 #[cfg(feature = "rand09")]
127 mod rand09;
128 #[cfg(feature = "serde")]
129 pub mod serde;
130 mod signed_duration;
131 mod sys;
132 #[cfg(test)]
133 mod tests;
134 mod time;
135 mod timestamp;
136 mod utc_date_time;
137 mod utc_offset;
138 pub mod util;
139 mod weekday;
140
141 pub use time_core::unit;
142
143 pub use crate::date::Date;
144 pub use crate::error::Error;
145 #[doc(hidden)]
146 #[cfg(feature = "std")]
147 #[expect(deprecated)]
148 pub use crate::instant::Instant;
149 pub use crate::month::Month;
150 pub use crate::offset_date_time::OffsetDateTime;
151 pub use crate::plain_date_time::PlainDateTime;
152 pub use crate::signed_duration::SignedDuration;
153 pub use crate::time::Time;
154 pub use crate::timestamp::Timestamp;
155 pub use crate::utc_date_time::UtcDateTime;
156 pub use crate::utc_offset::UtcOffset;
157 pub use crate::weekday::Weekday;
158
159 /// An alias for [`std::result::Result`] with a generic error from the time crate.
160 pub type Result<T> = core::result::Result<T, Error>;
161 /// A [`PlainDateTime`] under its original name.
162 ///
163 /// This type is not currently deprecated, but it likely will be in the future. Use
164 /// [`PlainDateTime`] when writing new code. In the next breaking release, this alias will be
165 /// removed.
166 pub type PrimitiveDateTime = PlainDateTime;
167 /// A [`SignedDuration`] under its original name.
168 ///
169 /// This type is not currently deprecated, but it likely will be in the future. Use
170 /// [`SignedDuration`] when writing new code. In the next breaking release, this alias will be
171 /// removed.
172 pub type Duration = SignedDuration;
173
174 /// A private type used to restrict the ability to call methods that are not intended to be called
175 /// by downstream users.
176 #[cfg(any(feature = "formatting", feature = "parsing"))]
177 #[derive(Debug)]
178 struct PrivateMethod;