Skip to main content

ViewSpec

Struct ViewSpec 

Source
pub struct ViewSpec {
    pub name: String,
    pub label: Option<String>,
    pub icon: Option<String>,
    pub group: Grouping,
    pub under: Option<String>,
    pub filter: Option<Condition>,
    pub nest: Option<Grain>,
}
Expand description

One view a workspace declares for itself.

Fields§

§name: String

The key under views — also the token that names this view to a frontend, and the id it is addressed by.

§label: Option<String>

What a person calls it. Absent falls back to the name, humanized.

§icon: Option<String>

A glyph hint for a frontend’s lens picker. Uninterpreted here: what a calendar looks like is the frontend’s business.

§group: Grouping

Classification — how records become groups.

§under: Option<String>

Aggregation — the index this view’s records hang under, as a link ('[Daily](id:abc1234)'). None scopes the view to the whole workspace.

§filter: Option<Condition>

The where: conditions a document in scope must also meet. None takes everything scope reaches.

Named filter because where is a Rust keyword; the config spelling is where, which is what a reader of the format sees.

Separate from under because the two fail differently: an anchor that names nothing is a broken view, while a condition that matches nothing is an ordinary empty answer.

§nest: Option<Grain>

Materialization: when set, filing a new record through this view nests it under an index at this grain below under, creating the index if the calendar has turned. None files flat.

Independent of Grouping::by on purpose — see the module docs.

Implementations§

Source§

impl ViewSpec

Source

pub fn parse(name: &str, value: &Value) -> Option<Self>

Read one views.<name> entry.

Returns None when the entry is not a mapping or names no groupable field — an entry that does not say what it groups by is not a view, and recording it as one would put a lens in the picker that groups nothing. crate::diagnose_view is the half that says why, so a malformed entry is reported rather than merely dropped.

Source

pub fn to_mapping(&self) -> Mapping

The mapping this view writes back as. Absent options are omitted rather than written empty, so a view declared from an app reads as the small thing it is.

Source

pub fn nest_route(&self, meta: &Value) -> Option<Vec<String>>

The index titles a new record nests under, coarsest first — or None when this view does not nest, or meta cannot be filed.

For a date view at month grain this is ["2026", "2026-07"]; for an alphabetical one at initial 2, ["A", "AD"]. Those are titles, which is exactly what prov’s route addressing takes (prov new --under "Daily/2026/2026-07" -p), so a frontend that materializes a view hands this straight to plan_route and never assembles a path itself.

None in three cases, all of which mean this record has no single home under this view rather than nowhere:

  • the view declares no nest;
  • no field in the grouping chain carries a usable value, so there is nothing to file by;
  • the value is multi-valued. This is the constraint prov’s spanning relation imposes: a document with two people cannot hang under two parents, and picking one would be inventing an answer the workspace did not give. Such a view groups perfectly well — it just cannot be materialized, which is why nest on a multi-valued field is a config finding rather than a runtime surprise.
Source

pub fn display_label(&self) -> String

What a person calls this view: its label, else its name humanized (daily_entriesDaily entries).

Trait Implementations§

Source§

impl Clone for ViewSpec

Source§

fn clone(&self) -> ViewSpec

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 Debug for ViewSpec

Source§

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

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

impl Eq for ViewSpec

Source§

impl PartialEq for ViewSpec

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ViewSpec

Auto Trait Implementations§

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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.