1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
//! # TextFSM
//!
//! A template-based state machine for parsing semi-formatted text.
//!
//! This is a Rust port of [Google's TextFSM](https://github.com/google/textfsm),
//! commonly used for parsing CLI output from network devices.
//!
//! ## Quick Start
//!
//! ```rust
//! use textfsm_rust::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);
//! ```
//!
//! ## Template Syntax
//!
//! Templates consist of two sections:
//!
//! 1. **Value definitions** at the top:
//! ```text
//! Value [Options] Name (regex)
//! ```
//! Options: `Required`, `Filldown`, `Fillup`, `Key`, `List`
//!
//! 2. **State definitions** below (separated by blank line):
//! ```text
//! StateName
//! ^pattern -> Action NewState
//! ```
//! Actions: `Next`, `Continue`, `Error`, `Record`, `Clear`, `Clearall`, `NoRecord`
//!
//! ## Compile-Time Template Validation
//!
//! Use the validation macros to catch template errors at compile time:
//!
//! ```rust,ignore
//! use textfsm_rust::{validate_template, validate_templates};
//!
//! // Validate a single template file
//! validate_template!("templates/cisco_show_version.textfsm");
//!
//! // Validate all .textfsm files in a directory
//! validate_templates!("templates/");
//! ```
//!
//! ## Serde Integration
//!
//! Enable the `serde` feature to deserialize parsed results directly into typed structs:
//!
//! ```toml
//! [dependencies]
//! textfsm-rust = { version = "0.1", features = ["serde"] }
//! ```
//!
//! ```rust,ignore
//! use textfsm_rust::{Deserialize, Template};
//!
//! #[derive(Deserialize, Debug)]
//! struct Interface {
//! interface: String,
//! status: String,
//! }
//!
//! let template = Template::parse_str(TEMPLATE)?;
//! let mut parser = template.parser();
//!
//! // Deserialize directly into typed structs
//! let interfaces: Vec<Interface> = parser.parse_text_into(input)?;
//! ```
//!
//! Field names are matched case-insensitively against template value names.
//!
//! ## Example Template
//!
//! ```text
//! Value Required Interface (\S+)
//! Value Filldown Status (up|down)
//! Value IPAddress (\d+\.\d+\.\d+\.\d+)
//!
//! Start
//! ^Interface: ${Interface} -> Continue
//! ^ Status: ${Status}
//! ^ IP: ${IPAddress} -> Record
//! ```
// Re-export everything from textfsm-core
pub use *;
// Re-export macros from textfsm-macros
pub use ;
// Re-export serde's Deserialize trait when serde feature is enabled
pub use Deserialize;