Skip to main content

Crate textfsm_core

Crate textfsm_core 

Source
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.
ValueDef
A Value definition from the template header.
ValueState
Runtime state for a single value.

Enums§

LineOp
Line operators control input line processing.
ListItem
A single item in a List value.
ParseError
Errors that occur during text parsing (runtime).
RecordOp
Record operators control output record handling.
TemplateError
Errors that occur when parsing a template file.
TextFsmError
Combined error type for public API.
Transition
State transition target.
Value
Runtime value during parsing.
ValueOption
Available options for Value definitions.

Type Aliases§

Result
Result type alias using TextFsmError.
ValueOptions
Set of options for a value.