#[non_exhaustive]pub struct Term {
pub value: String,
pub label: Option<String>,
pub description: Option<String>,
pub retired: bool,
pub tint: Option<Tint>,
}Expand description
One term of a controlled vocabulary.
#[non_exhaustive]: a term gains display and lifecycle facets over time, so
it is built from Term::value and the chainable setters rather than a
struct literal. Reading the fields is unchanged.
use fig_schema::Term;
let t = Term::value("archived").label("Archived").retired(true);
assert_eq!(t.display_label(), "Archived");
assert!(t.retired);Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.value: StringThe stored value.
label: Option<String>A human display label (defaults to value — see Term::display_label).
description: Option<String>A human gloss / help text.
retired: boolKnown but no longer offered: still valid where already present, excluded
from the picker’s offered set. Validating one yields Validation::Warn
rather than Validation::Reject, even under a closed vocabulary — see
validate_enum.
tint: Option<Tint>A per-value tint (e.g. public = positive/green).
Implementations§
Source§impl Term
impl Term
Sourcepub fn label_opt(self, label: Option<impl Into<String>>) -> Self
pub fn label_opt(self, label: Option<impl Into<String>>) -> Self
Set the display label from an optional one. None leaves it unset.
Sourcepub fn description(self, description: impl Into<String>) -> Self
pub fn description(self, description: impl Into<String>) -> Self
Set the human gloss.
Sourcepub fn description_opt(self, description: Option<impl Into<String>>) -> Self
pub fn description_opt(self, description: Option<impl Into<String>>) -> Self
Set the human gloss from an optional one. None leaves it unset.
Sourcepub fn retired(self, retired: bool) -> Self
pub fn retired(self, retired: bool) -> Self
Mark the term retired — known, but no longer offered.
Sourcepub fn tint(self, tint: impl Into<Option<Tint>>) -> Self
pub fn tint(self, tint: impl Into<Option<Tint>>) -> Self
Set the per-value tint. Takes a Tint or an Option<Tint>.
Sourcepub fn display_label(&self) -> &str
pub fn display_label(&self) -> &str
The text to display for this term: Term::label if set, otherwise the
stored Term::value.