Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better modularisation in icu_provider #5088

Merged
merged 13 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/datetime/src/calendar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use crate::provider::neo::*;
#[cfg(feature = "experimental")]
use core::marker::PhantomData;
#[cfg(any(feature = "datagen", feature = "experimental"))]
use icu_provider::NeverMarker;
use icu_provider::marker::NeverMarker;

/// The `CldrCalendar` trait is sealed except when the `"experimental"` Cargo
/// feature is enabled. If implementing `CldrCalendar`, you must also
Expand Down
2 changes: 1 addition & 1 deletion components/datetime/src/neo_marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use icu_calendar::{
},
AnyCalendar, AnyCalendarKind, AsCalendar, Calendar, Date, DateTime, Ref, Time,
};
use icu_provider::{prelude::*, NeverMarker};
use icu_provider::{marker::NeverMarker, prelude::*};
use icu_timezone::CustomTimeZone;

mod private {
Expand Down
8 changes: 4 additions & 4 deletions components/datetime/src/provider/calendar/symbols.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ symbols!(
feature = "serde",
serde(
borrow,
deserialize_with = "icu_provider::serde::borrow_de_utils::array_of_cow"
deserialize_with = "icu_provider::serde_borrow_de_utils::array_of_cow"
)
)]
[Cow<'data, str>; 12],
Expand Down Expand Up @@ -363,7 +363,7 @@ symbols!(
feature = "serde",
serde(
borrow,
deserialize_with = "icu_provider::serde::borrow_de_utils::array_of_cow"
deserialize_with = "icu_provider::serde_borrow_de_utils::array_of_cow"
)
)]
pub [Cow<'data, str>; 7],
Expand All @@ -385,7 +385,7 @@ symbols!(
feature = "serde",
serde(
borrow,
deserialize_with = "icu_provider::serde::borrow_de_utils::option_of_cow"
deserialize_with = "icu_provider::serde_borrow_de_utils::option_of_cow"
)
)]
/// Day period for noon, in locales that support it.
Expand All @@ -394,7 +394,7 @@ symbols!(
feature = "serde",
serde(
borrow,
deserialize_with = "icu_provider::serde::borrow_de_utils::option_of_cow"
deserialize_with = "icu_provider::serde_borrow_de_utils::option_of_cow"
)
)]
/// Day period for midnight, in locales that support it.
Expand Down
2 changes: 1 addition & 1 deletion components/datetime/src/provider/time_zones.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub struct TimeZoneFormatsV1<'data> {
#[cfg_attr(feature = "serde", serde(borrow))]
#[cfg_attr(
feature = "serde",
serde(deserialize_with = "icu_provider::serde::borrow_de_utils::tuple_of_cow")
serde(deserialize_with = "icu_provider::serde_borrow_de_utils::tuple_of_cow")
)]
pub hour_format: (Cow<'data, str>, Cow<'data, str>),
/// The localized GMT-offset format.
Expand Down
2 changes: 1 addition & 1 deletion components/experimental/src/personnames/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use core::fmt::{Debug, Formatter};

use icu_provider::prelude::*;
#[cfg(feature = "serde")]
use icu_provider::serde::borrow_de_utils::option_of_cow;
use icu_provider::serde_borrow_de_utils::option_of_cow;
use zerovec::VarZeroVec;

use crate::personnames::api::FormattingFormality;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion components/list/src/provider/serde_dfa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl<'data> SerdeDFA<'data> {
where
D: serde::de::Deserializer<'de>,
{
use icu_provider::serde::borrow_de_utils::CowBytesWrap;
use icu_provider::serde_borrow_de_utils::CowBytesWrap;
use serde::Deserialize;

#[cfg(feature = "serde_human")]
Expand Down
2 changes: 1 addition & 1 deletion components/properties/src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ macro_rules! data_struct_generic {
}
impl icu_provider::DataMarker for $marker {
const INFO: icu_provider::DataMarkerInfo = {
let mut info = DataMarkerInfo::from_path(icu_provider::data_marker_path!($path));
let mut info = DataMarkerInfo::from_path(icu_provider::marker::data_marker_path!($path));
info.is_singleton = true;
info
};
Expand Down
2 changes: 1 addition & 1 deletion ffi/capi/src/data_struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use alloc::borrow::Cow;
pub mod ffi {

use alloc::boxed::Box;
use icu_provider::AnyPayload;
use icu_provider::any::AnyPayload;
use icu_provider::DataPayload;

#[diplomat::opaque]
Expand Down
8 changes: 3 additions & 5 deletions ffi/capi/src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
#[allow(unused_imports)] // feature-specific
use alloc::boxed::Box;
use icu_provider::prelude::*;
#[allow(unused_imports)] // feature-specific
use icu_provider::MaybeSendSync;
use icu_provider_adapters::empty::EmptyDataProvider;
#[allow(unused_imports)] // feature-specific
use yoke::{trait_hack::YokeTraitHack, Yokeable};
Expand Down Expand Up @@ -38,7 +36,7 @@ pub mod ffi {
pub struct ICU4XDataProvider(pub ICU4XDataProviderInner);

#[cfg(feature = "buffer_provider")]
fn convert_buffer_provider<D: icu_provider::BufferProvider + 'static>(
fn convert_buffer_provider<D: icu_provider::buf::BufferProvider + 'static>(
x: D,
) -> ICU4XDataProvider {
ICU4XDataProvider(super::ICU4XDataProviderInner::Buffer(Box::new(x)))
Expand Down Expand Up @@ -297,7 +295,7 @@ macro_rules! call_constructor_unstable {
))?,
$crate::provider::ICU4XDataProviderInner::Empty => $unstable(&icu_provider_adapters::empty::EmptyDataProvider::new(), $($args,)*),
#[cfg(feature = "buffer_provider")]
$crate::provider::ICU4XDataProviderInner::Buffer(buffer_provider) => $unstable(&icu_provider::AsDeserializingBufferProvider::as_deserializing(buffer_provider), $($args,)*),
$crate::provider::ICU4XDataProviderInner::Buffer(buffer_provider) => $unstable(&icu_provider::buf::AsDeserializingBufferProvider::as_deserializing(buffer_provider), $($args,)*),
#[cfg(feature = "compiled_data")]
$crate::provider::ICU4XDataProviderInner::Compiled => { let $pre_transform = $compiled($($args,)*); $transform },
}
Expand All @@ -309,7 +307,7 @@ macro_rules! call_constructor_unstable {
))?,
$crate::provider::ICU4XDataProviderInner::Empty => $unstable(&icu_provider_adapters::empty::EmptyDataProvider::new(), $($args,)*),
#[cfg(feature = "buffer_provider")]
$crate::provider::ICU4XDataProviderInner::Buffer(buffer_provider) => $unstable(&icu_provider::AsDeserializingBufferProvider::as_deserializing(buffer_provider), $($args,)*),
$crate::provider::ICU4XDataProviderInner::Buffer(buffer_provider) => $unstable(&icu_provider::buf::AsDeserializingBufferProvider::as_deserializing(buffer_provider), $($args,)*),
#[cfg(feature = "compiled_data")]
$crate::provider::ICU4XDataProviderInner::Compiled => $compiled($($args,)*),
}
Expand Down
4 changes: 3 additions & 1 deletion ffi/capi/src/timezone_formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ macro_rules! call_method {
.$unstable(&icu_provider_adapters::empty::EmptyDataProvider::new()),
#[cfg(feature = "buffer_provider")]
$crate::provider::ICU4XDataProviderInner::Buffer(buffer_provider) => $self.0.$unstable(
&icu_provider::AsDeserializingBufferProvider::as_deserializing(buffer_provider),
&icu_provider::buf::AsDeserializingBufferProvider::as_deserializing(
buffer_provider,
),
),
#[cfg(feature = "compiled_data")]
$crate::provider::ICU4XDataProviderInner::Compiled => $self.0.$compiled(),
Expand Down
24 changes: 12 additions & 12 deletions ffi/harfbuzz/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,14 @@ impl GeneralCategoryData {

#[doc = icu_provider::gen_any_buffer_unstable_docs!(ANY, Self::try_new_unstable)]
pub fn try_new_with_any_provider(
provider: &(impl icu_provider::AnyProvider + ?Sized),
provider: &(impl icu_provider::any::AnyProvider + ?Sized),
) -> Result<Self, DataError> {
Self::try_new_unstable(&provider.as_downcasting())
}
#[cfg(feature = "serde")]
#[doc = icu_provider::gen_any_buffer_unstable_docs!(BUFFER,Self::try_new_unstable)]
pub fn try_new_with_buffer_provider(
provider: &(impl icu_provider::BufferProvider + ?Sized),
provider: &(impl icu_provider::buf::BufferProvider + ?Sized),
) -> Result<Self, DataError> {
Self::try_new_unstable(&provider.as_deserializing())
}
Expand Down Expand Up @@ -228,14 +228,14 @@ impl CombiningClassData {

#[doc = icu_provider::gen_any_buffer_unstable_docs!(ANY, Self::try_new_unstable)]
pub fn try_new_with_any_provider(
provider: &(impl icu_provider::AnyProvider + ?Sized),
provider: &(impl icu_provider::any::AnyProvider + ?Sized),
) -> Result<Self, DataError> {
Self::try_new_unstable(&provider.as_downcasting())
}
#[cfg(feature = "serde")]
#[doc = icu_provider::gen_any_buffer_unstable_docs!(BUFFER,Self::try_new_unstable)]
pub fn try_new_with_buffer_provider(
provider: &(impl icu_provider::BufferProvider + ?Sized),
provider: &(impl icu_provider::buf::BufferProvider + ?Sized),
) -> Result<Self, DataError> {
Self::try_new_unstable(&provider.as_deserializing())
}
Expand Down Expand Up @@ -269,14 +269,14 @@ impl MirroringData {

#[doc = icu_provider::gen_any_buffer_unstable_docs!(ANY, Self::try_new_unstable)]
pub fn try_new_with_any_provider(
provider: &(impl icu_provider::AnyProvider + ?Sized),
provider: &(impl icu_provider::any::AnyProvider + ?Sized),
) -> Result<Self, DataError> {
Self::try_new_unstable(&provider.as_downcasting())
}
#[cfg(feature = "serde")]
#[doc = icu_provider::gen_any_buffer_unstable_docs!(BUFFER,Self::try_new_unstable)]
pub fn try_new_with_buffer_provider(
provider: &(impl icu_provider::BufferProvider + ?Sized),
provider: &(impl icu_provider::buf::BufferProvider + ?Sized),
) -> Result<Self, DataError> {
Self::try_new_unstable(&provider.as_deserializing())
}
Expand Down Expand Up @@ -318,14 +318,14 @@ impl ScriptData {

#[doc = icu_provider::gen_any_buffer_unstable_docs!(ANY, Self::try_new_unstable)]
pub fn try_new_with_any_provider(
provider: &(impl icu_provider::AnyProvider + ?Sized),
provider: &(impl icu_provider::any::AnyProvider + ?Sized),
) -> Result<Self, DataError> {
Self::try_new_unstable(&provider.as_downcasting())
}
#[cfg(feature = "serde")]
#[doc = icu_provider::gen_any_buffer_unstable_docs!(BUFFER,Self::try_new_unstable)]
pub fn try_new_with_buffer_provider(
provider: &(impl icu_provider::BufferProvider + ?Sized),
provider: &(impl icu_provider::buf::BufferProvider + ?Sized),
) -> Result<Self, DataError> {
Self::try_new_unstable(&provider.as_deserializing())
}
Expand Down Expand Up @@ -365,14 +365,14 @@ impl ComposeData {

#[doc = icu_provider::gen_any_buffer_unstable_docs!(ANY, Self::try_new_unstable)]
pub fn try_new_with_any_provider(
provider: &(impl icu_provider::AnyProvider + ?Sized),
provider: &(impl icu_provider::any::AnyProvider + ?Sized),
) -> Result<Self, DataError> {
Self::try_new_unstable(&provider.as_downcasting())
}
#[cfg(feature = "serde")]
#[doc = icu_provider::gen_any_buffer_unstable_docs!(BUFFER,Self::try_new_unstable)]
pub fn try_new_with_buffer_provider(
provider: &(impl icu_provider::BufferProvider + ?Sized),
provider: &(impl icu_provider::buf::BufferProvider + ?Sized),
) -> Result<Self, DataError> {
Self::try_new_unstable(&provider.as_deserializing())
}
Expand Down Expand Up @@ -409,14 +409,14 @@ impl DecomposeData {

#[doc = icu_provider::gen_any_buffer_unstable_docs!(ANY, Self::try_new_unstable)]
pub fn try_new_with_any_provider(
provider: &(impl icu_provider::AnyProvider + ?Sized),
provider: &(impl icu_provider::any::AnyProvider + ?Sized),
) -> Result<Self, DataError> {
Self::try_new_unstable(&provider.as_downcasting())
}
#[cfg(feature = "serde")]
#[doc = icu_provider::gen_any_buffer_unstable_docs!(BUFFER,Self::try_new_unstable)]
pub fn try_new_with_buffer_provider(
provider: &(impl icu_provider::BufferProvider + ?Sized),
provider: &(impl icu_provider::buf::BufferProvider + ?Sized),
) -> Result<Self, DataError> {
Self::try_new_unstable(&provider.as_deserializing())
}
Expand Down
10 changes: 5 additions & 5 deletions provider/adapters/src/any_payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use zerofrom::ZeroFrom;
/// # type Yokeable = <HelloWorldV1Marker as DynamicDataMarker>::Yokeable;
/// # }
/// # impl DataMarker for DummyMarker {
/// # const INFO: DataMarkerInfo = DataMarkerInfo::from_path(icu_provider::data_marker_path!("dummy@1"));
/// # const INFO: DataMarkerInfo = DataMarkerInfo::from_path(icu_provider::marker::data_marker_path!("dummy@1"));
/// # }
/// // Requests for invalid markers get MissingDataMarker
/// assert!(matches!(
Expand All @@ -66,7 +66,7 @@ impl AnyPayloadProvider {
/// Creates an `AnyPayloadProvider` with an owned (allocated) payload of the given data.
pub fn from_owned<M: DataMarker>(data: M::Yokeable) -> Self
where
M::Yokeable: icu_provider::MaybeSendSync,
M::Yokeable: icu_provider::any::MaybeSendSync,
{
Self::from_payload::<M>(DataPayload::from_owned(data))
}
Expand All @@ -82,7 +82,7 @@ impl AnyPayloadProvider {
/// Creates an `AnyPayloadProvider` from an existing [`DataPayload`].
pub fn from_payload<M: DataMarker>(payload: DataPayload<M>) -> Self
where
M::Yokeable: icu_provider::MaybeSendSync,
M::Yokeable: icu_provider::any::MaybeSendSync,
{
AnyPayloadProvider {
marker: M::INFO,
Expand All @@ -102,7 +102,7 @@ impl AnyPayloadProvider {
pub fn new_default<M: DataMarker>() -> Self
where
M::Yokeable: Default,
M::Yokeable: icu_provider::MaybeSendSync,
M::Yokeable: icu_provider::any::MaybeSendSync,
{
Self::from_owned::<M>(M::Yokeable::default())
}
Expand All @@ -123,7 +123,7 @@ where
M: DataMarker,
for<'a> YokeTraitHack<<M::Yokeable as Yokeable<'a>>::Output>: Clone,
M::Yokeable: ZeroFrom<'static, M::Yokeable>,
M::Yokeable: icu_provider::MaybeSendSync,
M::Yokeable: icu_provider::any::MaybeSendSync,
{
fn load(&self, req: DataRequest) -> Result<DataResponse<M>, DataError> {
self.as_downcasting().load(req)
Expand Down
8 changes: 4 additions & 4 deletions provider/adapters/src/fork/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ use predicates::MissingDataMarkerPredicate;
///
/// [`DataMarkerInfo`]: icu_provider::DataMarkerInfo
/// [`DataProvider`]: icu_provider::DataProvider
/// [`AnyProvider`]: icu_provider::AnyProvider
/// [`BufferProvider`]: icu_provider::BufferProvider
/// [`AnyProvider`]: icu_provider::any::AnyProvider
/// [`BufferProvider`]: icu_provider::buf::BufferProvider
/// [`DynamicDataProvider`]: icu_provider::DynamicDataProvider
pub type ForkByMarkerProvider<P0, P1> = ForkByErrorProvider<P0, P1, MissingDataMarkerPredicate>;

Expand Down Expand Up @@ -205,8 +205,8 @@ impl<P0, P1> ForkByMarkerProvider<P0, P1> {
///
/// [`DataMarkerInfo`]: icu_provider::DataMarkerInfo
/// [`DataProvider`]: icu_provider::DataProvider
/// [`AnyProvider`]: icu_provider::AnyProvider
/// [`BufferProvider`]: icu_provider::BufferProvider
/// [`AnyProvider`]: icu_provider::any::AnyProvider
/// [`BufferProvider`]: icu_provider::buf::BufferProvider
/// [`DynamicDataProvider`]: icu_provider::DynamicDataProvider
pub type MultiForkByMarkerProvider<P> = MultiForkByErrorProvider<P, MissingDataMarkerPredicate>;

Expand Down
4 changes: 2 additions & 2 deletions provider/baked/src/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ impl DataExporter for BakedExporter {
#[allow(dead_code)]
pub(crate) const MUST_USE_MAKE_PROVIDER_MACRO: () = ();
}
icu_provider::impl_data_provider_never_marker!($name);
icu_provider::marker::impl_data_provider_never_marker!($name);
};
}
#[doc(inline)]
Expand All @@ -644,7 +644,7 @@ impl DataExporter for BakedExporter {
macro_rules! impl_any_provider {
($provider:ty) => {
#maybe_msrv
impl icu_provider::AnyProvider for $provider {
impl icu_provider::any::AnyProvider for $provider {
fn load_any(&self, marker: icu_provider::DataMarkerInfo, req: icu_provider::DataRequest) -> Result<icu_provider::AnyResponse, icu_provider::DataError> {
match marker.path.hashed() {
#(
Expand Down
4 changes: 2 additions & 2 deletions provider/baked/tests/data/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ macro_rules! __make_provider {
#[allow(dead_code)]
pub(crate) const MUST_USE_MAKE_PROVIDER_MACRO: () = ();
}
icu_provider::impl_data_provider_never_marker!($name);
icu_provider::marker::impl_data_provider_never_marker!($name);
};
}
#[doc(inline)]
Expand All @@ -36,7 +36,7 @@ macro_rules! impl_data_provider {
macro_rules! impl_any_provider {
($ provider : ty) => {
#[clippy::msrv = "1.70"]
impl icu_provider::AnyProvider for $provider {
impl icu_provider::any::AnyProvider for $provider {
fn load_any(&self, marker: icu_provider::DataMarkerInfo, req: icu_provider::DataRequest) -> Result<icu_provider::AnyResponse, icu_provider::DataError> {
match marker.path.hashed() {
h if h == <icu_provider::hello_world::HelloWorldV1Marker as icu_provider::DataMarker>::INFO.path.hashed() => icu_provider::DataProvider::<icu_provider::hello_world::HelloWorldV1Marker>::load(self, req).map(icu_provider::DataResponse::wrap_into_any_response),
Expand Down
4 changes: 3 additions & 1 deletion provider/bikeshed/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,16 @@ pub struct DatagenProvider {

macro_rules! cb {
($($marker:path = $path:literal,)+ #[experimental] $($emarker:path = $epath:literal,)+) => {
icu_provider::make_exportable_provider!(DatagenProvider, [
icu_provider::datagen::make_exportable_provider!(DatagenProvider, [
$($marker,)+
$(#[cfg(feature = "experimental")] $emarker,)+
]);
}
}
icu_registry::registry!(cb);

icu_provider::marker::impl_data_provider_never_marker!(DatagenProvider);

impl DatagenProvider {
/// The latest CLDR JSON tag that has been verified to work with this version of `icu_datagen_bikeshed`.
pub const LATEST_TESTED_CLDR_TAG: &'static str = "45.0.0";
Expand Down
2 changes: 1 addition & 1 deletion provider/blob/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading