#[non_exhaustive]pub enum Tint {
Accent,
Neutral,
Positive,
Warning,
Danger,
}Expand description
A semantic tint hint. Frontends map to theme-adaptive colours.
#[non_exhaustive]: a palette grows the same way an icon set does, so a
match needs a _ arm.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Implementations§
Source§impl Tint
impl Tint
Sourcepub const ALL: &'static [Tint]
pub const ALL: &'static [Tint]
Every tint, so a frontend can assert its colour mapping is total —
for t in Tint::ALL { assert!(my_colour(*t).is_some()) } — instead of
keeping a second copy of this list that silently falls behind.
Icon deliberately has no equivalent, and the asymmetry is the point
rather than an oversight. Every other #[non_exhaustive] enum here is
safe against a new variant because this crate never produces one: it
defines the vocabulary, and every value in a workspace is constructed by
the embedder, so a new variant can only reach a match through a
deliberate, reviewed change to the producer. Tint is the one where
that gate is not the producer’s: parse_vocabulary
reads a per-term tint:, and load_schema a
rule’s, so a Tint arrives from user data and the gate is “someone
edited a file”. This list existed before the parser learned the key,
so that the release which taught it would turn consumer tests red
instead of shipping a term that silently rendered untinted; a frontend
that asserts over it stays covered when a sixth tint is added here.
(Icon has an escape hatch instead: an unknown name is
Icon::Other, which a frontend already has to draw.)
Sourcepub fn from_name(name: &str) -> Option<Tint>
pub fn from_name(name: &str) -> Option<Tint>
The tint a schema document’s tint key — on a rule, or on a term —
names, or None for a spelling the crate cannot map. The loader drops
that None and lint notes it: a tint no frontend can name is one no
frontend can draw, and a presenter fails open.
use fig_schema::Tint;
assert_eq!(Tint::from_name("positive"), Some(Tint::Positive));
assert_eq!(Tint::from_name("green"), None);Sourcepub fn name(self) -> &'static str
pub fn name(self) -> &'static str
The name Tint::from_name reads this tint back from.