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

pub struct DataRequest {
    pub resource_path: ResourcePath,
}
Expand description

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

Fields

resource_path: ResourcePath

Implementations

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

Create a DataRequest to a particular ResourceKey with default options.

Performs the conversion.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Clone this trait object reference, returning a boxed trait object.

Return this boxed trait object as Box<dyn Any>. Read more

Return this trait object reference as &dyn Any. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.