pub struct ViewService<'a, P: ProjectDirectory + ?Sized> { /* private fields */ }Expand description
The saved-view service: the registry, the caller’s config, and the project directory the scope checks resolve against.
The service borrows the caller’s Config mutably because an accepted
mutation is config.views changing; it never reaches around the registry to
write anything else. The active marker is in-memory state beside the config —
data-model §4’s “if explicitly persisted” — so marking a view writes no file.
Implementations§
Source§impl<'a, P: ProjectDirectory + ?Sized> ViewService<'a, P>
impl<'a, P: ProjectDirectory + ?Sized> ViewService<'a, P>
Sourcepub fn new(config: &'a mut Config, projects: &'a P, path: &'a Path) -> Self
pub fn new(config: &'a mut Config, projects: &'a P, path: &'a Path) -> Self
A service over a caller’s config, project directory, and tix.toml path.
Sourcepub fn registry(&self) -> &ViewRegistry
pub fn registry(&self) -> &ViewRegistry
The registry, for a surface that needs to enumerate or render it directly.
Sourcepub fn show(&self, reference: &str) -> ViewResult<ViewDetail>
pub fn show(&self, reference: &str) -> ViewResult<ViewDetail>
Resolve one view by stable id or display name, parse and validate its plan, and return it with any unknown-metadata diagnostics (T013).
A malformed plan is refused here, before a caller could try to apply or re-save it: “show” is the first place a stored-but-unsupported field would otherwise slip through.
Sourcepub fn apply(
&self,
reference: &str,
board: &BoardConfiguration,
corpus: &Corpus,
resolution: &CategoryResolution,
) -> ViewResult<ViewApplyResult>
pub fn apply( &self, reference: &str, board: &BoardConfiguration, corpus: &Corpus, resolution: &CategoryResolution, ) -> ViewResult<ViewApplyResult>
Apply a saved view: resolve it, then build the board once through the existing filter path (T015/C-005).
Read-only: board, corpus, and config are borrowed, and the result
owns only derived copies. Nothing is written, and a refused or unsupported
plan produces no board.
Sourcepub fn active(&self) -> Option<&ActiveViewMarker>
pub fn active(&self) -> Option<&ActiveViewMarker>
The active marker, when a view has been selected.
Sourcepub fn mark_active(
&mut self,
reference: &str,
source: Option<ViewSurface>,
) -> ViewResult<()>
pub fn mark_active( &mut self, reference: &str, source: Option<ViewSurface>, ) -> ViewResult<()>
Select a saved view as the active marker (T016).
The plan is parsed and validated first, so an unsupported definition cannot be marked. Selecting is informational and idempotent: it writes no config and does not touch live filters, and selecting the same view twice leaves an equal marker (C-006).
Sourcepub fn set_active(&mut self, marker: ActiveViewMarker)
pub fn set_active(&mut self, marker: ActiveViewMarker)
Install a marker directly, for a surface restoring one it persisted.
Still informational: this writes nothing, and a marker whose view has since
been deleted is reported (not repaired) by Self::divergence.
Sourcepub fn clear_active(&mut self)
pub fn clear_active(&mut self)
Clear the active marker. Informational, writes nothing.
Sourcepub fn divergence(&self, live: &ViewPlan) -> ViewDivergence
pub fn divergence(&self, live: &ViewPlan) -> ViewDivergence
Compare the live plan against the active view’s saved definition (T016).
Never mutates anything. A missing marker, a deleted view, or an
uninterpretable saved plan is an explicit diagnostic rather than a
in_sync = true.
Sourcepub fn create(&mut self, definition: ViewDefinition) -> ViewMutation<ViewId>
pub fn create(&mut self, definition: ViewDefinition) -> ViewMutation<ViewId>
Create a definition under a freshly allocated stable id (T013).
The complete definition is validated — name, scope, and every plan field — before the candidate registry is committed, so a rejected create writes nothing.
Sourcepub fn update(
&mut self,
reference: &str,
definition: ViewDefinition,
) -> ViewMutation<ViewId>
pub fn update( &mut self, reference: &str, definition: ViewDefinition, ) -> ViewMutation<ViewId>
Replace an existing definition’s name, scope, and plan in place (T013).
The stable id never changes (identity survives a rename, C-002) and the record’s preserved extension fields are left untouched (NFR-002). A same-content update is a no-op: no commit, no audit event.
Sourcepub fn duplicate(
&mut self,
reference: &str,
name: Option<&str>,
) -> ViewMutation<ViewId>
pub fn duplicate( &mut self, reference: &str, name: Option<&str>, ) -> ViewMutation<ViewId>
Duplicate a definition under a new stable id (T013).
The copy carries the source’s scope, plan, and preserved extensions
verbatim; only the id is new. name overrides the label when given.
Sourcepub fn delete(
&mut self,
reference: &str,
_confirmation: DeleteConfirmed,
) -> ViewMutation<DeletedView>
pub fn delete( &mut self, reference: &str, _confirmation: DeleteConfirmed, ) -> ViewMutation<DeletedView>
Delete a view definition after explicit confirmation (T014/C-005).
Only the definition is removed; issues, comments, relationships, and board data are never touched. If the active marker named this view it is cleared, and the outcome reports that so the caller can surface it. Deleting an unknown reference is refused (nothing was stored to remove).
Auto Trait Implementations§
impl<'a, P> !UnwindSafe for ViewService<'a, P>
impl<'a, P> Freeze for ViewService<'a, P>
impl<'a, P> RefUnwindSafe for ViewService<'a, P>
impl<'a, P> Send for ViewService<'a, P>
impl<'a, P> Sync for ViewService<'a, P>
impl<'a, P> Unpin for ViewService<'a, P>
impl<'a, P> UnsafeUnpin for ViewService<'a, P>
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> 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