#[non_exhaustive]pub struct FacetValue<'a> {
pub value: &'a str,
pub label: &'a str,
pub count: Option<u64>,
pub standing: Standing,
pub depth: Nesting,
pub branching: bool,
pub pickable: bool,
pub open: Option<bool>,
pub join: Option<Join>,
pub gain: bool,
pub rank: Option<GroupRank>,
}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.
An option’s split between what submits and what reads, 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: NestingHow 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.
pickable: boolWhether pressing it narrows the set to it.
True for every value of a flat facet. In a tree, a node that is not pickable is a group: a heading whose press opens or closes it, and which offers no exclude. A non-pickable node that does not branch is a link row (“31 more”, “More groups”), whose press is its whole meaning. Which nodes are pickable is data, never a name: an app passes it in.
open: Option<bool>Whether its children are drawn, when that is view state of its own.
None keeps the older reading, open while in force, because picking a
value used to be the only way to look inside it. Some separates the
two: opening a group is not picking it.
join: Option<Join>How the picks among its children combine, for a node whose children
are picked: any of them, or all of them. None where nothing under it
can be picked. A renderer offers the toggle on the open row.
gain: boolWhether count is a gain rather than a total: how many
more results picking it adds, under a parent combining any of its picks
that already holds one. A renderer writes it as +n.
rank: Option<GroupRank>Where a group ranks among the others, for a group the app ranked.
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.
A plain option’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.
Sourcepub const fn standing(self, standing: Standing) -> Self
pub const fn standing(self, standing: Standing) -> Self
How it stands in the current selection.
Sourcepub const fn at(self, depth: Nesting, branching: bool) -> Self
pub const fn at(self, depth: Nesting, branching: bool) -> Self
Where it sits in the tree, and whether anything hangs off it.
Sourcepub const fn opened(self, open: bool) -> Self
pub const fn opened(self, open: bool) -> Self
Whether its children are drawn, as view state apart from its standing.