textfsm-rs
A robust, performant, and safe Rust implementation of TextFSM. This library is designed to parse semi-structured text—specifically output from networking device CLI commands—into structured programmatic data (JSON, YAML, or Rust HashMaps).
Why textfsm-rs?
- Blazing Fast: Optimized for high-throughput parsing with minimal memory allocations.
- Safe by Design: Written in 100% safe Rust, replacing Python's runtime errors with compile-time checks and graceful
Resulthandling. - NTC-Templates Compatible: Designed to work out-of-the-box with the massive library of templates from ntc-templates.
- Modern Tooling: Seamless integration with
serdefor serialization andpestfor reliable template parsing.
Features
- Full TextFSM Specification: Support for
Valuedefinitions (Filldown, Key, Required, List, Fillup), States, Rules, and Transitions. - Advanced Regex: Uses
fancy-regexto support Python-style features like lookahead and lookbehind. - Automatic Template Selection: Built-in
CliTablelogic to automatically select the right template based on device platform and command. - Zero-Panic: Library code avoids
unwrap()andpanic!, ensuring your automation tools stay up.
Installation
Add this to your Cargo.toml:
[]
= { = "https://github.com/itsvrushabh/textfsm-rs.git" }
= { = "1.0", = ["derive"] }
Quick Start
use ;
CLI Usage
You can use textfsm-rs as a standalone command-line tool.
Installation
Commands
Parse a single file:
Auto-detect template (using ntc-templates index):
Advanced: Automated Template Mapping
Using the ntc-templates index style:
use CliTable;
Documentation
- Usage Guide - Detailed examples and API usage.
- Creating Templates - Syntax guide for writing .textfsm files.
- Advanced Examples - Patterns for complex parsing scenarios.
- Common Capture Groups - Reference for standard variable names.
- Architecture - Deep dive into internal implementation and optimizations.
Contributing
Contributions are welcome! Please ensure all tests pass:
License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.