Skip to main content

Lowerer

Struct Lowerer 

Source
pub struct Lowerer<'a> {
    pub regexes: &'a RegexCache,
    pub schema: &'a RepoPath,
    pub findings: Vec<Finding>,
    pub rule_ids: HashSet<String>,
    pub lifecycle: Vec<LifecycleDimension>,
    pub types: TypeRegistry,
}
Expand description

The state of one lowering: the schema it reports on, what it found, and what it has read so far that later keys resolve against.

Fields§

§regexes: &'a RegexCache

The cache the schema’s regexes compile through.

§schema: &'a RepoPath

The schema that every finding is reported on.

§findings: Vec<Finding>

The findings so far.

§rule_ids: HashSet<String>

The rule-ids declared so far.

§lifecycle: Vec<LifecycleDimension>

The lifecycle, which only resolves against.

§types: TypeRegistry

The types a template of this schema is written with.

Implementations§

Source§

impl Lowerer<'_>

Source

pub fn explained( &mut self, node: &Spanned, shapes: &[&str], format_speaks: bool, )

A rule that declares a shape shows an example of it. A regex is a shape and not an instruction, and the example is the one voice a rule has: every failure it raises shows it, and the scaffold writes it. A unit rule bound to a format takes the format’s, where format_speaks; the format of a frontmatter value checks the value and has no example. A rule that only selects, a count and a text state nothing.

Source

pub fn one_voice(&mut self, node: &Spanned)

Guidance says what the example cannot, so the two holding one sentence, or guidance that is one text of an example list, is guidance that says nothing.

Source

pub fn one_voice_in( &mut self, line: usize, guidance: &str, examples: impl IntoIterator<Item = String>, )

As one_voice, for guidance and each of examples, which the format gathers from wherever its scaffold writes them after it.

Source

pub fn check_bounds(&mut self, line: usize, min: usize, max: Option<usize>)

A rule’s min is at most its max.

Source§

impl Lowerer<'_>

Source

pub fn shape(&mut self, node: &Spanned) -> Option<Shape>

The shape node declares, a failure reported on the schema.

Source

pub fn check_key( &mut self, line: usize, key: &str, shape: Option<&Shape>, format: Option<&Format>, )

A key names a hole or a named group of shape, or of every shape of the format the rule binds.

Source

pub fn frontmatter_constraint( &mut self, node: &Spanned, key: &str, ) -> FrontmatterConstraint

Grammar frontmatter-constraint, for the key key.

Source§

impl<'a> Lowerer<'a>

Source

pub fn new( regexes: &'a RegexCache, schema: &'a RepoPath, types: TypeRegistry, ) -> Self

A lowering of a schema at schema, whose templates see types.

Source

pub fn fail( &mut self, line: usize, criterion: &'static str, message: impl Into<String>, )

A finding on the schema, at line, that breaks criterion.

Source

pub fn fail_with(&mut self, line: usize, problem: Problem)

A finding on the schema, at line, for problem.

Source

pub fn regex(&self, node: &Spanned, key: &str) -> Option<Regex>

The regex at key of node, checked where the grammar was read.

Source

pub fn prohibitions(&self, node: &Spanned) -> Vec<Prohibition>

The prohibited-patterns of node.

Source

pub fn only(&mut self, node: &Spanned) -> Only

The only of a rule, resolved against the lifecycle.

Source

pub fn common(&mut self, node: &Spanned) -> RuleCommon

The keys every rule map carries: severity, and only.

Source

pub fn lower_core( &mut self, yaml: &Spanned, formats: FormatRegistry, ) -> CoreSchema

The keys of the core grammar of a schema: the lifecycle first, which only resolves against, then the frontmatter, the bans and the examples. formats is the registry the schema sees.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for Lowerer<'a>

§

impl<'a> !Send for Lowerer<'a>

§

impl<'a> !Sync for Lowerer<'a>

§

impl<'a> !UnwindSafe for Lowerer<'a>

§

impl<'a> Freeze for Lowerer<'a>

§

impl<'a> Unpin for Lowerer<'a>

§

impl<'a> UnsafeUnpin for Lowerer<'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> 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, 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.