#[non_exhaustive]pub struct FacetValue<'a> {
pub value: &'a str,
pub label: &'a str,
pub count: Option<u64>,
pub standing: Standing,
pub depth: u8,
pub branching: bool,
}Expand description
One value a Facet offers, as it currently stands.
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: &'a strWhat identifies it, and what a host keys its route on.
Choice::value’s split, and a tree is why it is not optional: two
leaves under different parents are legitimately both called “Ambient”,
and the path is the only thing telling them apart. It is also what
nearest-ancestor-wins resolves over, so an app that carried only labels
could not compute the standing it hands back here.
label: &'a strWhat it is called, as the user reads it.
The leaf’s own name rather than its path: a facet drawn as an indented tree repeats every ancestor on every line otherwise, and one drawn as a breadcrumb has the ancestors already.
count: Option<u64>How many members of the set carry it.
Optional, and settled that way rather than made mandatory: a count is a
measured fact the app may not have. Counting a tag subtree under an
active text search is a second query, and an app that will not pay for it
should be able to describe the facet anyway rather than write a zero that
reads as “none of them”. That is Awaiting::amount’s rule in a second
place — state a number when it was measured, and nothing when it was not.
standing: StandingWhether it is narrowing the set, and how it came to be.
depth: u8How far down the tree it sits, counting from zero at the root.
Always zero for a flat facet, which is what makes an indenting renderer one code path rather than two. A renderer that draws no tree at all still reads this, since a value’s depth is what distinguishes two same-named leaves under different parents.
branching: boolWhether taking it reveals values under it.
Distinct from having a nonzero depth: a leaf deep in the
tree branches no further, and a root with children does. Both facts are
needed and neither implies the other, which is why the pair is two
members rather than one count.
Implementations§
Source§impl<'a> FacetValue<'a>
impl<'a> FacetValue<'a>
Sourcepub const fn new(value: &'a str, label: &'a str) -> Self
pub const fn new(value: &'a str, label: &'a str) -> Self
An unpicked value at the root of the facet.
Sourcepub const fn of(value: &'a str) -> Self
pub const fn of(value: &'a str) -> Self
A value whose identifier is also what the user reads.
[Choice::of]’s convenience, and it is the flat case: a type or a tier
is its own name, and only a tree needs a path that is not one.
Sourcepub const fn counted(self, count: u64) -> Self
pub const fn counted(self, count: u64) -> Self
How many members carry it, when that was measured.
Trait Implementations§
Source§impl<'a> Clone for FacetValue<'a>
impl<'a> Clone for FacetValue<'a>
Source§fn clone(&self) -> FacetValue<'a>
fn clone(&self) -> FacetValue<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more