search_query

Parsed representation of search query strings. Parsed representation of a search query string with structured filters.

Filter syntax:

Same filter types OR-combine; different filter types AND-combine. Exclude filters AND-combine (exclude any match). Unknown prefixes are treated as free text.

const KNOWN_PREFIXES

source

const KNOWN_PREFIXES: &[&str] = &["is", "status", "tag"];

Known filter prefixes (case-insensitive matching is handled by lowercasing the prefix).

enum Filter

source

pub enum Filter

A single filter extracted from the query.

Variant Description
Is(String) Matches entities whose type equals the given lowercase name (e.g. task).
Status(String) Matches entities whose status equals the given lowercase name.
Tag(String) Matches entities carrying the given lowercase tag label.

Implements Clone, Debug, Eq, PartialEq.

struct ParsedQuery

source

pub struct ParsedQuery

The result of parsing a search query string.

Field Type Description
exclude Vec<Filter> Negated filters (prefixed with -) that must not match.
include Vec<Filter> Filters that must match; same-type filters OR-combine, different-type AND-combine.
text Vec<String> Free-text tokens to match against entity content.

Implements Clone, Debug, Default, Eq, PartialEq.

ParsedQuery::is_empty

source

pub fn is_empty(&self) -> bool

Returns true when the query has no filters and no text.

Parameter Type Description
returns bool false when text, include or exclude is not empty.

fn parse

source

pub fn parse(query: &str) -> ParsedQuery

Parse a search query string into a ParsedQuery.

Tokens are split on whitespace. A known prefix with a non-empty value becomes a filter, with the value lowercased; every other token, including a bare - and a negated unknown prefix, is kept verbatim as free text.

Parameter Type Description
query &str the raw query string, as the user typed it
returns ParsedQuery The include filters, exclude filters and free-text tokens, each in the order they appeared.