icu_locale_core/preferences/extensions/unicode/keywords/
emoji.rs1use crate::preferences::extensions::unicode::enum_keyword;
6
7#[non_exhaustive]
#[doc = r" A Unicode Emoji Presentation Style Identifier"]
#[doc = r""]
#[doc = r" It specifies a request for the preferred emoji"]
#[doc =
r" presentation style. This can be used as part of the value for an HTML lang attribute,"]
#[doc = r#" for example `<html lang="sr-Latn-u-em-emoji">`."#]
#[doc =
r" The valid values are listed in [LDML](https://unicode.org/reports/tr35/#UnicodeEmojiPresentationStyleIdentifier)."]
pub enum EmojiPresentationStyle {
#[doc = r" Use an emoji presentation for emoji characters if possible"]
Emoji,
#[doc = r" Use a text presentation for emoji characters if possible"]
Text,
#[doc =
r" Use the default presentation for emoji characters as specified in UTR #51 Presentation Style"]
#[default]
Default,
}
#[automatically_derived]
impl ::core::default::Default for EmojiPresentationStyle {
#[inline]
fn default() -> EmojiPresentationStyle { Self::Default }
}
#[automatically_derived]
impl ::core::fmt::Debug for EmojiPresentationStyle {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
EmojiPresentationStyle::Emoji => "Emoji",
EmojiPresentationStyle::Text => "Text",
EmojiPresentationStyle::Default => "Default",
})
}
}
#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for EmojiPresentationStyle { }
#[automatically_derived]
impl ::core::clone::Clone for EmojiPresentationStyle {
#[inline]
fn clone(&self) -> EmojiPresentationStyle { *self }
}
#[automatically_derived]
impl ::core::cmp::Eq for EmojiPresentationStyle {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_receiver_is_total_eq(&self) -> () {}
}
#[automatically_derived]
impl ::core::marker::StructuralPartialEq for EmojiPresentationStyle { }
#[automatically_derived]
impl ::core::cmp::PartialEq for EmojiPresentationStyle {
#[inline]
fn eq(&self, other: &EmojiPresentationStyle) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}
#[automatically_derived]
impl ::core::marker::Copy for EmojiPresentationStyle { }
#[automatically_derived]
impl ::core::hash::Hash for EmojiPresentationStyle {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state)
}
}
impl crate::preferences::PreferenceKey for EmojiPresentationStyle {
fn unicode_extension_key() -> Option<crate::extensions::unicode::Key> {
Some(const {
use crate::extensions::unicode::Key;
match Key::try_from_utf8("em".as_bytes()) {
Ok(r) => r,
_ => {
::core::panicking::panic_fmt(format_args!("Invalid extensions::unicode::Key: em"));
}
}
})
}
fn try_from_key_value(key: &crate::extensions::unicode::Key,
value: &crate::extensions::unicode::Value)
->
Result<Option<Self>,
crate::preferences::extensions::unicode::errors::PreferencesParseError> {
if Self::unicode_extension_key() == Some(*key) {
Self::try_from(value).map(Some)
} else { Ok(None) }
}
fn unicode_extension_value(&self)
-> Option<crate::extensions::unicode::Value> {
Some((*self).into())
}
}
impl TryFrom<&crate::extensions::unicode::Value> for EmojiPresentationStyle {
type Error =
crate::preferences::extensions::unicode::errors::PreferencesParseError;
fn try_from(s: &crate::extensions::unicode::Value)
-> Result<Self, Self::Error> {
let subtag =
s.get_subtag(0).unwrap_or(&const {
use crate::subtags::Subtag;
match Subtag::try_from_utf8("true".as_bytes()) {
Ok(r) => r,
_ => {
::core::panicking::panic_fmt(format_args!("Invalid subtags::Subtag: true"));
}
}
});
#[allow(unused_imports)]
use crate::extensions::unicode::value;
Ok(match subtag.as_str() {
"emoji" => { EmojiPresentationStyle::Emoji }
"text" => { EmojiPresentationStyle::Text }
"default" => { EmojiPresentationStyle::Default }
_ => { return Err(Self::Error::InvalidKeywordValue); }
})
}
}
impl From<EmojiPresentationStyle> for crate::extensions::unicode::Value {
fn from(input: EmojiPresentationStyle)
-> crate::extensions::unicode::Value {
let f;
#[allow(unused_mut)]
let mut s = None;
match input
{
#[allow(non_snake_case)]
EmojiPresentationStyle::Emoji => {
f =
const {
use crate::subtags::Subtag;
match Subtag::try_from_utf8("emoji".as_bytes()) {
Ok(r) => r,
_ => {
::core::panicking::panic_fmt(format_args!("Invalid subtags::Subtag: emoji"));
}
}
};
}
#[allow(non_snake_case)]
EmojiPresentationStyle::Text => {
f =
const {
use crate::subtags::Subtag;
match Subtag::try_from_utf8("text".as_bytes()) {
Ok(r) => r,
_ => {
::core::panicking::panic_fmt(format_args!("Invalid subtags::Subtag: text"));
}
}
};
}
#[allow(non_snake_case)]
EmojiPresentationStyle::Default => {
f =
const {
use crate::subtags::Subtag;
match Subtag::try_from_utf8("default".as_bytes()) {
Ok(r) => r,
_ => {
::core::panicking::panic_fmt(format_args!("Invalid subtags::Subtag: default"));
}
}
};
}
}
if let Some(s) = s {
crate::extensions::unicode::Value::from_two_subtags(f, s)
} else { crate::extensions::unicode::Value::from_subtag(Some(f)) }
}
}
impl EmojiPresentationStyle {
pub const fn as_str(&self) -> &'static str {
match self
{
#[allow(non_snake_case)]
Self::Emoji => {
return "emoji";
}
#[allow(non_snake_case)]
Self::Text => {
return "text";
}
#[allow(non_snake_case)]
Self::Default => {
return "default";
}
}
}
}enum_keyword!(
8 [Default]
15 EmojiPresentationStyle {
16 ("emoji" => Emoji),
18 ("text" => Text),
20 [default]
22 ("default" => Default)
23}, "em");