Struct fencryption_lib::tmp_dir::TmpDir
source · pub struct TmpDir(_);Expand description
TmpDir is a struct to manipulate a temporary directory.
The path argument in method that have it must be relative because it will be joined to the temporary directory path.
When this struct is dropped, the temporary directory is automatically deleted.
Implementations
sourceimpl TmpDir
impl TmpDir
pub fn new() -> Result<TmpDir, Error>
pub fn path(&self) -> PathBuf
sourcepub fn write_file<P, C>(&self, path: P, contents: C) -> Result<()>where
P: AsRef<Path>,
C: AsRef<[u8]>,
pub fn write_file<P, C>(&self, path: P, contents: C) -> Result<()>where
P: AsRef<Path>,
C: AsRef<[u8]>,
Writes to a file (or create it if it doesn’t exist) in the TmpDir. See std::fs::write.
sourcepub fn read_file<P>(&self, path: P) -> Result<Vec<u8>>where
P: AsRef<Path>,
pub fn read_file<P>(&self, path: P) -> Result<Vec<u8>>where
P: AsRef<Path>,
Reads a file from the TmpDir. See std::fs::read.
sourcepub fn create_dir<P>(&self, path: P) -> Result<()>where
P: AsRef<Path>,
pub fn create_dir<P>(&self, path: P) -> Result<()>where
P: AsRef<Path>,
Creates a directory. See std::fs::create_dir.
sourcepub fn create_dir_all<P>(&self, path: P) -> Result<()>where
P: AsRef<Path>,
pub fn create_dir_all<P>(&self, path: P) -> Result<()>where
P: AsRef<Path>,
Creates a directory and all of its parent if they are missing. See std::fs::create_dir_all.
sourcepub fn create_file<P>(&self, path: P) -> Result<File>where
P: AsRef<Path>,
pub fn create_file<P>(&self, path: P) -> Result<File>where
P: AsRef<Path>,
Creates a file in the TmpDir. See std::fs::File::create.
sourcepub fn open_file<P>(&self, path: P) -> Result<File>where
P: AsRef<Path>,
pub fn open_file<P>(&self, path: P) -> Result<File>where
P: AsRef<Path>,
Opens a file from the TmpDir. See std::fs::File::open.
sourcepub fn open_file_with_opts<P>(&self, opts: OpenOptions, path: P) -> Result<File>where
P: AsRef<Path>,
pub fn open_file_with_opts<P>(&self, opts: OpenOptions, path: P) -> Result<File>where
P: AsRef<Path>,
Opens a file from the TmpDir using the provided OpenOptions. See std::fs::OpenOptions::open.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for TmpDir
impl Send for TmpDir
impl Sync for TmpDir
impl Unpin for TmpDir
impl UnwindSafe for TmpDir
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more