Expand description
§TextFSM Core
Core parsing library for TextFSM template-based state machine.
This crate provides the core parsing functionality. For the user-facing API
with compile-time template validation macros, use the textfsm-rust crate.
§Quick Start
use textfsm_core::Template;
let template_str = r#"
Value Name (\S+)
Value Age (\d+)
Start
^Name: ${Name}, Age: ${Age} -> Record
"#;
let template = Template::parse_str(template_str).unwrap();
let mut parser = template.parser();
let input = "Name: Alice, Age: 30\nName: Bob, Age: 25\n";
let results = parser.parse_text(input).unwrap();
assert_eq!(results.len(), 2);§Features
serde- Enable serde deserialization support. Allows using [Parser::parse_text_into] to deserialize parsed results directly into typed Rust structs.
Structs§
- Parser
- Parser for processing text with a compiled template.
- Rule
- A rule within a state.
- State
- A state containing rules.
- Template
- Compiled template - immutable, can be shared across threads.
- Value
Def - A Value definition from the template header.
- Value
State - Runtime state for a single value.
Enums§
- LineOp
- Line operators control input line processing.
- List
Item - A single item in a List value.
- Parse
Error - Errors that occur during text parsing (runtime).
- Record
Op - Record operators control output record handling.
- Template
Error - Errors that occur when parsing a template file.
- Text
FsmError - Combined error type for public API.
- Transition
- State transition target.
- Value
- Runtime value during parsing.
- Value
Option - Available options for Value definitions.
Type Aliases§
- Result
- Result type alias using TextFsmError.
- Value
Options - Set of options for a value.