-
Notifications
You must be signed in to change notification settings - Fork 174
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
Making IterableResourceProvider
return Locale
s instead of ResourceOptions
#2175
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,37 +5,32 @@ | |
//! Collection of iteration APIs for data providers. | ||
|
||
use crate::prelude::*; | ||
use icu_locid::Locale; | ||
|
||
/// A [`DynProvider`] that can iterate over all supported [`ResourceOptions`] for a certain key. | ||
/// A [`DynProvider`] that can iterate over all supported [`Locale`]s for a certain key. | ||
/// | ||
/// Implementing this trait means that a data provider knows all of the data it can successfully | ||
/// return from a load request. | ||
pub trait IterableDynProvider<M: DataMarker>: DynProvider<M> { | ||
/// Given a [`ResourceKey`], returns a list of [`ResourceOptions`]. | ||
fn supported_options_for_key( | ||
&self, | ||
key: ResourceKey, | ||
) -> Result<Vec<ResourceOptions>, DataError>; | ||
/// Given a [`ResourceKey`], returns a list of [`Locale`]s. | ||
fn supported_locales_for_key(&self, key: ResourceKey) -> Result<Vec<Locale>, DataError>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue: We may want to use the name The other issue here is that I think we may want to retire this mechanism in the data exporter entirely, and instead use a declarative list of locales combined with locale fallback. At least when reading CLDR data, we only need to load the list of CLDR locales one time, and then use the same list for all of the data keys. See #834 for further discussion. |
||
} | ||
|
||
/// A [`ResourceProvider`] that can iterate over all supported [`ResourceOptions`] for a certain key. | ||
/// A [`ResourceProvider`] that can iterate over all supported [`Locale`]s for a certain key. | ||
/// | ||
/// Implementing this trait means that a data provider knows all of the data it can successfully | ||
/// return from a load request. | ||
pub trait IterableResourceProvider<M: ResourceMarker>: ResourceProvider<M> { | ||
/// Returns a list of [`ResourceOptions`]. | ||
fn supported_options(&self) -> Result<Vec<ResourceOptions>, DataError>; | ||
/// Returns a list of [`Locale`]s. | ||
fn supported_locales(&self) -> Result<Vec<Locale>, DataError>; | ||
} | ||
|
||
impl<M, P> IterableDynProvider<M> for Box<P> | ||
where | ||
M: DataMarker, | ||
P: IterableDynProvider<M> + ?Sized, | ||
{ | ||
fn supported_options_for_key( | ||
&self, | ||
key: ResourceKey, | ||
) -> Result<Vec<ResourceOptions>, DataError> { | ||
(**self).supported_options_for_key(key) | ||
fn supported_locales_for_key(&self, key: ResourceKey) -> Result<Vec<Locale>, DataError> { | ||
(**self).supported_locales_for_key(key) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue: I am not aligned on the motivation for this change (trying to remove ResourceOptions from public APIs).