Skip to main content

Selection

Struct Selection 

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

A resolved, ordered, immutable snapshot of the issues a bulk operation acts on.

Built by Selection::resolve. The store is read; nothing is written, and there is no method on this type that can write — that is the property contract §3 needs, and it is structural rather than a promise.

Implementations§

Source§

impl Selection

Source

pub fn resolve( store: &Store, selectors: &[String], query: Option<&str>, source: SelectionSource, scope: SelectionScope, ) -> Result<Self>

Resolve a selection from explicit selectors and/or a query.

Resolution order, and why: explicit selectors first, then the query’s issues, then de-duplication. A user who typed both means the union, and taking the union in that order means the explicit ones lead — which is what a dry run should show first.

Ambiguity and not-found are the existing diagnostics, propagated unwrapped (contract §2). The first version wrapped the selector failure in a fresh NotFound, and the user saw not found: not found: issue matching … — the same doubled prefix a relationship message had. One message, from one place.

Source

pub fn from_issues( issues: impl IntoIterator<Item = Issue>, source: SelectionSource, scope: SelectionScope, ) -> Self

A snapshot from issues the caller already has, with no store involved.

Two callers need this and neither is a test: the TUI multi-select (WP07) resolves a selection from the board’s cards rather than from typed selectors, and a caller previewing a large in-memory set has no store to resolve against. Both want the same guarantee — a value that cannot grow — which is what makes this a constructor on the type rather than a pub field.

The order is preserved rather than sorted: a board’s column order is what a user sees, and a selection’s order is presentation (the fingerprint is the order-insensitive part, and is the thing an apply is authorized for).

Numbers are de-duplicated, because a board can list the same issue twice and a plan that writes it twice is the failure the data-model calls “the plan never double-writes an issue unintentionally”.

Source

pub fn issues(&self) -> &[Issue]

The issues, in the snapshot’s order.

Source

pub fn into_issues(self) -> Vec<Issue>

Take the snapshot, so a later stage owns it rather than borrowing.

Source

pub fn source(&self) -> SelectionSource

Source

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

Source

pub fn scope(&self) -> SelectionScope

Source

pub fn selectors(&self) -> &[String]

The selectors after de-duplication, in the order they resolved.

Source

pub fn duplicates(&self) -> &[String]

Selectors that named an issue an earlier selector had already named.

Reported rather than silently dropped: a user who typed 12 12 alpha and sees “3 issues” would otherwise have no way to know the third selector was ignored. The plan renders this (WP02 T009).

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn numbers(&self) -> Vec<u32>

The issue numbers, for a confirmation echo.

Source

pub fn fingerprint(&self) -> Vec<u32>

A stable identity for this selection, so an apply can refuse a plan that was confirmed against a different snapshot (contract §4: “apply requires the exact confirmed plan”).

Built from the numbers, not from a hash of the issue contents: a user may edit a selected issue between preview and apply, and the plan still applies to those issues — the values were validated at preview time and re-validated at apply time, so a content hash would refuse a legitimate apply for the wrong reason. Membership is what has to match.

Source

pub fn matches_fingerprint(&self, fingerprint: &[u32]) -> bool

Whether this selection matches a fingerprint, ignoring order.

Order-insensitive on purpose. A selection’s order is presentation; its membership is what an apply is authorized for, and rejecting an apply because the board came back in a different order would be a refusal with no user-visible cause.

Trait Implementations§

Source§

impl Clone for Selection

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 Selection

Source§

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

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

impl Eq for Selection

Source§

impl PartialEq for Selection

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 Selection

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

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> 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.