Trait PreferenceKey
trait PreferenceKey: Sized
A low-level trait implemented on each preference exposed in component preferences.
PreferenceKey has to be implemented on
preferences that are to be included in Formatter preferences.
The trait may be implemented to indicate that the given preference has
a unicode key corresponding to it or be a custom one.
ICU4X provides an implementation of PreferenceKey for all
Unicode Extension Keys. The only external use of this trait is to implement
it on custom preferences that are to be included in a component preferences bag.
The below example show cases a manual generation of an em (emoji) unicode extension key
and a custom struct to showcase the difference in their behavior. For all use purposes,
the EmojiPresentationStyle preference exposed by this crate should be used.
Examples
use ;
define_preferences!;
Provided Methods
fn try_from_key_value(_key: &Key, _value: &Value) -> Result<Option<Self>, PreferencesParseError>Optional constructor of the given preference. It takes the unicode extension key and if the key matches it attemptes to construct the preference based on the given value. If the value is not a valid value for the given key, the constructor throws.
fn unicode_extension_key() -> Option<Key>Retrieve unicode extension key corresponding to a given preference.
fn unicode_extension_value(self: &Self) -> Option<Value>Retrieve unicode extension value corresponding to the given instance of the preference.
Implementors
impl PreferenceKey for NumberingSystemimpl PreferenceKey for RegionOverrideimpl PreferenceKey for RegionalSubdivisionimpl PreferenceKey for CurrencyTypeimpl PreferenceKey for TimeZoneShortId