file-content 0.3.1

A library for working with files and common text data encodings.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use anyhow::anyhow;
use file_content::File;

fn main() -> anyhow::Result<()> {
    let file_path = std::env::args()
        .nth(1)
        .ok_or_else(|| anyhow!("Usage: read_file <file>"))?;

    let file: File = File::new_from_path(&file_path)?;

    println!("{:?}", file);

    let content_only: String = file_content::read_to_string(&file_path)?;

    println!("{content_only}");

    Ok(())
}