pub struct TempDir {
pub path: PathBuf,
/* private fields */
}Fields§
§path: PathBufPath of the temporary directory.
Implementations§
Source§impl TempDir
impl TempDir
Sourcepub fn create<P: AsRef<Path>>(
&self,
filename: P,
content: &[u8],
) -> Result<String>
pub fn create<P: AsRef<Path>>( &self, filename: P, content: &[u8], ) -> Result<String>
Create a file in the temporary directory and return full path.
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Creates a new temporary directory.
This temporary directory and all the files it contains will be removed on drop.
The temporary directory name is constructed by using CARGO_PKG_NAME
followed by a dot and random alphanumeric characters.
§Examples
use threecpio::temp_dir::TempDir;
let tempdir = TempDir::new().unwrap();
println!("Temporary directory: {}", tempdir.path.display());Sourcepub fn new_and_set_current_dir() -> Result<Self>
pub fn new_and_set_current_dir() -> Result<Self>
Creates a new temporary directory and changes the current working directory to this directory.
This temporary directory and all the files it contains will be removed on drop. The current working directory will be set back on drop as well.
The temporary directory name is constructed by using CARGO_PKG_NAME
followed by a dot and random alphanumeric characters.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TempDir
impl RefUnwindSafe for TempDir
impl Send for TempDir
impl Sync for TempDir
impl Unpin for TempDir
impl UnwindSafe for TempDir
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