fileio 0.1.0

Fluent file I/O crate for Rust: read/write/append lines easily, including write_line functionality
Documentation
  • Coverage
  • 90.91%
    10 out of 11 items documented1 out of 10 items with examples
  • Size
  • Source code size: 5.74 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.33 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 13s Average build duration of successful builds.
  • all releases: 8s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • ThatOneGlitchedGuy

FileIO

Fluent file operations in Rust: read, write, append, replace, or insert lines easily.

Features

  • .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 overwriting

Installation

Add to your Cargo.toml:

[dependencies]
fileio = "...."

Usage:

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);
}