Skip to main content

FixedProvider

Struct FixedProvider 

Source
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>

Source

pub fn from_owned(data: M::DataStruct) -> Self

Creates a FixedProvider with an owned (allocated) payload of the given data.

Source

pub fn from_static(data: &'static M::DataStruct) -> Self

Creates a FixedProvider with a statically borrowed payload of the given data.

Source

pub fn from_payload(data: DataPayload<M>) -> Self

Creates a FixedProvider from an existing DataPayload.

Source

pub fn new_default() -> Self
where 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>
where M: DataMarker, for<'a> <M::DataStruct as Yokeable<'a>>::Output: Clone,

Source§

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,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,