Skip to main content

FacetValue

Struct FacetValue 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§value: &'a str

What 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 str

What 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: Standing

Whether it is narrowing the set, and how it came to be.

§depth: Nesting

How 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: bool

Whether 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: bool

Whether 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: bool

Whether 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>

Source

pub const fn new(value: &'a str, label: &'a str) -> Self

An unpicked value at the root of the facet.

Source

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.

Source

pub const fn counted(self, count: u64) -> Self

How many members carry it, when that was measured.

Source

pub const fn standing(self, standing: Standing) -> Self

How it stands in the current selection.

Source

pub const fn at(self, depth: Nesting, branching: bool) -> Self

Where it sits in the tree, and whether anything hangs off it.

Source

pub const fn heading(self) -> Self

A group: a heading whose press opens it, never a pick.

Source

pub const fn opened(self, open: bool) -> Self

Whether its children are drawn, as view state apart from its standing.

Source

pub const fn joined(self, join: Join) -> Self

How the picks among its children combine.

Source

pub const fn gained(self) -> Self

Its count is a gain, +n, rather than a total.

Source

pub const fn ranked(self, rank: GroupRank) -> Self

Where it ranks among the groups.

Source

pub const fn is_open(&self) -> bool

Whether its children are drawn: its own open state when it has one, else whether it is in force.

A link row: neither pickable nor branching, so pressing it is its whole meaning (“31 more”).

Trait Implementations§

Source§

impl<'a> Clone for FacetValue<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for FacetValue<'a>

Source§

impl<'a> Debug for FacetValue<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Eq for FacetValue<'a>

Source§

impl<'a> Hash for FacetValue<'a>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'a> PartialEq for FacetValue<'a>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<'a> StructuralPartialEq for FacetValue<'a>

Auto Trait Implementations§

§

impl<'a> Forget for FacetValue<'a>

§

impl<'a> Freeze for FacetValue<'a>

§

impl<'a> Move for FacetValue<'a>

§

impl<'a> RefUnwindSafe for FacetValue<'a>

§

impl<'a> Send for FacetValue<'a>

§

impl<'a> Sync for FacetValue<'a>

§

impl<'a> Unpin for FacetValue<'a>

§

impl<'a> UnsafeUnpin for FacetValue<'a>

§

impl<'a> UnwindSafe for FacetValue<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.