Skip to main content

CompileError

Enum CompileError 

Source
pub enum CompileError {
    Syntax {
        pos: usize,
        message: String,
    },
    EmptyMatchable,
    StateCap {
        limit: usize,
    },
    Serialize {
        message: String,
    },
    Invalid {
        message: String,
    },
}
Expand description

What: Re-exports the compile-time error type. Why: The surrounding function uses this step to keep the matcher behavior correct at this point.

In TS you’d write (pseudocode):

// Same step as the Rust statement below, written with ordinary TS objects/functions.

Reasons a pattern (or a serialized DFA) is rejected before it can match.

What: every failure path in parsing, the empty-match guard, the DFA state cap, and (de)serialization funnels into one of these variants. Why: callers (the scanner, tests) get a single typed error to match on, and compile/new never panic on bad input; they return one of these instead.

In TS you’d write (pseudocode):

type CompileError =
  | { kind: "variant" };

Variants§

§

Syntax

A syntax or unsupported-construct rejection at a byte offset.

What: holds the offset into the pattern and a message naming what was wrong (unsupported operator, bad escape, unbalanced bracket, operand not a single atom, mixed operators, stacked quantifier, bad repetition). Why: one variant covers every parse rejection so the surface stays small while still pointing the rule author at the exact spot.

In TS you’d write (pseudocode):

// Same step as the Rust statement below, written with ordinary TS objects/functions.

Fields

§pos: usize

What: Byte offset into the pattern where the problem was detected. Why: pos stores byte offset into the pattern where the problem was detected, so matcher code reads that precomputed state by name instead of recomputing or passing it separately.

In TS you’d write (pseudocode):

pos: number;
§message: String

What: Human-readable description of what was rejected. Why: message stores human-readable description of what was rejected, so matcher code reads that precomputed state by name instead of recomputing or passing it separately.

In TS you’d write (pseudocode):

message: string;
§

EmptyMatchable

The pattern can match the empty string, so under unanchored search it would match every input.

What: raised when the parsed root is nullable in some realizable anchor context. Why: such a rule is a footgun (flags every line); rejecting it at compile time is safer than silently matching everything.

In TS you’d write (pseudocode):

// Same step as the Rust statement below, written with ordinary TS objects/functions.
§

StateCap

Determinization produced more states than the configured cap.

What: complement and intersection can blow up the state count on pathological patterns. Why: a hard cap turns that into a clean error instead of unbounded memory use.

In TS you’d write (pseudocode):

// Same step as the Rust statement below, written with ordinary TS objects/functions.

Fields

§limit: usize

What: State-count limit that was exceeded. Why: limit stores state-count limit that was exceeded, so matcher code reads that precomputed state by name instead of recomputing or passing it separately.

In TS you’d write (pseudocode):

limit: number;
§

Serialize

Encoding a compiled automaton to bytes failed.

What: wraps a bincode serialization failure as a string. Why: keeps the public error free of a bincode type in its signature.

In TS you’d write (pseudocode):

// Same step as the Rust statement below, written with ordinary TS objects/functions.

Fields

§message: String

What: Underlying codec failure rendered as text. Why: message stores underlying codec failure rendered as text, so matcher code reads that precomputed state by name instead of recomputing or passing it separately.

In TS you’d write (pseudocode):

message: string;
§

Invalid

A deserialized automaton failed structural validation.

What: raised by from_bytes when decoded indices are out of bounds or lengths are inconsistent. Why: a hostile or corrupt blob must be rejected before it is ever executed, so the match loop can never read out of bounds.

In TS you’d write (pseudocode):

// Same step as the Rust statement below, written with ordinary TS objects/functions.

Fields

§message: String

What: Description of which invariant the decoded automaton violated. Why: message stores description of which invariant the decoded automaton violated, so matcher code reads that precomputed state by name instead of recomputing or passing it separately.

In TS you’d write (pseudocode):

message: string;

Trait Implementations§

Source§

impl Clone for CompileError

Source§

fn clone(&self) -> CompileError

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 CompileError

Source§

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

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

impl Display for CompileError

What: Renders a CompileError for end users and logs. Why: The program attaches these functions to the named Rust type so callers can use method syntax.

In TS you’d write (pseudocode):

// Methods are written inside a class or as functions that take the value.
Source§

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

Writes a one-line description of the error.

What: matches each variant to a sentence. Why: Display is what the scanner surfaces and what Error builds on.

In TS you’d write (pseudocode):

function fmt(f: fmt.Formatter<'_>): fmt.Result {
  // Rust body below is the implementation.
}
Source§

impl Eq for CompileError

Source§

impl Error for CompileError

What: Lets CompileError participate in the standard error ecosystem. Why: The program attaches these functions to the named Rust type so callers can use method syntax.

In TS you’d write (pseudocode):

// Methods are written inside a class or as functions that take the value.
1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl PartialEq for CompileError

Source§

fn eq(&self, other: &CompileError) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for CompileError

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> 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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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