Struct tempdir::TempDir [] [src]

pub struct TempDir {
    // some fields omitted
}

A wrapper for a path to temporary directory implementing automatic scope-based deletion.

Methods

impl TempDir
[src]

fn new_in<P: AsRef<Path>>(tmpdir: P, prefix: &str) -> Result<TempDir>

Attempts to make a temporary directory inside of tmpdir whose name will have the prefix prefix. The directory will be automatically deleted once the returned wrapper is destroyed.

If no directory can be created, Err is returned.

fn new(prefix: &str) -> Result<TempDir>

Attempts to make a temporary directory inside of env::temp_dir() whose name will have the prefix prefix. The directory will be automatically deleted once the returned wrapper is destroyed.

If no directory can be created, Err is returned.

fn into_path(self) -> PathBuf

Unwrap the wrapped std::path::Path from the TempDir wrapper. This discards the wrapper so that the automatic deletion of the temporary directory is prevented.

fn path(&self) -> &Path

Access the wrapped std::path::Path to the temporary directory.

fn close(self) -> Result<()>

Close and remove the temporary directory

Although TempDir removes the directory on drop, in the destructor any errors are ignored. To detect errors cleaning up the temporary directory, call close instead.

Trait Implementations

impl Drop for TempDir
[src]

fn drop(&mut self)

A method called when the value goes out of scope. Read more