[][src]Struct vmm_sys_util::tempdir::TempDir

pub struct TempDir { /* fields omitted */ }

Wrapper over a temporary directory.

The directory will be maintained for the lifetime of the TempDir object.

Implementations

impl TempDir[src]

pub fn new_with_prefix<P: AsRef<OsStr>>(prefix: P) -> Result<TempDir>[src]

Creates a new temporary directory with prefix.

The directory will be removed when the object goes out of scope.

Examples

let t = TempDir::new_with_prefix("/tmp/testdir").unwrap();

pub fn new_in(path: &Path) -> Result<TempDir>[src]

Creates a new temporary directory with inside path.

The directory will be removed when the object goes out of scope.

Examples

let t = TempDir::new_in(Path::new("/tmp/")).unwrap();

pub fn new() -> Result<TempDir>[src]

Creates a new temporary directory with inside $TMPDIR if set, otherwise in /tmp.

The directory will be removed when the object goes out of scope.

Examples

let t = TempDir::new().unwrap();

pub fn remove(&self) -> Result<()>[src]

Removes the temporary directory.

Calling this is optional as when a TempDir object goes out of scope, the directory will be removed. Calling remove explicitly allows for better error handling.

Errors

This function can only be called once per object. An error is returned otherwise.

Examples

let temp_dir = TempDir::new_with_prefix("/tmp/testdir").unwrap();
temp_dir.remove().unwrap();

pub fn as_path(&self) -> &Path[src]

Returns the path to the tempdir.

Examples

let temp_dir = TempDir::new_with_prefix("/tmp/testdir").unwrap();
assert!(temp_dir.as_path().exists());

Trait Implementations

impl Drop for TempDir[src]

Auto Trait Implementations

impl RefUnwindSafe for TempDir

impl Send for TempDir

impl Sync for TempDir

impl Unpin for TempDir

impl UnwindSafe for TempDir

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.