1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//! Presentation style requested by text/emoji variation selectors.
use crate::unicode;
/// A presentation style requested by a variation selector.
///
/// Text presentation is requested by `U+FE0E` (VS15); emoji presentation by
/// `U+FE0F` (VS16).
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Presentation {
/// Text presentation, requested by `U+FE0E`.
Text,
/// Emoji presentation, requested by `U+FE0F`.
Emoji,
}
impl Presentation {
/// Return the variation selector character that requests this
/// presentation.
#[must_use]
pub(crate) fn as_selector(self) -> char {
match self {
Self::Text => unicode::TEXT_PRESENTATION_SELECTOR,
Self::Emoji => unicode::EMOJI_PRESENTATION_SELECTOR,
}
}
/// Parse a variation selector character into the presentation it requests.
///
/// Returns `None` if the character is not `U+FE0E` or `U+FE0F`.
#[must_use]
pub const fn from_selector(ch: char) -> Option<Self> {
match ch {
unicode::TEXT_PRESENTATION_SELECTOR => Some(Self::Text),
unicode::EMOJI_PRESENTATION_SELECTOR => Some(Self::Emoji),
_ => None,
}
}
}