Skip to main content

GateCtx

Struct GateCtx 

Source
pub struct GateCtx {
    pub repo_root: Utf8PathBuf,
    /* private fields */
}
Expand description

Where a gate runs: the repository root pre-commit invoked it from, and the subject filter that bounds what it judges there.

§Subject paths and support paths

A subject path is one whose content the gate judges and which can appear in a finding. A support path is one the gate reads to know what to judge: the canon manifest, the known-issue records, the docs-root resolution, the tracking registry. The filter governs subject paths. Self::path and read_text stay open, because a filter that reached support paths would let a project disable a gate by excluding the file that configures it.

§Every route a subject path takes

There are three, and each passes through Self::subjects, so a gate author cannot reach an unfiltered subject list:

  1. The &[String] a gate is handed, filtered in commands::gate.
  2. walk_files, which filters before it returns.
  3. crate::gates::spec_change_is_typed, which resolves its own candidate set and filters it explicitly.

canon::every_subject_producer_is_filter_aware holds that list.

Fields§

§repo_root: Utf8PathBuf

The repository root; every path a gate reads or reports is relative to it.

Implementations§

Source§

impl GateCtx

Source

pub fn new(repo_root: impl Into<Utf8PathBuf>) -> Self

A context rooted at the given repository, judging everything.

This is the shape every test and every internal caller wants. The command path uses Self::with_filter.

Source

pub fn with_filter( repo_root: impl Into<Utf8PathBuf>, filter: PathFilter, ) -> Self

A context whose gate judges only what the filter admits.

Source

pub fn path(&self, relative: impl AsRef<Utf8Path>) -> Utf8PathBuf

Resolve a repository-relative path for reading.

Deliberately unfiltered: a gate reads its support files through here.

Source

pub fn subjects<P: AsRef<Utf8Path>>( &self, candidates: impl IntoIterator<Item = P>, ) -> Vec<P>

The subset of candidates this gate judges.

Every subject path pre-commit or an operator hands a gate comes through here, and the registry whitelist binds.

Source

pub fn retained<P: AsRef<Utf8Path>>( &self, candidates: impl IntoIterator<Item = P>, ) -> Vec<P>

The subset of candidates this gate’s exclusions leave.

For a subject set the gate discovered itself. See PathFilter::retains.

Source

pub const fn filter(&self) -> &PathFilter

The filter itself, for --explain and for the renderer.

Trait Implementations§

Source§

impl Debug for GateCtx

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

Source§

type Output = T

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