Skip to main content

Crate mi_simple_io

Crate mi_simple_io 

Source
Expand description

§mi-simple-io

Small synchronous IO utilities for common file and terminal workflows.

use mi_simple_io::{read_file, remove, write_file};

let file = std::env::temp_dir().join("mi_simple_io_doctest.txt");
write_file(&file, "hello")?;
assert_eq!(read_file(&file)?, "hello");
remove(&file)?;

Structs§

FileStats
Basic text file statistics.
TempFile
Temporary file removed when dropped.

Functions§

append_file
Append text to a file, creating it when missing.
clear_dir
Remove all directory contents while keeping the directory itself.
confirm
Ask a yes/no question and return the selected answer.
copy_file
Copy a file and return the number of bytes copied.
create_dir
Create a directory and any missing parents.
current_dir
Return the current working directory.
exists
Return whether a path exists.
file_extension
Return the lowercase file extension as UTF-8 lossy text, or an empty string.
file_size
Return file size in bytes.
file_stats
Read a text file and return basic statistics.
file_stem
Return the file stem as UTF-8 lossy text, or an empty string.
is_dir
Return whether a path is a directory.
is_file
Return whether a path is a regular file.
move_file
Move or rename a file or directory.
parse_confirmation
Parse confirmation text using a default for empty or unknown input.
read_all_lines
Read all lines from a file.
read_bytes
Read a file into bytes.
read_file
Read a UTF-8 text file into a string.
read_first_lines
Read the first n lines from a file.
read_input
Read a trimmed line from standard input after printing a prompt.
read_last_lines
Read the last n lines from a file.
read_lines
Read a file as a line iterator, preserving line read errors.
remove
Remove a file or directory tree.
safe_write
Write text via a sibling temporary file before replacing the destination.
temp_dir
Return the system temporary directory.
write_file
Write text to a file, replacing existing content.
write_or_append
Write text when the file is missing, otherwise append it.