Expand description
High-level filesystem operations using io_uring.
This module provides convenience functions that mirror std::fs, but use io_uring for async I/O.
All functions use the global default ring.
§Example
ⓘ
use uring_file::fs::{self, OpenOptions};
#[tokio::main]
async fn main() -> std::io::Result<()> {
// Read entire file
let contents = fs::read_to_string("/etc/hostname").await?;
println!("Hostname: {}", contents.trim());
// Write to file
fs::write("/tmp/hello.txt", b"Hello, world!").await?;
// Open with options
let file = OpenOptions::new()
.read(true)
.write(true)
.create(true)
.open("/tmp/data.bin")
.await?;
// Create directory tree
fs::create_dir_all("/tmp/a/b/c").await?;
// Remove directory tree
fs::remove_dir_all("/tmp/a").await?;
Ok(())
}Structs§
- Open
Options - Options for opening files, mirroring
std::fs::OpenOptions.
Functions§
- append
- Append data to a file, creating it if it doesn’t exist.
- copy
- Copy the contents of one file to another.
- create
- Create a file for writing, truncating if it exists.
- create_
dir - Create a directory.
- create_
dir_ all - Create a directory and all parent directories.
- exists
- Check if a path exists.
- hard_
link - Create a hard link.
- metadata
- Get metadata for a file or directory.
- open
- Open a file in read-only mode.
- read
- Read the entire contents of a file into a byte vector.
- read_
to_ string - Read the entire contents of a file into a string.
- remove_
dir - Remove an empty directory.
- remove_
dir_ all - Remove a directory and all its contents recursively.
- remove_
file - Remove a file.
- rename
- Rename a file or directory.
- symlink
- Create a symbolic link.
- truncate
- Truncate a file to the specified length.
- write
- Write data to a file, creating it if it doesn’t exist, truncating it if it does.