pub struct DirBuilder { /* private fields */ }Expand description
A builder used to create directories in various manners, based on uring async operations.
This builder supports the Linux specific option mode and may support at in the future.
Implementations§
Source§impl DirBuilder
impl DirBuilder
Sourcepub fn new() -> DirBuilder
pub fn new() -> DirBuilder
Creates a new set of options with default mode/security settings for all platforms and also non-recursive.
§Examples
let builder = tokio_uring::fs::DirBuilder::new();Sourcepub fn recursive(&mut self, recursive: bool) -> &mut Self
pub fn recursive(&mut self, recursive: bool) -> &mut Self
Indicates that directories should be created recursively, creating all parent directories. Parents that do not exist are created with the same security and permissions settings.
This option defaults to false.
§Examples
let mut builder = tokio_uring::fs::DirBuilder::new();
builder.recursive(true);Sourcepub fn mode(&mut self, mode: u32) -> &mut Self
pub fn mode(&mut self, mode: u32) -> &mut Self
Sets the mode to create new directories with. This option defaults to 0o777.
This option defaults to 0o777.
§Examples
let mut builder = tokio_uring::fs::DirBuilder::new();
builder.mode(0o700);Sourcepub async fn create<P: AsRef<Path>>(&self, path: P) -> Result<()>
pub async fn create<P: AsRef<Path>>(&self, path: P) -> Result<()>
Creates the specified directory with the options configured in this builder.
It is considered an error if the directory already exists unless recursive mode is enabled.
§Examples
tokio_uring::start(async {
let path = "/tmp/foo/bar/baz";
tokio_uring::fs::DirBuilder::new()
.recursive(true)
.mode(0o700) // user-only mode: drwx------
.create(path).await.unwrap();
// TODO change with tokio_uring version
assert!(std::fs::metadata(path).unwrap().is_dir());
})