| Crates.io | get-file-size |
| lib.rs | get-file-size |
| version | 0.1.2 |
| created_at | 2025-02-09 03:18:04.195103+00 |
| updated_at | 2025-07-12 22:43:43.324048+00 |
| description | Rust crate for asynchronous file size retrieval and line counting, utilizing the tokio runtime for non-blocking I/O operations. |
| homepage | |
| repository | https://github.com/klebs6/klebs-general |
| max_upload_size | |
| id | 1548619 |
| size | 33,024 |
get-file-size is a Rust crate for efficiently determining the size of a file and counting the number of lines within a file asynchronously. This utility is particularly useful in systems where I/O operations need to be non-blocking, elevating performance in concurrent applications or environments where swift, streamlined file operations are essential.
Asynchronous File Size Retrieval: Implement utilizing the GetFileSize trait, which employs asynchronous methods to fetch file metadata, ensuring minimal blocking during operations.
Line Counting: An additional function, count_lines_in_file, provides the ability to count lines in a file asynchronously.
Integrate get-file-size into your project by adding it as a dependency in your Cargo.toml:
[dependencies]
get-file-size = "0.1.0"
use get_file_size::GetFileSize;
use std::path::PathBuf;
use tokio;
#[tokio::main]
async fn main() -> Result<(), get_file_size::FileError> {
let file_path = PathBuf::from("example.txt");
// Obtain file size asynchronously
let file_size = file_path.file_size().await?;
println!("File size: {} bytes", file_size);
// Count lines in file asynchronously
let line_count = get_file_size::count_lines_in_file(&file_path).await?;
println!("Line count: {}", line_count);
Ok(())
}
Contributions, bug reports, and feature requests are welcome. Please check the issues page to get involved.
This project is dual-licensed under the terms of the MIT license and the Apache License (Version 2.0).