pub struct TempDirBuilder { /* private fields */ }Expand description
A builder for configuring and creating a TempDir.
Obtain one via TempDir::builder. The directory name is composed as
{prefix}{random}{suffix} with an unpredictable, collision-resistant random
core, created with an exclusive create.
§Example
let dir = TempDir::builder()
.prefix("workspace_")
.create()
.await?;
let name = dir.dir_path().file_name().unwrap().to_string_lossy().into_owned();
assert!(name.starts_with("workspace_"));Implementations§
Source§impl TempDirBuilder
impl TempDirBuilder
Sourcepub fn prefix<S: Into<String>>(self, prefix: S) -> Self
pub fn prefix<S: Into<String>>(self, prefix: S) -> Self
Sets the directory name prefix. Defaults to atmpd_.
Sourcepub fn suffix<S: Into<String>>(self, suffix: S) -> Self
pub fn suffix<S: Into<String>>(self, suffix: S) -> Self
Sets the directory name suffix. Defaults to empty.
Sourcepub fn dir<P: Into<PathBuf>>(self, root: P) -> Self
pub fn dir<P: Into<PathBuf>>(self, root: P) -> Self
Sets the root directory to create the directory in. Defaults to the
system temporary directory (std::env::temp_dir).
Trait Implementations§
Source§impl Clone for TempDirBuilder
impl Clone for TempDirBuilder
Source§fn clone(&self) -> TempDirBuilder
fn clone(&self) -> TempDirBuilder
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for TempDirBuilder
impl RefUnwindSafe for TempDirBuilder
impl Send for TempDirBuilder
impl Sync for TempDirBuilder
impl Unpin for TempDirBuilder
impl UnsafeUnpin for TempDirBuilder
impl UnwindSafe for TempDirBuilder
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