pub struct Labels { /* private fields */ }Expand description
Immutable presentation rules for labels inferred from data identities.
Explicit chart text such as axis-label overrides, titles, and captions is always rendered verbatim. Aliases take precedence over the selected humanized or raw fallback.
Implementations§
Source§impl Labels
impl Labels
Sourcepub const fn humanized() -> Self
pub const fn humanized() -> Self
Humanize automatically sourced column names and categorical values.
Sourcepub const fn raw() -> Self
pub const fn raw() -> Self
Render automatically sourced labels exactly as represented by the plot data.
Sourcepub const fn is_humanized(&self) -> bool
pub const fn is_humanized(&self) -> bool
Whether automatically sourced labels use the humanized fallback.
Sourcepub fn get_aliases(
&self,
) -> Option<impl ExactSizeIterator<Item = (&str, &str)> + '_>
pub fn get_aliases( &self, ) -> Option<impl ExactSizeIterator<Item = (&str, &str)> + '_>
Authored aliases in raw-key order, without resolving or validating text.
None preserves the absence of an aliases collection. Reading this view
neither normalizes display text nor checks a complete label domain.
Sourcepub fn alias(self, raw: impl Into<String>, display: impl Into<String>) -> Self
pub fn alias(self, raw: impl Into<String>, display: impl Into<String>) -> Self
Add one exact raw-identity to display-label mapping.
Sourcepub fn aliases<I, R, D>(self, aliases: I) -> Self
pub fn aliases<I, R, D>(self, aliases: I) -> Self
Add exact raw-identity to display-label mappings.
Sourcepub fn resolve(&self, raw: &str) -> Result<String, Error>
pub fn resolve(&self, raw: &str) -> Result<String, Error>
Resolve one raw name with alias precedence and the selected fallback.
The result uses the shared display-text syntax, preserving explicit alias whitespace and mandatory breaks. Collisions between different identities are checked when the renderer resolves their complete semantic domain.
use lichtung_plot::Labels;
let labels = Labels::humanized().alias("mean_score", " Score\r\n(points) ");
assert_eq!(labels.resolve("mean_score")?, " Score\r\n(points) ");
assert_eq!(labels.resolve("control_group")?, "Control group");
assert_eq!(Labels::raw().resolve("control_group")?, "control_group");
assert!(labels.alias("bad", "a\tb").resolve("bad").is_err());Trait Implementations§
impl Eq for Labels
impl StructuralPartialEq for Labels
Auto Trait Implementations§
impl Forget for Labels
impl Freeze for Labels
impl Move for Labels
impl RefUnwindSafe for Labels
impl Send for Labels
impl Sync for Labels
impl Unpin for Labels
impl UnsafeUnpin for Labels
impl UnwindSafe for Labels
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> Scalar for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.