[−][src]Struct drop_dir::DropDir
Represents a Directory that will be automatically deleted when it goes out of scope.
Example
use std::path::PathBuf; use drop_dir::DropDir; use std::fs::File; let drop_dir = DropDir::new(PathBuf::from("/tmp/some/path")).unwrap(); let mut file = File::create(drop_dir.path().join("file.txt")).unwrap(); // drop_dir deleted when it goes out of scope.
Limitation
In the example above, only the last component of the drop_dir
is removed.
That is, the dir /tmp/some/temp/path
is deleted, but /tmp/some/temp
remains.
Any other behavior would get complicated.
Methods
impl DropDir
[src]
pub fn new(path_buf: PathBuf) -> Result<DropDir, Error>
[src]
new
Constructs a new DropDir object from a PathBuf.
Creates the directory at PathBuf if it does not exist (using fs::create_dir_all
).
Example
let drop_dir = DropDir::new(PathBuf::from("/tmp/some/path")).unwrap();
pub fn path(&self) -> PathBuf
[src]
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for DropDir
impl Send for DropDir
impl Sync for DropDir
impl Unpin for DropDir
impl UnwindSafe for DropDir
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,