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: ResourceCategory
sub_category: TinyStr16
version: 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
Performs the conversion.
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
Auto Trait Implementations
impl RefUnwindSafe for ResourceKey
impl Send for ResourceKey
impl Sync for ResourceKey
impl Unpin for ResourceKey
impl UnwindSafe for ResourceKey
Blanket Implementations
Mutably borrows from an owned value. Read more