pub struct TempDir { /* private fields */ }Expand description
A securely-created temporary directory.
Call cleanup() to remove the directory. If dropped
without calling cleanup(), a best-effort removal is attempted.
use openjd_sessions::TempDir;
let dir = tempfile::tempdir().unwrap();
let mut td = TempDir::new(Some(dir.path()), Some("test-"), None).unwrap();
assert!(td.path().exists());
td.cleanup().unwrap();
assert!(!td.path().exists());Implementations§
Source§impl TempDir
impl TempDir
Sourcepub fn new(
dir: Option<&Path>,
prefix: Option<&str>,
_user: Option<&dyn SessionUser>,
) -> Result<Self, SessionError>
pub fn new( dir: Option<&Path>, prefix: Option<&str>, _user: Option<&dyn SessionUser>, ) -> Result<Self, SessionError>
Create a new secure temp directory.
dir: parent directory (defaults toopenjd_temp_dir(None))prefix: optional name prefixuser: optional session user for cross-user ownership
pub fn path(&self) -> &Path
Sourcepub fn cleanup(&mut self) -> Result<(), SessionError>
pub fn cleanup(&mut self) -> Result<(), SessionError>
Remove the directory and all contents.
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 UnsafeUnpin 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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more