Skip to main content

Scope

Struct Scope 

Source
pub struct Scope<'a> { /* private fields */ }
Expand description

The vocabulary one request is resolved against.

Borrows both halves; nothing here outlives the call that builds it.

Implementations§

Source§

impl<'a> Scope<'a>

Source

pub fn new(elements: &'a [Value], envelope: &'a Value) -> Self

Builds a scope over the elements and the envelope that carried them.

The synonym scope starts unset, which admits only the groups that hold for every command. That is the fail-safe half of the pair: a caller that never states which subcommand it is resolving for gets no mode-specific synonym, rather than the synonyms of some arbitrary mode.

Source

pub fn with_command(self, command: Option<&'a str>) -> Self

GAP-SG-274: states which subcommand slug this scope resolves keys for.

Consumed by the synonym table alone. graph declares kind a spelling of the entity type; graph-ndjson does not, because there kind is the line discriminator and answering node to --select type would be a wrong value rather than a missing one.

Source

pub fn is_empty(&self) -> bool

true when there are no elements to resolve a key against.

An empty result array carries no vocabulary, so it cannot tell a key that does not exist from a key that simply had no row to appear in.

Source

pub fn classify(&self, key: &str) -> KeyOrigin

Where key lives, if anywhere.

An envelope with no elements can still answer KeyOrigin::EnvelopeOnly, which is what makes the scalar-envelope refusal precise instead of a blanket “no array here”.

Source

pub fn effective_key(&self, key: &str) -> Option<String>

GAP-SG-230: the spelling this payload actually uses for key.

Returns key itself when the payload carries it, the synonym when the payload spells the same field differently, and None when no spelling in the group is present anywhere in scope.

§Why this is a separate question from Self::classify

classify answers “may this request proceed”; this answers “which name do I look the value up under”. They only look like one question while both spellings are the same string. graph entities emits entity_type and graph --format json emits type for the very same column, so a caller that learned one name asks with it against both — and the four shaping knobs walk the path with the name the CALLER wrote, never with the verdict this scope reached. Answering only the first question would let a request pass the gate and then match nothing, which trades a refusal that names the fix for an empty set with exit 0.

Elements are consulted before the envelope, mirroring classify, so the answer describes the place a predicate or a projection will actually look.

Source

pub fn suggestions(&self, key: &str) -> Vec<String>

Key names close enough to key to be worth offering as a correction.

Ordered by descending similarity and capped at K_VOCABULARY_MAX_SUGGESTIONS. An empty vector means nothing in the vocabulary resembled the request, which is itself informative: the caller is looking at the wrong command, not at a typo.

GAP-SG-230: a DECLARED synonym that the payload really carries is placed first and bypasses the similarity floor entirely. Similarity is a proxy for “you mistyped this”; a synonym is not a typo, it is the same field under the name a sibling surface chose, and the table says so as a fact. Leaving it to Jaro-Winkler was measured to lose exactly the case this exists for: entity_type against type shares no prefix, so the metric scores it below VOCABULARY_SUGGESTION_MIN_SIMILARITY and the caller who asked with the sibling spelling was told nothing resembled its key — while the field sat right there under another name.

Source

pub fn vocabulary_is_partial(&self) -> bool

Distinct field names a correction could plausibly have meant.

Reads the elements when there are elements and the envelope when there are none, because that is the same split resolve_projection uses to decide what a key must address. Without the fallback the most useful refusal in the catalogue — --select body_length read, the case GAP-SG-202 was written from — named no alternative at all, since a read envelope carries no array to sample.

Borrowed, never cloned: the set holds &str into the payload, so a vocabulary of five hundred names costs five hundred pointers.

Whether the SUGGESTION vocabulary was built from less than everything.

Reported as vocabulary_partial so a caller reading an empty or thin suggestion list can tell “nothing resembled your key” from “the sampler stopped before it got there”. Only the suggestion path samples; Self::classify always scans every element, so a PARTIAL vocabulary never weakens a verdict — it only shortens the advice that follows one.

Auto Trait Implementations§

§

impl<'a> Freeze for Scope<'a>

§

impl<'a> RefUnwindSafe for Scope<'a>

§

impl<'a> Send for Scope<'a>

§

impl<'a> Sync for Scope<'a>

§

impl<'a> Unpin for Scope<'a>

§

impl<'a> UnsafeUnpin for Scope<'a>

§

impl<'a> UnwindSafe for Scope<'a>

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> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. 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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more