Expand description
Lossless intermediate representation (IR) for network device configuration text.
This crate provides:
- a tree model (
Document,Node,LineNode,BlockNode) - a conservative parser (
parse_generic,parse_with_dialect) - a lossless renderer (
Document::render)
The parser is intentionally conservative for pre-alpha use:
- it only uses indentation as a structural cue
- unknown patterns are preserved as regular lines
- no input lines are dropped
§Example
use netform_ir::parse_generic;
let input = "interface Ethernet1\n description uplink\n";
let doc = parse_generic(input);
assert_eq!(doc.render(), input);Modules§
- detect
- Score-based dialect auto-detection from configuration text.
Structs§
- Block
Node - Structured block node with a header line and nested children.
- Document
- Lossless parsed document backed by an arena and root node list.
- Document
Metadata - Document metadata attached during parsing.
- Generic
Dialect - Conservative default dialect for vendor-agnostic parsing.
- IosKey
Hint Config - Configuration for
ios_family_key_hint, parameterizing the constructs that differ across IOS-family dialects while sharing the common structure. - IosLike
Dialect - Parameterized dialect for IOS-like configuration text (EOS, IOS XE, NX-OS, …).
- Line
Node - Leaf node preserving original raw text and parse metadata for one line.
- NodeId
- Stable arena identifier for a node in a
Document. - Parse
Finding - Parser-level uncertainty note attached to a source span.
- Parsed
Line Parts - Minimal tokenized representation of a content line.
- Path
- Location path used by diffs and diagnostics (
root_index, then child indices). - Span
- Source span pointing to a single line and byte range in the original input.
Enums§
- Dialect
Hint - Declared parser dialect used for this document.
- Node
- Arena node variant.
- Trivia
Kind - Lightweight classification used by parser, normalization, and diff views.
Traits§
- Dialect
- Dialect extension point for trivia classification and line tokenization.
Functions§
- classify_
ios_ like_ trivia - Classify trivia for IOS-like dialects (EOS, IOS XE).
- classify_
trivia_ with_ prefixes - Classify a line as blank, comment, or content based on the given comment prefixes.
- common_
key_ hint - Derive a stable identity key for constructs shared across all IOS-like dialects (EOS, IOS XE, NX-OS).
- count_
indent - Count the visual indentation width of a line, treating tabs as 4 spaces.
- ios_
family_ key_ hint - Derive a key hint for constructs shared across IOS-family dialects.
- ios_
like_ key_ hint - Derive a stable identity key for IOS-like configuration lines.
- parse_
generic - Parse input using the built-in generic dialect.
- parse_
interface - Parse an interface name into
(canonical_type, id)using the given type prefix table. - parse_
ios_ like_ parts - Tokenize a content line for IOS-like dialects (EOS, IOS XE).
- parse_
with_ dialect - Parse input into a lossless IR using the given dialect implementation.
- tokenize
- Tokenize a raw configuration line, splitting on whitespace while preserving
quoted strings. Characters in
punctuationare emitted as their own tokens (flushing any accumulated word first), matching the Junos-style brace/semicolon handling.