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

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

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

impl ResourceKey[src]

pub fn get_components(&self) -> ResourceKeyComponents[src]

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_plurals::provider::key::CARDINAL_V1;
let components = resc_key.get_components();

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

pub fn match_key(&self, key: Self) -> Result<(), Error>[src]

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::UnsupportedResourceKey(_))));
assert!(matches!(FOO_BAR.match_key(BAR_BAZ), Err(DataError::UnsupportedCategory(_))));

Trait Implementations

impl Clone for ResourceKey[src]

impl Copy for ResourceKey[src]

impl Debug for ResourceKey[src]

impl Display for ResourceKey[src]

impl Eq for ResourceKey[src]

impl From<&'_ ResourceKey> for Error[src]

impl From<ResourceKey> for DataRequest[src]

Create a DataRequest to a particular ResourceKey with default options.

impl Ord for ResourceKey[src]

impl PartialEq<ResourceKey> for ResourceKey[src]

impl PartialOrd<ResourceKey> for ResourceKey[src]

impl StructuralEq for ResourceKey[src]

impl StructuralPartialEq for ResourceKey[src]

impl Writeable for ResourceKey[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.