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: 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
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.

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 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: u8

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.

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.

[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.

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: u8, branching: bool) -> Self

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

Trait Implementations§

Source§

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

Source§

fn clone(&self) -> FacetValue<'a>

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: &FacetValue<'a>) -> 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> Freeze 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.