file_editor/lib.rs
1//! # file-editor
2//! **Fluent, chain-friendly text-file editing for Rust (edition 2024)**
3//!
4//! ---
5//! ## Quick taste
6//! ```no_run
7//! use file_editor::Editor;
8//!
9//! fn main() -> std::io::Result<()> {
10//! Editor::create("demo.txt")? // create or truncate
11//! .append("world\n")
12//! .prepend("hello ")
13//! .insert_after("hello", " Rustaceans!\n", false)
14//! .save()?; // flush to disk
15//! Ok(())
16//! }
17//! ```
18//!
19//! ---
20//! ## Opt-in **regex** power
21//! The default build is **zero-dependency**.
22//! Enable the feature below to pass a compiled `regex::Regex` anywhere a pattern is accepted.
23//!
24//! ```toml
25//! file-editor = { version = "0.2", features = ["regex"] }
26//! ```
27//!
28//! ```ignore
29//! use file_editor::Editor;
30//! use regex::Regex;
31//!
32//! fn main() -> std::io::Result<()> {
33//! let re = Regex::new(r"token=\w+")?; // redact secrets
34//! Editor::open("config.env")?
35//! .mask(&re, "***")
36//! .save()?;
37//! Ok(())
38//! }
39//! ```
40//!
41//! ---
42//! **See [`Editor`] for the complete API and method-by-method examples.**
43
44mod editor;
45mod pattern;
46pub mod utils;
47
48pub use editor::Editor;