Struct tracing::stdlib::fs::DirBuilder
1.6.0 · source · pub struct DirBuilder {
inner: DirBuilder,
recursive: bool,
}
Expand description
A builder used to create directories in various manners.
This builder also supports platform-specific options.
Fields§
§inner: DirBuilder
§recursive: bool
Implementations§
source§impl DirBuilder
impl DirBuilder
1.6.0 · 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
use std::fs::DirBuilder;
let builder = DirBuilder::new();
1.6.0 · sourcepub fn recursive(&mut self, recursive: bool) -> &mut DirBuilder
pub fn recursive(&mut self, recursive: bool) -> &mut DirBuilder
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
use std::fs::DirBuilder;
let mut builder = DirBuilder::new();
builder.recursive(true);
1.6.0 · sourcepub fn create<P>(&self, path: P) -> Result<(), Error>
pub fn create<P>(&self, path: P) -> Result<(), Error>
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
use std::fs::{self, DirBuilder};
let path = "/tmp/foo/bar/baz";
DirBuilder::new()
.recursive(true)
.create(path).unwrap();
assert!(fs::metadata(path).unwrap().is_dir());
Trait Implementations§
1.6.0 · source§impl Debug for DirBuilder
impl Debug for DirBuilder
1.6.0 · source§impl DirBuilderExt for DirBuilder
impl DirBuilderExt for DirBuilder
Auto Trait Implementations§
impl Freeze for DirBuilder
impl RefUnwindSafe for DirBuilder
impl Send for DirBuilder
impl Sync for DirBuilder
impl Unpin for DirBuilder
impl UnwindSafe for DirBuilder
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more