static-automata 1.0.2

Derive macro for static regular grammar
Documentation
use static_automata::{Validate, grammar};

/// Automata module.
///
/// This module file is generated by the command line interface or builder
/// library. It contains an `Iri` type definition for the `IRI` production of
/// the `iri.abnf` that we exported here, with a `validate_bytes` and a
/// `validate_bytes` const function.
///
/// The attribute macro itself doesn't generate anything, but replaces this item
/// with an external module import `mod automata;`.
#[grammar(file = "iri.abnf", export("IRI"))]
mod automata {}

/// Derive the `validate_bytes` and `validate_str` methods from the
/// `automata::Iri` automaton.
#[derive(Validate)]
#[automaton(automata::Iri)]
struct Foo;

fn main() {
	assert!(Foo::validate_str("https://rust-lang.org/"));
	assert!(!Foo::validate_str("not an IRI"));
}