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
impl ViewPlan
Sourcepub fn from_parts(filter: StructuredFilter, text_query: &str) -> Self
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.
Sourcepub fn from_query(text_query: &str) -> Self
pub fn from_query(text_query: &str) -> Self
A plan from a raw query string alone, with no structured criteria.
Sourcepub fn filter(&self) -> &StructuredFilter
pub fn filter(&self) -> &StructuredFilter
The structured criteria.
Sourcepub fn text_query(&self) -> Option<&str>
pub fn text_query(&self) -> Option<&str>
The remaining text query, with control tokens lifted out. None when the
plan carries no free text.
Sourcepub fn sort(&self) -> Option<&str>
pub fn sort(&self) -> Option<&str>
The supported sort key, or None for the board’s default ordering.
Sourcepub fn visibility(&self) -> Option<&ViewVisibility>
pub fn visibility(&self) -> Option<&ViewVisibility>
The visibility snapshot, or None when the plan leaves visibility to the
live board.
Sourcepub fn extensions(&self) -> &Table
pub fn extensions(&self) -> &Table
Plan-level keys this build does not interpret, preserved verbatim.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Whether the plan asks for nothing at all — no criteria, text, sort, group, visibility, or unknown metadata.
Sourcepub fn with_filter(self, filter: StructuredFilter) -> Self
pub fn with_filter(self, filter: StructuredFilter) -> Self
Replace the structured criteria, normalizing the result.
Sourcepub fn with_text_query(self, text_query: &str) -> Self
pub fn with_text_query(self, text_query: &str) -> Self
Replace the text query, lifting any control tokens it carries.
Sourcepub fn with_group(self, group: &str) -> Self
pub fn with_group(self, group: &str) -> Self
Set the group key.
Sourcepub fn with_visibility(self, visibility: ViewVisibility) -> Self
pub fn with_visibility(self, visibility: ViewVisibility) -> Self
Set the visibility snapshot.
Sourcepub fn with_extensions(self, extensions: Table) -> Self
pub fn with_extensions(self, extensions: Table) -> Self
Attach plan-level unknown metadata (already normalized by the caller’s round trip; kept verbatim here).
Sourcepub fn normalize(&mut self)
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.
Sourcepub fn validate(
&self,
board: &BoardConfiguration,
config: &Config,
) -> ViewResult<()>
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.
Sourcepub fn diagnostics(&self) -> Vec<ViewDiagnostic>
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>.
Sourcepub fn to_toml(&self) -> Table
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.
Sourcepub fn from_toml(table: &Table) -> ViewResult<Self>
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.
Sourcepub fn apply(
&self,
board: &BoardConfiguration,
config: &Config,
corpus: &Corpus,
resolution: &CategoryResolution,
) -> ViewResult<ViewApplyResult>
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.
Sourcepub fn apply_as(
&self,
view_id: &ViewId,
board: &BoardConfiguration,
config: &Config,
corpus: &Corpus,
resolution: &CategoryResolution,
) -> ViewResult<ViewApplyResult>
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.
Sourcepub fn effective_query(&self) -> String
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).
Sourcepub fn effective_board(&self, board: &BoardConfiguration) -> BoardConfiguration
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§
impl StructuralPartialEq for ViewPlan
Auto Trait Implementations§
impl Freeze for ViewPlan
impl RefUnwindSafe for ViewPlan
impl Send for ViewPlan
impl Sync for ViewPlan
impl Unpin for ViewPlan
impl UnsafeUnpin for ViewPlan
impl UnwindSafe for ViewPlan
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<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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