Struct icu_provider::prelude::DataRequest[][src]

pub struct DataRequest {
    pub resource_path: ResourcePath,
}

A struct to request a certain piece of data from a data provider.

Fields

resource_path: ResourcePath

Implementations

impl DataRequest[src]

pub fn try_langid(&self) -> Result<&LanguageIdentifier, Error>[src]

Returns the LanguageIdentifier for this DataRequest, or an error if it is not present.

Examples

use icu_provider::prelude::*;

const FOO_BAR: ResourceKey = icu_provider::resource_key!(x, "foo", "bar", 1);

let req_no_langid = DataRequest {
    resource_path: ResourcePath {
        key: FOO_BAR,
        options: ResourceOptions::default(),
    }
};

let req_with_langid = DataRequest {
    resource_path: ResourcePath {
        key: FOO_BAR,
        options: ResourceOptions {
            variant: None,
            langid: Some(icu_locid_macros::langid!("ar-EG")),
        },
    }
};

assert!(matches!(req_no_langid.try_langid(), Err(DataError::NeedsLanguageIdentifier(_))));
assert!(matches!(req_with_langid.try_langid(), Ok(_)));

Trait Implementations

impl Clone for DataRequest[src]

impl Debug for DataRequest[src]

impl Display for DataRequest[src]

impl From<DataRequest> for Error[src]

impl From<ResourceKey> for DataRequest[src]

Create a DataRequest to a particular ResourceKey with default options.

impl PartialEq<DataRequest> for DataRequest[src]

impl StructuralPartialEq for DataRequest[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> ErasedDataStruct for T where
    T: Clone + Debug + Any
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.