Skip to main content

Facet

Struct Facet 

Source
#[non_exhaustive]
pub struct Facet<'a> { pub name: &'a str, pub mode: Selecting, pub values: &'a [FacetValue<'a>], }
Expand description

A named dimension a set can be narrowed by.

One word for six things that were six mechanisms. MNW’s discover page filters by free text, a flat any-of over item types, a tree of tags, a numeric range over price, a nested one-of over AI tier, and a browse position in the tag tree held separately from the tag selection — and the last two being separate is the whole reason a filter row there needs a tick box and a chevron. The panel is a mixed bag of hand-written controls because nothing named the thing they all are.

Deliberately wider than that one page. audiofiles’ library browser and goingson’s filters are the same shape, and a word that only fitted discover would be discover’s markup with a neutral name on it.

§What it does not say

What picking a value calls. This crate names no address, so a facet is paired with routes the way a column’s sortable flag is paired with what reordering calls.

How a tree is drawn. Indented rows, a column of panes, a breadcrumb and a list: all four are honest renderings of the same described facet, and a terminal will not pick the same one a browser does. FacetValue::depth is what a renderer needs to draw any of them; the choice is not described.

Which values to show. A tag tree has thousands of nodes and a panel shows a handful. Deciding which handful is the app’s — it is the same question as which rows go in a table, and no table member answers it either.

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.
§name: &'a str

What the dimension is called, as the user reads it.

§mode: Selecting

How many of its values may be in force, and in what shape.

§values: &'a [FacetValue<'a>]

The values on offer, in the order they are drawn.

A Selecting::Text facet has none: the value is whatever was typed, and a description that listed the possible strings would be listing the corpus. A Selecting::Range facet has none either, for the reason FieldKind::Range takes bounds rather than options — the ends are the question and the values between them are not enumerable.

Implementations§

Source§

impl<'a> Facet<'a>

Source

pub const fn new( name: &'a str, mode: Selecting, values: &'a [FacetValue<'a>], ) -> Self

A dimension with values to pick from.

Source

pub fn engaged(&self) -> bool

Whether the facet is narrowing the set right now.

The question a renderer asks to decide whether to offer a way out of it, and the reason it is derived rather than carried: a facet with nothing standing is unengaged by construction, so a member saying so could disagree with the values beside it. Standing::Inherited does not count — something further up is what is doing the narrowing, and clearing a child that was never picked clears nothing.

Always false for Selecting::Text and Selecting::Range, which carry no values. A host that wants a clear affordance on those knows whether its own box is empty; the description does not hold the typed string.

Source

pub fn reach(&self) -> u8

The deepest value in the facet, or zero when it is flat.

What an indenting renderer needs to reserve a gutter before it draws the first row, which is “First paint is final paint” applied to a tree: a gutter widened as deeper values arrive is the reflow that rule forbids.

Trait Implementations§

Source§

impl<'a> Clone for Facet<'a>

Source§

fn clone(&self) -> Facet<'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 Facet<'a>

Source§

impl<'a> Debug for Facet<'a>

Source§

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

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

impl<'a> Eq for Facet<'a>

Source§

impl<'a> Hash for Facet<'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 Facet<'a>

Source§

fn eq(&self, other: &Facet<'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 Facet<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Facet<'a>

§

impl<'a> RefUnwindSafe for Facet<'a>

§

impl<'a> Send for Facet<'a>

§

impl<'a> Sync for Facet<'a>

§

impl<'a> Unpin for Facet<'a>

§

impl<'a> UnsafeUnpin for Facet<'a>

§

impl<'a> UnwindSafe for Facet<'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.