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: StringThe 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: GroupingClassification — 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
impl ViewSpec
Sourcepub fn parse(name: &str, value: &Value) -> Option<Self>
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.
Sourcepub fn to_mapping(&self) -> Mapping
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.
Sourcepub fn nest_route(&self, meta: &Value) -> Option<Vec<String>>
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
neston a multi-valued field is a config finding rather than a runtime surprise.
Sourcepub fn display_label(&self) -> String
pub fn display_label(&self) -> String
What a person calls this view: its label, else its name humanized
(daily_entries → Daily entries).
Trait Implementations§
impl Eq for ViewSpec
impl StructuralPartialEq for ViewSpec
Auto Trait Implementations§
impl Freeze for ViewSpec
impl RefUnwindSafe for ViewSpec
impl Send for ViewSpec
impl Sync for ViewSpec
impl Unpin for ViewSpec
impl UnsafeUnpin for ViewSpec
impl UnwindSafe for ViewSpec
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.