| 1 |
// @generated |
| 2 |
/// Implement `DataProvider<WeekDataV1Marker>` on the given struct using the data |
| 3 |
/// hardcoded in this file. This allows the struct to be used with |
| 4 |
/// `icu`'s `_unstable` constructors. |
| 5 |
#[doc(hidden)] |
| 6 |
#[macro_export] |
| 7 |
macro_rules! __impl_datetime_week_data_v1 { |
| 8 |
($ provider : ty) => { |
| 9 |
#[clippy::msrv = "1.67"] |
| 10 |
const _: () = <$provider>::MUST_USE_MAKE_PROVIDER_MACRO; |
| 11 |
#[clippy::msrv = "1.67"] |
| 12 |
impl icu_provider::DataProvider<icu::calendar::provider::WeekDataV1Marker> for $provider { |
| 13 |
fn load(&self, req: icu_provider::DataRequest) -> Result<icu_provider::DataResponse<icu::calendar::provider::WeekDataV1Marker>, icu_provider::DataError> { |
| 14 |
static UND_MV: <icu::calendar::provider::WeekDataV1Marker as icu_provider::DataMarker>::Yokeable = icu::calendar::provider::WeekDataV1 { first_weekday: icu::calendar::types::IsoWeekday::Friday, min_week_days: 1u8 }; |
| 15 |
static UND: <icu::calendar::provider::WeekDataV1Marker as icu_provider::DataMarker>::Yokeable = icu::calendar::provider::WeekDataV1 { first_weekday: icu::calendar::types::IsoWeekday::Monday, min_week_days: 1u8 }; |
| 16 |
static UND_AD: <icu::calendar::provider::WeekDataV1Marker as icu_provider::DataMarker>::Yokeable = icu::calendar::provider::WeekDataV1 { first_weekday: icu::calendar::types::IsoWeekday::Monday, min_week_days: 4u8 }; |
| 17 |
static UND_AE: <icu::calendar::provider::WeekDataV1Marker as icu_provider::DataMarker>::Yokeable = icu::calendar::provider::WeekDataV1 { first_weekday: icu::calendar::types::IsoWeekday::Saturday, min_week_days: 1u8 }; |
| 18 |
static UND_AG: <icu::calendar::provider::WeekDataV1Marker as icu_provider::DataMarker>::Yokeable = icu::calendar::provider::WeekDataV1 { first_weekday: icu::calendar::types::IsoWeekday::Sunday, min_week_days: 1u8 }; |
| 19 |
static UND_PT: <icu::calendar::provider::WeekDataV1Marker as icu_provider::DataMarker>::Yokeable = icu::calendar::provider::WeekDataV1 { first_weekday: icu::calendar::types::IsoWeekday::Sunday, min_week_days: 4u8 }; |
| 20 |
static VALUES: [&<icu::calendar::provider::WeekDataV1Marker as icu_provider::DataMarker>::Yokeable; 115usize] = [&UND, &UND_AD, &UND_AE, &UND_AE, &UND_AG, &UND_AD, &UND_AG, &UND_AD, &UND_AD, &UND_AG, &UND_AD, &UND_AD, &UND_AE, &UND_AG, &UND_AG, &UND_AG, &UND_AG, &UND_AG, &UND_AG, &UND_AD, &UND_AG, &UND_AD, &UND_AD, &UND_AE, &UND_AD, &UND_AG, &UND_AG, &UND_AE, &UND_AD, &UND_AE, &UND_AD, &UND_AG, &UND_AD, &UND_AD, &UND_AD, &UND_AD, &UND_AD, &UND_AD, &UND_AD, &UND_AD, &UND_AD, &UND_AD, &UND_AG, &UND_AG, &UND_AG, &UND_AG, &UND_AD, &UND_AG, &UND_AD, &UND_AG, &UND_AD, &UND_AG, &UND_AE, &UND_AE, &UND_AD, &UND_AD, &UND_AD, &UND_AG, &UND_AE, &UND_AG, &UND_AG, &UND_AG, &UND_AG, &UND_AE, &UND_AG, &UND_AD, &UND_AD, &UND_AD, &UND_AE, &UND_AD, &UND_AG, &UND_AG, &UND_AG, &UND_AD, &UND_AG, &UND_MV, &UND_AG, &UND_AG, &UND_AG, &UND_AD, &UND_AD, &UND_AG, &UND_AE, &UND_AG, &UND_AG, &UND_AG, &UND_AG, &UND_AD, &UND_AG, &UND_PT, &UND_AG, &UND_AE, &UND_AD, &UND_AD, &UND_AG, &UND_AE, &UND_AD, &UND_AG, &UND_AD, &UND_AD, &UND_AD, &UND_AG, &UND_AE, &UND_AG, &UND_AG, &UND_AG, &UND_AG, &UND_AG, &UND_AD, &UND_AG, &UND_AG, &UND_AG, &UND_AG, &UND_AG, &UND_AG]; |
| 21 |
static KEYS: [&str; 115usize] = ["und", "und-AD", "und-AE", "und-AF", "und-AG", "und-AN", "und-AS", "und-AT", "und-AX", "und-BD", "und-BE", "und-BG", "und-BH", "und-BR", "und-BS", "und-BT", "und-BW", "und-BZ", "und-CA", "und-CH", "und-CO", "und-CZ", "und-DE", "und-DJ", "und-DK", "und-DM", "und-DO", "und-DZ", "und-EE", "und-EG", "und-ES", "und-ET", "und-FI", "und-FJ", "und-FO", "und-FR", "und-GB", "und-GF", "und-GG", "und-GI", "und-GP", "und-GR", "und-GT", "und-GU", "und-HK", "und-HN", "und-HU", "und-ID", "und-IE", "und-IL", "und-IM", "und-IN", "und-IQ", "und-IR", "und-IS", "und-IT", "und-JE", "und-JM", "und-JO", "und-JP", "und-KE", "und-KH", "und-KR", "und-KW", "und-LA", "und-LI", "und-LT", "und-LU", "und-LY", "und-MC", "und-MH", "und-MM", "und-MO", "und-MQ", "und-MT", "und-MV", "und-MX", "und-MZ", "und-NI", "und-NL", "und-NO", "und-NP", "und-OM", "und-PA", "und-PE", "und-PH", "und-PK", "und-PL", "und-PR", "und-PT", "und-PY", "und-QA", "und-RE", "und-RU", "und-SA", "und-SD", "und-SE", "und-SG", "und-SJ", "und-SK", "und-SM", "und-SV", "und-SY", "und-TH", "und-TT", "und-TW", "und-UM", "und-US", "und-VA", "und-VE", "und-VI", "und-WS", "und-YE", "und-ZA", "und-ZW"]; |
| 22 |
let mut metadata = icu_provider::DataResponseMetadata::default(); |
| 23 |
let payload = if let Ok(payload) = KEYS.binary_search_by(|k| req.locale.strict_cmp(k.as_bytes()).reverse()).map(|i| *unsafe { VALUES.get_unchecked(i) }) { |
| 24 |
payload |
| 25 |
} else { |
| 26 |
const FALLBACKER: icu::locid_transform::fallback::LocaleFallbackerWithConfig<'static> = icu::locid_transform::fallback::LocaleFallbacker::new().for_config(<icu::calendar::provider::WeekDataV1Marker as icu_provider::KeyedDataMarker>::KEY.fallback_config()); |
| 27 |
let mut fallback_iterator = FALLBACKER.fallback_for(req.locale.clone()); |
| 28 |
loop { |
| 29 |
if let Ok(payload) = KEYS.binary_search_by(|k| fallback_iterator.get().strict_cmp(k.as_bytes()).reverse()).map(|i| *unsafe { VALUES.get_unchecked(i) }) { |
| 30 |
metadata.locale = Some(fallback_iterator.take()); |
| 31 |
break payload; |
| 32 |
} |
| 33 |
if fallback_iterator.get().is_und() { |
| 34 |
return Err(icu_provider::DataErrorKind::MissingLocale.with_req(<icu::calendar::provider::WeekDataV1Marker as icu_provider::KeyedDataMarker>::KEY, req)); |
| 35 |
} |
| 36 |
fallback_iterator.step(); |
| 37 |
} |
| 38 |
}; |
| 39 |
Ok(icu_provider::DataResponse { payload: Some(icu_provider::DataPayload::from_static_ref(payload)), metadata }) |
| 40 |
} |
| 41 |
} |
| 42 |
}; |
| 43 |
} |
| 44 |
/// Implement `IterableDataProvider<WeekDataV1Marker>` on the given struct using the data |
| 45 |
/// hardcoded in this file. This allows the struct to be used with |
| 46 |
/// `DatagenDriver` for this key. |
| 47 |
#[doc(hidden)] |
| 48 |
#[macro_export] |
| 49 |
macro_rules! __impliterable_datetime_week_data_v1 { |
| 50 |
($ provider : ty) => { |
| 51 |
#[clippy::msrv = "1.67"] |
| 52 |
impl icu_provider::datagen::IterableDataProvider<icu::calendar::provider::WeekDataV1Marker> for $provider { |
| 53 |
fn supported_locales(&self) -> Result<alloc::vec::Vec<icu_provider::DataLocale>, icu_provider::DataError> { |
| 54 |
Ok(["und", "und-AD", "und-AE", "und-AF", "und-AG", "und-AN", "und-AS", "und-AT", "und-AX", "und-BD", "und-BE", "und-BG", "und-BH", "und-BR", "und-BS", "und-BT", "und-BW", "und-BZ", "und-CA", "und-CH", "und-CO", "und-CZ", "und-DE", "und-DJ", "und-DK", "und-DM", "und-DO", "und-DZ", "und-EE", "und-EG", "und-ES", "und-ET", "und-FI", "und-FJ", "und-FO", "und-FR", "und-GB", "und-GF", "und-GG", "und-GI", "und-GP", "und-GR", "und-GT", "und-GU", "und-HK", "und-HN", "und-HU", "und-ID", "und-IE", "und-IL", "und-IM", "und-IN", "und-IQ", "und-IR", "und-IS", "und-IT", "und-JE", "und-JM", "und-JO", "und-JP", "und-KE", "und-KH", "und-KR", "und-KW", "und-LA", "und-LI", "und-LT", "und-LU", "und-LY", "und-MC", "und-MH", "und-MM", "und-MO", "und-MQ", "und-MT", "und-MV", "und-MX", "und-MZ", "und-NI", "und-NL", "und-NO", "und-NP", "und-OM", "und-PA", "und-PE", "und-PH", "und-PK", "und-PL", "und-PR", "und-PT", "und-PY", "und-QA", "und-RE", "und-RU", "und-SA", "und-SD", "und-SE", "und-SG", "und-SJ", "und-SK", "und-SM", "und-SV", "und-SY", "und-TH", "und-TT", "und-TW", "und-UM", "und-US", "und-VA", "und-VE", "und-VI", "und-WS", "und-YE", "und-ZA", "und-ZW"].into_iter().map(|s| <icu_provider::DataLocale as core::str::FromStr>::from_str(s).unwrap()).collect()) |
| 55 |
} |
| 56 |
} |
| 57 |
}; |
| 58 |
} |