Expand description
§XIO - Extended I/O Operations Library
xio is a library that provides extended I/O operations and utilities for file system manipulation,
with a focus on asynchronous operations using Tokio. The library offers functionality for:
- Directory traversal with customizable filters
- File reading and writing operations
- Specialized Rust file processing
- File system utilities for common operations
§Features
- Asynchronous file operations using Tokio
- Directory walking with customizable filters (hidden files, git directories, etc.)
- Specialized handling for Rust source files
- Batch file processing capabilities
- Integration with external tools (e.g., Neovim)
- Configurable logging with different verbosity levels
§Logging Configuration
The library uses the log crate for logging. To configure logging in your application:
use env_logger::{Builder, Env};
use log::info;
// Set RUST_LOG environment variable to configure logging level
// Examples:
// export RUST_LOG=xio=debug # Show all debug messages from xio
// export RUST_LOG=xio=info # Show only info and above from xio
// export RUST_LOG=xio=warn # Show only warnings and errors from xio
// Initialize logging in your application
Builder::from_env(Env::default())
.filter_module("xio", log::LevelFilter::Info) // Default level
.init();§Example
use std::path::Path;
use xio::{walk_directory, anyhow};
use log::info;
async fn process_txt_files() -> anyhow::Result<()> {
walk_directory("./", "txt", |path| {
let path = path.to_path_buf();
async move {
info!("Processing: {}", path.display());
Ok(())
}
}).await
}Re-exports§
pub use split::DirectorySplitter;pub use split::FileMatcher;pub use split::RegexFileMatcher;pub use split::SplitConfig;pub use anyhow;pub use log;pub use walkdir;
Modules§
- fs
- File system utility functions for working with files and directories.
- io
- Traits, helpers, and type definitions for core I/O functionality.
- split
Structs§
- Arc
- A thread-safe reference-counting pointer. ‘Arc’ stands for ‘Atomically Reference Counted’.
- Path
- A slice of a path (akin to
str). - PathBuf
- An owned, mutable path (akin to
String).
Functions§
- check_
file_ for_ multiple_ lines - Processes a file and adds it to a list if it contains multiple lines.
- delete_
files_ with_ extension - Deletes files with a specific extension in a directory and its subdirectories.
- is_
git_ dir - Determines if a directory entry is a git repository directory.
- is_
hidden - Determines if a directory entry is hidden.
- is_
target_ dir - Determines if a directory entry is a target directory.
- open_
files_ in_ neovim - Opens a list of files in Neovim or a specified editor.
- process_
file - Process a file with the given function.
- process_
rust_ file - Process a Rust file and check for pedantic warnings.
- read_
file_ content - Reads the entire content of a file into a string.
- read_
lines - Reads all lines from a file at the given path.
- walk_
directory - Walks through a directory and asynchronously processes files with a specific extension.
- walk_
rust_ files - Walks through Rust files in a directory and applies a callback function to each file.
- write_
to_ file - Writes content to a file at the specified path.