Skip to main content

Query

Struct Query 

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

A composable, sidecar-backed filter over a store’s records.

Build with Query::new and the with_* methods, then Query::execute. Multiple Query::with_where clauses AND together (intersection over the sidecar records).

Implementations§

Source§

impl Query

Source

pub fn new() -> Self

Start a new, empty query (matches everything until narrowed).

Source

pub fn with_type(self, type_: &str) -> Self

Restrict to a single type (frontmatter type predicate).

Setting it again replaces the previous value — a query has at most one type (a record carries exactly one type, so two types would never intersect).

Source

pub fn with_layer(self, layer: Layer) -> Self

Restrict to one layer (Sources / Records / Wiki) — scopes which sidecars’ records survive. Setting it again replaces the previous layer.

Source

pub fn with_where(self, key: &str, value: &str) -> Self

Add a key=value frontmatter predicate; chains as AND with any others (intersection over the sidecar records). Repeating the same key adds a second clause — both must hold — rather than replacing the first.

Source

pub fn execute(&self, store: &Store) -> Result<Vec<IndexRecord>, StoreError>

Resolve the query against the relevant type-folder index.jsonl sidecar(s) and return the matching IndexRecords — complete, one sequential read per type-folder, no whole-store walk.

The candidate set comes from the most selective frozen sidecar reader, always layer-scoped when with_layer is set, so an --in <layer> scope confines the sidecar walk to that layer’s subtree (O(entities-in-layer), the interactive-loop contract):

  • a type predicate reads the sidecars across the named layer (or the whole store when unscoped) and filters by the frontmatter type. The folder layout is convention, not enforcement (SPEC), so a record whose type is filed outside that type’s canonical layer — a contact in sources/, a custom screenshot that only ever lives in sources/ — is still found, and --type X --in <other-layer> returns exactly the records of that type filed under the other layer rather than always being empty;
  • otherwise the first where clause picks the sidecars and pre-filters, scoped to the layer when set;
  • otherwise (a layer scope but no type/where) the layer’s own sidecar records are the candidate set, so --in <layer> on its own enumerates that layer instead of silently returning empty.

Every remaining predicate is then applied in memory over the returned records — no extra sidecar reads, no walk.

A fully bare query (no type, no where, no layer) constrains nothing and has no selective candidate set, so it returns an empty result.

Trait Implementations§

Source§

impl Clone for Query

Source§

fn clone(&self) -> Query

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 Query

Source§

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

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

impl Default for Query

Source§

fn default() -> Query

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Query

§

impl RefUnwindSafe for Query

§

impl Send for Query

§

impl Sync for Query

§

impl Unpin for Query

§

impl UnsafeUnpin for Query

§

impl UnwindSafe for Query

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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<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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V