Struct icu_provider::prelude::ResourceKey[][src]

pub struct ResourceKey {
    pub category: ResourceCategory,
    pub sub_category: TinyStr16,
    pub version: u16,
}
Expand description

A category, subcategory, and version, used for requesting data from a DataProvider.

The fields in a ResourceKey should generally be known at compile time.

Use resource_key! as a shortcut to create resource keys in code.

Fields

category: ResourceCategorysub_category: TinyStr16version: u16

Implementations

Gets the standard path components of this ResourceKey. These components should be used when persisting the ResourceKey on the filesystem or in structured data.

Examples

use icu_provider::prelude::*;

let resc_key = icu_provider::hello_world::key::HELLO_WORLD_V1;
let components = resc_key.get_components();

assert_eq!(
    ["core", "helloworld@1"],
    components.iter().collect::<Vec<&str>>()[..]
);

Returns Ok if this data key matches the argument, or the appropriate error.

Convenience method for data providers that support a single ResourceKey.

Examples

use icu_provider::prelude::*;

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

assert!(matches!(FOO_BAR.match_key(FOO_BAR), Ok(())));
assert!(matches!(FOO_BAR.match_key(FOO_BAZ), Err(DataError::MissingResourceKey(_))));
assert!(matches!(FOO_BAR.match_key(BAR_BAZ), Err(DataError::MissingResourceKey(_))));

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 returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

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

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Writes bytes to the given sink. Errors from the sink are bubbled up.

Returns a hint for the number of bytes that will be written to the sink. Read more

Creates a new String with the data from this Writeable. Like ToString, but smaller and faster. Read more

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.