Struct icu_provider::hello_world::HelloWorldProvider
source · pub struct HelloWorldProvider;
Expand description
A data provider returning Hello World strings in different languages.
Mostly useful for testing.
§Examples
use icu_locale_core::langid;
use icu_provider::hello_world::*;
use icu_provider::prelude::*;
let german_hello_world: DataResponse<HelloWorldV1Marker> =
HelloWorldProvider
.load(DataRequest {
id: DataIdentifierBorrowed::for_locale(&langid!("de").into()),
..Default::default()
})
.expect("Loading should succeed");
assert_eq!("Hallo Welt", german_hello_world.payload.get().message);
Load the reverse string using an auxiliary key:
use icu_provider::hello_world::*;
use icu_provider::prelude::*;
use icu_locale_core::langid;
let reverse_hello_world: DataResponse<HelloWorldV1Marker> =
HelloWorldProvider
.load(DataRequest {
id: DataIdentifierBorrowed::for_marker_attributes_and_locale(DataMarkerAttributes::from_str_or_panic("reverse"), &langid!("en").into()),
..Default::default()
})
.expect("Loading should succeed");
assert_eq!("Olleh Dlrow", reverse_hello_world.payload.get().message);
Implementations§
source§impl HelloWorldProvider
impl HelloWorldProvider
sourcepub fn into_json_provider(self) -> HelloWorldJsonProvider
pub fn into_json_provider(self) -> HelloWorldJsonProvider
Converts this provider into a BufferProvider
that uses JSON serialization.
Trait Implementations§
source§impl DataProvider<HelloWorldV1Marker> for HelloWorldProvider
impl DataProvider<HelloWorldV1Marker> for HelloWorldProvider
source§fn load(
&self,
req: DataRequest<'_>,
) -> Result<DataResponse<HelloWorldV1Marker>, DataError>
fn load( &self, req: DataRequest<'_>, ) -> Result<DataResponse<HelloWorldV1Marker>, DataError>
Query the provider for data, returning the result. Read more
source§impl Debug for HelloWorldProvider
impl Debug for HelloWorldProvider
source§impl Default for HelloWorldProvider
impl Default for HelloWorldProvider
source§fn default() -> HelloWorldProvider
fn default() -> HelloWorldProvider
Returns the “default value” for a type. Read more
source§impl DryDataProvider<HelloWorldV1Marker> for HelloWorldProvider
impl DryDataProvider<HelloWorldV1Marker> for HelloWorldProvider
source§fn dry_load(
&self,
req: DataRequest<'_>,
) -> Result<DataResponseMetadata, DataError>
fn dry_load( &self, req: DataRequest<'_>, ) -> Result<DataResponseMetadata, DataError>
source§impl DynamicDataProvider<AnyMarker> for HelloWorldProvider
impl DynamicDataProvider<AnyMarker> for HelloWorldProvider
source§fn load_data(
&self,
marker: DataMarkerInfo,
req: DataRequest<'_>,
) -> Result<DataResponse<AnyMarker>, DataError>
fn load_data( &self, marker: DataMarkerInfo, req: DataRequest<'_>, ) -> Result<DataResponse<AnyMarker>, DataError>
Query the provider for data, returning the result. Read more
source§impl DynamicDataProvider<ExportMarker> for HelloWorldProvider
impl DynamicDataProvider<ExportMarker> for HelloWorldProvider
source§fn load_data(
&self,
marker: DataMarkerInfo,
req: DataRequest<'_>,
) -> Result<DataResponse<ExportMarker>, DataError>
fn load_data( &self, marker: DataMarkerInfo, req: DataRequest<'_>, ) -> Result<DataResponse<ExportMarker>, DataError>
Query the provider for data, returning the result. Read more
source§impl ExportableProvider for HelloWorldProvider
impl ExportableProvider for HelloWorldProvider
source§fn supported_markers(&self) -> HashSet<DataMarkerInfo>
fn supported_markers(&self) -> HashSet<DataMarkerInfo>
Returns the set of supported markers
source§impl IterableDataProvider<HelloWorldV1Marker> for HelloWorldProvider
impl IterableDataProvider<HelloWorldV1Marker> for HelloWorldProvider
source§fn iter_ids(&self) -> Result<BTreeSet<DataIdentifierCow<'_>>, DataError>
fn iter_ids(&self) -> Result<BTreeSet<DataIdentifierCow<'_>>, DataError>
Returns a set of
DataIdentifierCow
.source§impl IterableDynamicDataProvider<ExportMarker> for HelloWorldProvider
impl IterableDynamicDataProvider<ExportMarker> for HelloWorldProvider
source§fn iter_ids_for_marker(
&self,
marker: DataMarkerInfo,
) -> Result<BTreeSet<DataIdentifierCow<'_>>, DataError>
fn iter_ids_for_marker( &self, marker: DataMarkerInfo, ) -> Result<BTreeSet<DataIdentifierCow<'_>>, DataError>
Given a
DataMarkerInfo
, returns a set of DataIdentifierCow
.source§impl PartialEq for HelloWorldProvider
impl PartialEq for HelloWorldProvider
impl StructuralPartialEq for HelloWorldProvider
Auto Trait Implementations§
impl Freeze for HelloWorldProvider
impl RefUnwindSafe for HelloWorldProvider
impl Send for HelloWorldProvider
impl Sync for HelloWorldProvider
impl Unpin for HelloWorldProvider
impl UnwindSafe for HelloWorldProvider
Blanket Implementations§
source§impl<P> AsDynamicDataProviderAnyMarkerWrap for P
impl<P> AsDynamicDataProviderAnyMarkerWrap for P
source§fn as_any_provider(&self) -> DynamicDataProviderAnyMarkerWrap<'_, P>
fn as_any_provider(&self) -> DynamicDataProviderAnyMarkerWrap<'_, P>
Returns an object implementing
AnyProvider
when called on DynamicDataProvider<AnyMarker>
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more