Skip to main content

Crate ferronconf

Crate ferronconf 

Source
Expand description

A Rust library for parsing ferron.conf configuration files.

ferron.conf is a domain-specific language for Ferron web server configurations. This crate provides a reference implementation including a lexer, parser, and AST.

§Features

  • Lexer — Tokenizes configuration files with support for comments, strings, numbers, booleans, and interpolation
  • Parser — Builds an AST from tokens with full error reporting
  • AST — Type-safe representation of configuration structures with helper methods

§Quick Start

use ferronconf::Config;
use std::str::FromStr;

let input = r#"
example.com {
    root /var/www/example
    tls true
}

*.example.com:443 {
    proxy http://backend
}
"#;

let config = Config::from_str(input).unwrap();

// Find all host blocks
for host_block in config.find_host_blocks() {
    for host in &host_block.hosts {
        println!("Host: {}", host.as_str());
    }
}

§See Also

  • Config — The root AST node
  • Span — Source location for error reporting
  • ParseError — Error type for parse failures

Structs§

Block
A block of nested statements enclosed in braces.
Config
The root AST node representing a complete ferron.conf configuration file.
Directive
A configuration directive with a name, optional arguments, and an optional nested block.
HostBlock
A host-specific configuration block.
HostPattern
A host pattern in a host block.
MatchBlock
A conditional match block that evaluates request attributes.
MatcherExpression
An expression in a match block that compares two operands.
ParseError
A parse error with message and source location.
SnippetBlock
A reusable configuration snippet definition.
Span
A source location (line and column) for error reporting.

Enums§

HostLabels
The type of host label in a host pattern.
Operand
An operand in a matcher expression.
Operator
A comparison operator in a matcher expression.
Statement
A statement in the configuration file.
StringPart
A part of an interpolated string.
Value
A value in a directive argument or expression operand.