Crates.io | fileio |
lib.rs | fileio |
version | 0.1.0 |
created_at | 2025-09-25 11:10:59.794185+00 |
updated_at | 2025-09-25 11:10:59.794185+00 |
description | Fluent file I/O crate for Rust: read/write/append lines easily, including write_line functionality |
homepage | |
repository | https://github.com/lilcloudcoder/fileio |
max_upload_size | |
id | 1854486 |
size | 6,213 |
Fluent file operations in Rust: read, write, append, replace, or insert lines easily.
.read_all()
→ Read entire file as a String.read_lines()
→ Read file line by line.append(content)
→ Append a line at the end.write(content)
→ Overwrite the whole file.write_line(line_number, content)
→ Replace a specific line.insert_line(line_number, content)
→ Insert a line without overwritingAdd to your Cargo.toml
:
[dependencies]
fileio = "...."
use fileio::file;
fn main() {
let f = file("/full/path/to/file/example.txt");
// Append a line
f.append("This is a new line!").unwrap();
// Replace line 2
f.write_line(2, "Updated line 2").unwrap();
// Insert a line at line 1
f.insert_line(1, "Inserted line 1").unwrap();
// Read and print all lines
for line in f.read_lines().unwrap() {
println!("{}", line);
}
// Read the entire file as string
let content = f.read_all().unwrap();
println!("Whole file:\n{}", content);
}