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)> + '_>
Configured alias projections in raw-key order, before text validation.
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::formatting::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 Labelswhere
*const ArcInner<BTreeMap<String, String>> is !null: Freeze,
PhantomData<ArcInner<BTreeMap<String, String>>>: Freeze,
*const ArcInner<HashMap<RawKey, BTreeMap<String, String>>> is !null: Freeze,
PhantomData<ArcInner<HashMap<RawKey, BTreeMap<String, String>>>>: Freeze,
*const ArcInner<BTreeMap<String, CapturedLabel>> is !null: Freeze,
PhantomData<ArcInner<BTreeMap<String, CapturedLabel>>>: Freeze,
*const ArcInner<BTreeMap<(usize, usize), String>> is !null: Freeze,
PhantomData<ArcInner<BTreeMap<(usize, usize), String>>>: Freeze,
*const ArcInner<[String]> is !null: Freeze,
PhantomData<ArcInner<[String]>>: Freeze,
*const ArcInner<GridRowLabels> is !null: Freeze,
PhantomData<ArcInner<GridRowLabels>>: Freeze,
impl Move for Labels
impl RefUnwindSafe for Labels
impl Send for Labels
impl Sync for Labels
impl Unpin for Labels
impl UnsafeUnpin for Labelswhere
*const ArcInner<BTreeMap<String, String>> is !null: UnsafeUnpin,
PhantomData<ArcInner<BTreeMap<String, String>>>: UnsafeUnpin,
*const ArcInner<HashMap<RawKey, BTreeMap<String, String>>> is !null: UnsafeUnpin,
PhantomData<ArcInner<HashMap<RawKey, BTreeMap<String, String>>>>: UnsafeUnpin,
*const ArcInner<BTreeMap<String, CapturedLabel>> is !null: UnsafeUnpin,
PhantomData<ArcInner<BTreeMap<String, CapturedLabel>>>: UnsafeUnpin,
*const ArcInner<BTreeMap<(usize, usize), String>> is !null: UnsafeUnpin,
PhantomData<ArcInner<BTreeMap<(usize, usize), String>>>: UnsafeUnpin,
*const ArcInner<[String]> is !null: UnsafeUnpin,
PhantomData<ArcInner<[String]>>: UnsafeUnpin,
*const ArcInner<GridRowLabels> is !null: UnsafeUnpin,
PhantomData<ArcInner<GridRowLabels>>: UnsafeUnpin,
impl UnwindSafe for Labelswhere
Arc<BTreeMap<String, String>>: UnwindSafe,
Arc<HashMap<RawKey, BTreeMap<String, String>>>: UnwindSafe,
Arc<BTreeMap<String, CapturedLabel>>: UnwindSafe,
Arc<BTreeMap<(usize, usize), String>>: UnwindSafe,
Arc<[String]>: UnwindSafe,
Arc<GridRowLabels>: UnwindSafe,
Blanket Implementations§
impl<T> Allocation for T
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,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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.