Skip to main content

ViewPlan

Struct ViewPlan 

Source
pub struct ViewPlan { /* private fields */ }
Expand description

The normalized query/board plan (data-model §3).

Construct one with ViewPlan::from_parts (the adapter from a filter modal’s StructuredFilter plus a raw query), ViewPlan::from_query (the raw query alone), the with_* builders, or ViewPlan::from_toml (the persisted shape). Whichever route, the value is normalized before it is returned.

Implementations§

Source§

impl ViewPlan

Source

pub fn from_parts(filter: StructuredFilter, text_query: &str) -> Self

Adapt the two inputs every surface already has into one normalized plan (T007).

filter is the typed modal state; text_query is the raw query string. Any sort:/group: control token in the query is lifted into the typed fields (first occurrence wins, matching crate::search::control_token) and removed from the text query, so the plan has exactly one place a sort or group lives. A typed field the caller already set wins over the token; the token is dropped either way.

Source

pub fn from_query(text_query: &str) -> Self

A plan from a raw query string alone, with no structured criteria.

Source

pub fn filter(&self) -> &StructuredFilter

The structured criteria.

Source

pub fn text_query(&self) -> Option<&str>

The remaining text query, with control tokens lifted out. None when the plan carries no free text.

Source

pub fn sort(&self) -> Option<&str>

The supported sort key, or None for the board’s default ordering.

Source

pub fn group(&self) -> Option<&str>

The supported group key, or None for no grouping.

Source

pub fn visibility(&self) -> Option<&ViewVisibility>

The visibility snapshot, or None when the plan leaves visibility to the live board.

Source

pub fn extensions(&self) -> &Table

Plan-level keys this build does not interpret, preserved verbatim.

Source

pub fn is_empty(&self) -> bool

Whether the plan asks for nothing at all — no criteria, text, sort, group, visibility, or unknown metadata.

Source

pub fn with_filter(self, filter: StructuredFilter) -> Self

Replace the structured criteria, normalizing the result.

Source

pub fn with_text_query(self, text_query: &str) -> Self

Replace the text query, lifting any control tokens it carries.

Source

pub fn with_sort(self, sort: &str) -> Self

Set the sort key.

Source

pub fn with_group(self, group: &str) -> Self

Set the group key.

Source

pub fn with_visibility(self, visibility: ViewVisibility) -> Self

Set the visibility snapshot.

Source

pub fn with_extensions(self, extensions: Table) -> Self

Attach plan-level unknown metadata (already normalized by the caller’s round trip; kept verbatim here).

Source

pub fn normalize(&mut self)

Canonicalize every value (T008).

Trims text, drops the empty ones, folds overdue: false to “unset”, and normalizes column lists. Unsupported sort or group keys are kept — normalization is not validation, and Self::validate is what reports them. An explicit sort/group key is kept too: sort:created is a different plan from “no sort”, because the board’s own order_by is not the sorted path.

Source

pub fn validate( &self, board: &BoardConfiguration, config: &Config, ) -> ViewResult<()>

Report every unsupported field in the plan, against board and the project’s category vocabulary (T009).

Returns Ok(()) only when every field is representable on this board. Otherwise the refusal carries one diagnostic per problem, in a stable order (filter, then sort, then group, then visibility), each with its record-relative field path. config is consulted for the configured category vocabulary — the same Config::categories the live category: token path validates against — so a plan cannot validate here and then match nothing on apply.

Source

pub fn diagnostics(&self) -> Vec<ViewDiagnostic>

Unknown-metadata notices for this plan (T010).

Informational, never a refusal: the keys were preserved, and this is how a surface tells the user they exist. The fields are plan.extensions.<key>, plan.filter.extensions.<key>, and plan.visibility.extensions.<key>.

Source

pub fn to_toml(&self) -> Table

Serialize to the persisted [plan] table shape (T010).

Only fields that are set are written, so an empty plan is an empty table. Unknown keys captured at any level are merged back into their original position, unchanged.

Source

pub fn from_toml(table: &Table) -> ViewResult<Self>

Parse the persisted [plan] table shape (T010).

Structural problems (a field of the wrong TOML type) are refusals; an unsupported value (sort = "bogus") is not — that is Self::validate’s job, so a plan written by a newer build with a sort key this build does not know still loads and still round-trips.

Source

pub fn apply( &self, board: &BoardConfiguration, config: &Config, corpus: &Corpus, resolution: &CategoryResolution, ) -> ViewResult<ViewApplyResult>

Apply the plan: build the board once through the existing filter path and return a read-only result (T011/C-005).

Validates first, so an unsupported field returns a refusal and no board is built. The board’s visibility comes from the plan when the plan sets it and from board otherwise; the sort and group are reconstructed as the existing control tokens, so the existing BoardState::build_filtered ordering and grouping apply unchanged.

Source

pub fn apply_as( &self, view_id: &ViewId, board: &BoardConfiguration, config: &Config, corpus: &Corpus, resolution: &CategoryResolution, ) -> ViewResult<ViewApplyResult>

Self::apply for a plan reached through a stable view id, so the result carries the identity its surface selected.

Source

pub fn effective_query(&self) -> String

The query string the existing matcher and board builder consume: the free text plus the typed sort/group re-spelled as their control tokens.

Public because a surface that installs a plan into live filter state (the TUI, WP05) must hand the same query to the same BoardState::build_filtered path Self::apply uses. Re-spelling the tokens at the call site would be a second, drift-prone spelling of the control-token protocol (C-002/C-007/NFR-003).

Source

pub fn effective_board(&self, board: &BoardConfiguration) -> BoardConfiguration

The board configuration a view is applied over: the live board, with its visibility replaced when the plan carries a snapshot.

Public for the same reason as Self::effective_query: a surface that keeps the applied plan as live state (the TUI, WP05) rebuilds the board through the existing path, and the visibility it must use is exactly the one Self::apply used.

Trait Implementations§

Source§

impl Clone for ViewPlan

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

Source§

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

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

impl Default for ViewPlan

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for ViewPlan

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 StructuralPartialEq for ViewPlan

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<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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.