pub struct FixedProvider<M: DataMarker> {
data: DataPayload<M>,
}Expand description
A data provider that returns clones of a fixed type-erased payload.
§Examples
use icu_provider::hello_world::*;
use icu_provider::prelude::*;
use icu_provider_adapters::fixed::FixedProvider;
use std::borrow::Cow;
use writeable::assert_writeable_eq;
let provider = FixedProvider::<HelloWorldV1>::from_static(&HelloWorld {
message: Cow::Borrowed("custom hello world"),
});
// Check that it works:
let formatter =
HelloWorldFormatter::try_new_unstable(&provider, Default::default())
.expect("marker matches");
assert_writeable_eq!(formatter.format(), "custom hello world");Fields§
§data: DataPayload<M>Implementations§
Source§impl<M: DataMarker> FixedProvider<M>
impl<M: DataMarker> FixedProvider<M>
Sourcepub fn from_owned(data: M::DataStruct) -> Self
pub fn from_owned(data: M::DataStruct) -> Self
Creates a FixedProvider with an owned (allocated) payload of the given data.
Sourcepub fn from_static(data: &'static M::DataStruct) -> Self
pub fn from_static(data: &'static M::DataStruct) -> Self
Creates a FixedProvider with a statically borrowed payload of the given data.
Sourcepub fn from_payload(data: DataPayload<M>) -> Self
pub fn from_payload(data: DataPayload<M>) -> Self
Creates a FixedProvider from an existing DataPayload.
Sourcepub fn new_default() -> Selfwhere
M::DataStruct: Default,
pub fn new_default() -> Selfwhere
M::DataStruct: Default,
Creates a FixedProvider with the default (allocated) version of the data struct.
Trait Implementations§
Source§impl<M> DataProvider<M> for FixedProvider<M>
impl<M> DataProvider<M> for FixedProvider<M>
Source§fn load(&self, _: DataRequest<'_>) -> Result<DataResponse<M>, DataError>
fn load(&self, _: DataRequest<'_>) -> Result<DataResponse<M>, DataError>
Query the provider for data, returning the result. Read more
Source§impl<M> Debug for FixedProvider<M>where
M: DynamicDataMarker + DataMarker,
for<'a> &'a <M::DataStruct as Yokeable<'a>>::Output: Debug,
impl<M> Debug for FixedProvider<M>where
M: DynamicDataMarker + DataMarker,
for<'a> &'a <M::DataStruct as Yokeable<'a>>::Output: Debug,
Auto Trait Implementations§
impl<M> Freeze for FixedProvider<M>
impl<M> RefUnwindSafe for FixedProvider<M>
impl<M> !Send for FixedProvider<M>
impl<M> !Sync for FixedProvider<M>
impl<M> Unpin for FixedProvider<M>
impl<M> UnsafeUnpin for FixedProvider<M>
impl<M> UnwindSafe for FixedProvider<M>
Blanket Implementations§
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