pub struct File {
inner: NamedTempFile,
path: PathBuf,
}Expand description
A unique temporary file removed when dropped.
Fields§
§inner: NamedTempFile§path: PathBufImplementations§
Source§impl File
impl File
Sourcepub fn with_affixes(prefix: &str, suffix: &str) -> Result<Self>
pub fn with_affixes(prefix: &str, suffix: &str) -> Result<Self>
Create a unique temporary file with diagnostic filename affixes.
The file is removed when this guard is dropped.
Call Self::retain to preserve it as a regular open file.
§Errors
Returns a contextual error when the file cannot be created.
Sourcepub fn retain(self) -> Result<File>
pub fn retain(self) -> Result<File>
Retain the file after this temporary guard is consumed.
The returned open file owns its custom path context. Dropping that handle does not remove the filesystem entry. Its caller is responsible for eventual deletion.
§Errors
Returns a contextual error when the platform cannot retain the file.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for File
impl RefUnwindSafe for File
impl Send for File
impl Sync for File
impl Unpin for File
impl UnsafeUnpin for File
impl UnwindSafe for File
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