Struct icu_provider::struct_provider::StructProvider [−][src]
pub struct StructProvider<'data, M> where
M: DataMarker<'data>, { pub key: ResourceKey, pub data: DataPayload<'data, M>, }
Expand description
A data provider that returns clones of a constant data payload.
Examples
use icu_provider::prelude::*; use icu_provider::hello_world::*; use icu_provider::struct_provider::StructProvider; use std::borrow::Cow; let local_data = HelloWorldV1 { message: Cow::Owned("hello world".to_string()), }; // A placeholder key to use to serve the data struct const SAMPLE_KEY: ResourceKey = icu_provider::resource_key!(x, "xyz", "example", 1); let provider = StructProvider { key: SAMPLE_KEY, data: DataPayload::from_owned(local_data), }; let payload: DataPayload<HelloWorldV1Marker> = provider.load_payload(&DataRequest::from(SAMPLE_KEY)) .expect("Load should succeed") .take_payload() .expect("Data should be present"); assert_eq!(payload.get().message, "hello world");
Fields
key: ResourceKey
data: DataPayload<'data, M>
Trait Implementations
impl<'data, M> DataProvider<'data, M> for StructProvider<'data, M> where
M: DataMarker<'data>,
for<'a> YokeTraitHack<<M::Yokeable as Yokeable<'a>>::Output>: Clone,
impl<'data, M> DataProvider<'data, M> for StructProvider<'data, M> where
M: DataMarker<'data>,
for<'a> YokeTraitHack<<M::Yokeable as Yokeable<'a>>::Output>: Clone,
Query the provider for data, returning the result. Read more
Auto Trait Implementations
impl<'data, M> !RefUnwindSafe for StructProvider<'data, M>
impl<'data, M> !Send for StructProvider<'data, M>
impl<'data, M> !Sync for StructProvider<'data, M>
impl<'data, M> Unpin for StructProvider<'data, M> where
<M as DataMarker<'data>>::Yokeable: Unpin,
impl<'data, M> UnwindSafe for StructProvider<'data, M> where
<M as DataMarker<'data>>::Cart: RefUnwindSafe,
<M as DataMarker<'data>>::Yokeable: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
Clone this trait object reference, returning a boxed trait object.