Struct TempDir
pub struct TempDir { /* private fields */ }std only.Expand description
Guard for a private temporary directory that removes it recursively on drop.
An outstanding anonymous-file job keeps the directory alive until it finishes.
Self::close runs explicit cleanup on the blocking pool and reports failures.
new and with_prefix generate an
unpredictable name below the platform temporary directory. create
accepts an exact caller-selected path. Creation is exclusive and uses
owner-only permissions on Unix, so an existing file, directory, or symlink
is never reused.
Implementations§
§impl TempDir
impl TempDir
pub async fn new() -> Result<TempDir, Error>
Available on crate features grpc and http only.
pub async fn new() -> Result<TempDir, Error>
grpc and http only.Create an unpredictably named private temporary directory below the platform temporary directory.
pub fn new_sync() -> Result<TempDir, Error>
Available on crate features grpc and http only.
pub fn new_sync() -> Result<TempDir, Error>
grpc and http only.Blocking counterpart to Self::new.
pub async fn with_prefix(prefix: impl AsRef<OsStr>) -> Result<TempDir, Error>
Available on crate features grpc and http only.
pub async fn with_prefix(prefix: impl AsRef<OsStr>) -> Result<TempDir, Error>
grpc and http only.Create an unpredictably named private temporary directory with
prefix below the platform temporary directory.
The prefix must be one ordinary path component. Creation is exclusive, so an existing file, directory, or symlink is never reused.
pub fn with_prefix_sync(prefix: impl AsRef<OsStr>) -> Result<TempDir, Error>
Available on crate features grpc and http only.
pub fn with_prefix_sync(prefix: impl AsRef<OsStr>) -> Result<TempDir, Error>
grpc and http only.Blocking counterpart to Self::with_prefix.
pub async fn with_prefix_in(
prefix: impl AsRef<OsStr>,
parent: impl AsRef<Path>,
) -> Result<TempDir, Error>
Available on crate features grpc and http only.
pub async fn with_prefix_in( prefix: impl AsRef<OsStr>, parent: impl AsRef<Path>, ) -> Result<TempDir, Error>
grpc and http only.Create an unpredictably named private temporary directory with the given
prefix below the existing parent. The prefix must be one ordinary path
component. A relative parent is resolved at creation time, so the guard
keeps referring to the same path if the working directory changes.
pub fn with_prefix_in_sync(
prefix: impl AsRef<OsStr>,
parent: impl AsRef<Path>,
) -> Result<TempDir, Error>
Available on crate features grpc and http only.
pub fn with_prefix_in_sync( prefix: impl AsRef<OsStr>, parent: impl AsRef<Path>, ) -> Result<TempDir, Error>
grpc and http only.Blocking counterpart to Self::with_prefix_in.
pub async fn anonymous_file(&self) -> Result<File, Error>
Available on crate features grpc and http only.
pub async fn anonymous_file(&self) -> Result<File, Error>
grpc and http only.Exclusively create an anonymous read/write file in this directory.
The operation requests removal before returning the open file. On Unix the file is unlinked immediately. On Windows the standard file sharing mode permits deletion, which completes when the last handle closes. Filesystems that reject removal of an open file return an error before the caller can write data.
pub fn anonymous_file_sync(&self) -> Result<File, Error>
Available on crate features grpc and http only.
pub fn anonymous_file_sync(&self) -> Result<File, Error>
grpc and http only.Blocking counterpart to Self::anonymous_file.
pub async fn create(path: impl Into<PathBuf>) -> Result<TempDir, Error>
Available on crate features grpc and http only.
pub async fn create(path: impl Into<PathBuf>) -> Result<TempDir, Error>
grpc and http only.Exclusively create and guard a temporary directory at path.
The guard retains its absolute path for cleanup.
pub fn create_sync(path: impl Into<PathBuf>) -> Result<TempDir, Error>
Available on crate features grpc and http only.
pub fn create_sync(path: impl Into<PathBuf>) -> Result<TempDir, Error>
grpc and http only.Blocking counterpart to Self::create.
pub fn path(&self) -> &Path
Available on crate features grpc and http only.
pub fn path(&self) -> &Path
grpc and http only.Return the guarded directory path.
pub async fn close(self) -> Result<(), Error>
Available on crate features grpc and http only.
pub async fn close(self) -> Result<(), Error>
grpc and http only.Remove the directory now and report any cleanup failure.
pub fn close_sync(self) -> Result<(), Error>
Available on crate features grpc and http only.
pub fn close_sync(self) -> Result<(), Error>
grpc and http only.Blocking counterpart to Self::close.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for TempDir
impl !UnwindSafe for TempDir
impl Forget for TempDir
impl Freeze for TempDir
impl Move for TempDir
impl Send for TempDir
impl Sync for TempDir
impl Unpin for TempDir
impl UnsafeUnpin for TempDirwhere
*const ArcInner<TempDirInner> is !null: UnsafeUnpin,
PhantomData<ArcInner<TempDirInner>>: UnsafeUnpin,
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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> ⓘ
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> ⓘ
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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a rama_grpc::Request§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy that returns Action::Follow only if self and other return
Action::Follow. Read more