pub struct TaskQuery { /* private fields */ }Expand description
Query parameters for filtered, snapshot-consistent Task listing.
Filtering is carried by TaskFilter.
Pagination applies only to list operations.
Implementations§
Source§impl TaskQuery
impl TaskQuery
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates an unfiltered query with default pagination.
§Example
use solti_model::{DEFAULT_LIMIT, TaskPhase, TaskQuery};
let query = TaskQuery::new();
assert_eq!(query.limit(), DEFAULT_LIMIT);
assert!(query.matches_phase(&TaskPhase::Failed));Sourcepub fn from_filter(filter: TaskFilter) -> Self
pub fn from_filter(filter: TaskFilter) -> Self
Creates a query from filters.
Sourcepub fn with_phase(self, phase: TaskPhase) -> Self
pub fn with_phase(self, phase: TaskPhase) -> Self
Adds a phase filter.
Multiple calls accumulate with OR semantics.
Sourcepub fn with_phases(self, phases: impl IntoIterator<Item = TaskPhase>) -> Self
pub fn with_phases(self, phases: impl IntoIterator<Item = TaskPhase>) -> Self
Adds phase filters from an iterator.
Values are deduplicated and retain OR semantics.
Sourcepub fn with_label_selector(self, selector: LabelSelector) -> ModelResult<Self>
pub fn with_label_selector(self, selector: LabelSelector) -> ModelResult<Self>
Filter by labels.
Every selector requirement is ANDed. An empty selector matches all tasks.
§Errors
Returns ModelError::Invalid when the selector is invalid.
Sourcepub fn with_active(self) -> Self
pub fn with_active(self) -> Self
Filter by all active phases: Pending and Running.
Sourcepub fn with_terminal(self) -> Self
pub fn with_terminal(self) -> Self
Filter by all terminal phases.
Sourcepub fn with_limit(self, limit: usize) -> Self
pub fn with_limit(self, limit: usize) -> Self
Sets the page size.
Zero selects DEFAULT_LIMIT. Values above MAX_LIMIT are capped.
Sourcepub fn with_continuation(self, continuation: TaskContinuation) -> Self
pub fn with_continuation(self, continuation: TaskContinuation) -> Self
Continue a previously returned collection snapshot.
Sourcepub fn matches_phase(&self, phase: &TaskPhase) -> bool
pub fn matches_phase(&self, phase: &TaskPhase) -> bool
Returns whether a phase passes the phase filter.
Sourcepub fn matches_labels(&self, labels: &Labels) -> bool
pub fn matches_labels(&self, labels: &Labels) -> bool
Returns whether labels pass the selector.
Sourcepub fn continuation(&self) -> Option<&TaskContinuation>
pub fn continuation(&self) -> Option<&TaskContinuation>
Continuation cursor, when this is not the first page.
Sourcepub fn filter(&self) -> &TaskFilter
pub fn filter(&self) -> &TaskFilter
Filters applied before pagination.
Sourcepub fn label_selector(&self) -> &LabelSelector
pub fn label_selector(&self) -> &LabelSelector
Label selector.