Struct OpenOptions
pub struct OpenOptions { /* private fields */ }
Expand description
Options and flags which can be used to configure how a file is opened.
This builder exposes the ability to configure how a File
is opened and
what operations are permitted on the open file. The File::open
and
File::create
methods are aliases for commonly used options using this
builder.
Generally speaking, when using OpenOptions
, you’ll first call
OpenOptions::new
, then chain calls to methods to set each option, then
call OpenOptions::open
, passing the path of the file you’re trying to
open. This will give you a io::Result
with a File
inside that you
can further operate on.
§Examples
Opening a file to read:
use tokio_uring::fs::OpenOptions;
fn main() -> Result<(), Box<dyn std::error::Error>> {
tokio_uring::start(async {
let file = OpenOptions::new()
.read(true)
.open("foo.txt")
.await?;