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: ResourceCategory
sub_category: TinyStr16
version: u16
Implementations
impl ResourceKey
[src]
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 Clone for ResourceKey
[src]fn clone(&self) -> ResourceKey
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for ResourceKey
[src]
impl Copy for ResourceKey
[src]impl Eq for ResourceKey
[src]
impl Eq for ResourceKey
[src]impl From<&'_ ResourceKey> for Error
[src]
impl From<&'_ ResourceKey> for Error
[src]fn from(resc_key: &ResourceKey) -> Self
[src]
impl From<ResourceKey> for DataRequest
[src]
impl From<ResourceKey> for DataRequest
[src]Create a DataRequest
to a particular ResourceKey
with default options.
fn from(key: ResourceKey) -> Self
[src]
impl Ord for ResourceKey
[src]
impl Ord for ResourceKey
[src]impl PartialEq<ResourceKey> for ResourceKey
[src]
impl PartialEq<ResourceKey> for ResourceKey
[src]fn eq(&self, other: &ResourceKey) -> bool
[src]
fn ne(&self, other: &ResourceKey) -> bool
[src]
impl PartialOrd<ResourceKey> for ResourceKey
[src]
impl PartialOrd<ResourceKey> for ResourceKey
[src]impl StructuralEq for ResourceKey
[src]
impl StructuralEq for ResourceKey
[src]impl StructuralPartialEq for ResourceKey
[src]
impl StructuralPartialEq for ResourceKey
[src]impl Writeable for ResourceKey
[src]
impl Writeable for ResourceKey
[src]Auto Trait Implementations
impl RefUnwindSafe for ResourceKey
impl RefUnwindSafe for ResourceKey
impl Send for ResourceKey
impl Send for ResourceKey
impl Sync for ResourceKey
impl Sync for ResourceKey
impl Unpin for ResourceKey
impl Unpin for ResourceKey
impl UnwindSafe for ResourceKey
impl UnwindSafe for ResourceKey