Trait icu_provider::iter::KeyedDataProvider [−][src]
pub trait KeyedDataProvider { fn supports_key(resc_key: &ResourceKey) -> Result<(), Error>; fn or_else_supports_key(
err: Error,
resc_key: &ResourceKey
) -> Result<(), Error> { ... } }
A DataProvider
whose supported keys are known statically at compile time.
Implementing this trait means that a DataProvider
is built to support a specific set of
keys; for example, by transforming those keys from an external data source.
TODO: When const_trait_impl is stable, most implementations of this trait should be const.
Required methods
fn supports_key(resc_key: &ResourceKey) -> Result<(), Error>
[src]
Given a ResourceKey
, checks whether this type of DataProvider
supports it.
Returns Ok if the key is supported, or an Error with more information if not. The Error
should be either UnsupportedCategory
or UnsupportedResourceKey
.
Provided methods
fn or_else_supports_key(err: Error, resc_key: &ResourceKey) -> Result<(), Error>
[src]
Auto-implemented function that enables chaining of KeyedDataProviders
while preserving
UnsupportedResourceKey
.
Examples
ⓘ
DataProviderA::supports_key(resc_key) .or_else(|err| DataProviderB::or_else_supports_key(err, resc_key)) .or_else(|err| DataProviderC::or_else_supports_key(err, resc_key))