Skip to main content

Request

Struct Request 

Source
pub struct Request {
    pub basis: Basis,
    pub query: Query,
    pub now: SystemTime,
}
Expand description

Everything that determines an answer.

Fields§

§basis: Basis

Root, scope, and content: what a holder of stored state must match.

§query: Query

Selection, views, and view options.

§now: SystemTime

The instant relative time windows were resolved against.

Fixed when the request is built, so Selection::modified is absolute and a watch that builds its request once at start never slides its window.

Implementations§

Source§

impl Request

Source

pub const DEFAULTS: RequestDefaults

The defaults table.

Source

pub const fn new(basis: Basis, query: Query, now: SystemTime) -> Self

One read of what basis holds, from a query its caller already has typed.

The composition six call sites wrote out by hand, each of them a holder’s basis and one read’s query and instant. A literal is not wrong, but a name is where the rule can be stated: basis is the holder’s, never the read’s, and now is this read’s, fixed so a watch that repaints does not slide its own window.

No validation, because the query is already typed and its holder is the one that knows which rule applies – Self::validate_read for a retained index, Self::validate for a request that is its own basis. Self::read is the constructor that parses and validates in one step.

Source

pub fn read( basis: Basis, spec: &ReadSpec<'_>, now: SystemTime, axes: &'static AxisNames, ) -> Result<Self, RequestError>

One read of what basis holds, written in the value grammars.

The constructor every read site wants: a holder supplies the basis it was opened with, and the caller supplies only what this read asks. The view default comes from the analyzers the basis already holds, so a typed set never has to be spelled back into the grammar to find out what a request that read files displays, and no caller builds a request with a throw-away basis and overwrites it afterwards.

§Errors

RequestError for a value no grammar accepts, and for a read the basis cannot answer: Self::validate’s rules, which here are the holder’s own.

Source

pub fn build( spec: &RequestSpec<'_>, now: SystemTime, axes: &'static AxisNames, ) -> Result<Self, RequestError>

Parse a spec into a request, resolving relative time windows against now.

Refusals name each axis as axes spells it, and so do the report diagnostics of the query built here. Every value is parsed before any is checked against another, in the order the command line reads its flags: content, views, selection, the page denominator, then scope. Rules that relate axes are Self::validate’s.

Source

pub fn validate(&self) -> Result<(), RequestError>

Refuse a request no holder of its own basis could answer.

In order: more views than one report carries, a view its content cannot answer, and a selection by ignored state its scope does not observe.

Source

pub fn validate_read(&self, held: &Basis) -> Result<(), RequestError>

Refuse a read that held, the basis of a retained index or opened root, cannot answer.

Content must be equal: an index built with other analyzers holds other metrics, and serving a narrower request from a wider store is a projection this model does not define. The remaining rules are Self::validate’s, applied to what held observed rather than to what the request says it would have. Scope equality is not checked here; ScanConfig owns it.

Source

pub fn validate_delivery(&self, delivery: &Delivery) -> Result<(), RequestError>

Refuse a delivery that cannot carry this request out.

Everything a watch cannot do, in one place, because a watch is the one delivery that changes which requests can be answered at all:

  • A narrowed scan scope (RequestError::WatchScope): a watcher cannot filter its backend’s events against a boundary the scan drew. Selection still works, because it filters the retained index rather than the scan.
  • Content analysis (RequestError::WatchContent): nothing re-reads a file the watch sees change, so a session would go on reporting the metrics it started with as fresh.
  • A snapshot nothing verified (RequestError::WatchCacheOnly): the window between the snapshot and the session’s start is never observed, so the first answer would describe a tree that may have moved and every later one would build on it.

Each was a guard on one surface, which is why a library caller and a Python caller could ask for what the command line refuses.

One refusal applies to every route: a stale answer comes from the snapshot, which CachePolicy::Off never reads (RequestError::StaleOkCacheOff).

Trait Implementations§

Source§

impl Clone for Request

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 Request

Source§

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

Formats the value using the given formatter. Read more

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