|
1 |
| -//! Data providers for time zone data |
| 1 | +//! Providers for time zone data |
2 | 2 | //!
|
3 |
| -//! This crate aims to provide a variety of data providers |
4 |
| -//! for time zone data. |
| 3 | +//! Let's talk about time zone data everyone! |
| 4 | +//! |
| 5 | +//! At a high level, the `timezone_provider` crate provides a set of traits along with a few |
| 6 | +//! implementations of those traits. The general intention here is to make providing time zone |
| 7 | +//! data as agnostic and easy as possible. |
| 8 | +//! |
| 9 | +//! This crate is fairly "low level" at least as far as date and time needs are concerned. So |
| 10 | +//! we'll cover the basic overview of the trait and some of the general implementations of |
| 11 | +//! those traits, and then we will go on a bit further of a dive for the power users that |
| 12 | +//! are interested in implementing their own provider or is just really curious about what |
| 13 | +//! is going on. |
| 14 | +//! |
| 15 | +//! ## Available providers |
| 16 | +//! |
| 17 | +//! Below is a list of currently available time zone providers. |
| 18 | +//! |
| 19 | +//! - `ZoneInfo64TzdbProvider`: a provider using ICU4C's zoneinfo64 resource bundle (enable with `zoneinfo64` features flag) |
| 20 | +//! - `FsTzdbProvider`: a provider that reads and parses tzdata at runtime from the host file system's |
| 21 | +//! TZif files (enable with `tzif` feature flag) |
| 22 | +//! - `CompiledTzdbProvider`: a provider that reads and parses tzdata at runtime from TZif's compiled |
| 23 | +//! into the application (enable with `tzif` feature flag) |
| 24 | +//! |
| 25 | +//! Coming soon (hopefully), a zero copy compiled tzdb provider (see `experimental_tzif` for more). |
| 26 | +//! |
| 27 | +//! ## Time zone provider traits |
| 28 | +//! |
| 29 | +//! This crate provides three primary traits for working with time zone data. |
| 30 | +//! |
| 31 | +//! - [`TimeZoneProvider`][crate::provider::TimeZoneProvider] |
| 32 | +//! - [`TimeZoneNormalizer`][crate::provider::TimeZoneNormalizer] |
| 33 | +//! - [`TimeZoneResolver`][crate::provider::TimeZoneResolver] |
| 34 | +//! |
| 35 | +//! The first trait `TimeZoneProvider` is the primary interface for a time zone provider used by `temporal_rs`. |
| 36 | +//! |
| 37 | +//! Meanwhile, the two other traits, `TimeZoneNormalizer` and `TimeZoneResolver`, are secondary |
| 38 | +//! traits that can be used to implement the core `TimeZoneProvider`. Once implemented, this |
| 39 | +//! crate providers a default type for creating a `TimeZoneProvider` by mixing and matching objects that implement the secondary |
| 40 | +//! traits, `NormalizerAndResolver`. |
| 41 | +//! |
| 42 | +//! ### Why two secondary traits? |
| 43 | +//! |
| 44 | +//! Well that's because `TimeZoneProvider` handles two different concerns: fetching and |
| 45 | +//! formatting normalized and canonicalized time zone identifiers, and resolving time |
| 46 | +//! zone data requests. This functionality typically requires two different sets of data, |
| 47 | +//! each of which may be in a variety of formats. |
| 48 | +//! |
| 49 | +//! ### Why not just have the two secondary traits without `TimeZoneProvider`? |
| 50 | +//! |
| 51 | +//! Well while the functionality typically requires two sets of data. Those sets are not |
| 52 | +//! necessarily completely unique. The time zone database updates potentially multiple times a |
| 53 | +//! year so having your formatting in 2025a while your data is in 2025b could cause some |
| 54 | +//! desync. So in order to better represent this `TimeZoneProvider` is used on top of them. |
| 55 | +//! |
| 56 | +//! **NOTE:** you CAN always just directly use `TimeZoneNormalizer` and |
| 57 | +//! `TimeZoneResolver` together if you want. We just wouldn't recommemnd it. |
5 | 58 | //!
|
6 | 59 |
|
7 | 60 | #![no_std]
|
|
0 commit comments