pub struct PersistAtomicError {
pub error: Error,
pub file: NamedTempFile,
}Expand description
Error returned by NamedTempFile::persist_atomic when the
atomic-persist sequence fails partway through.
The underlying io::Error is in PersistAtomicError::error
and the original NamedTempFile is in
PersistAtomicError::file, preserved so the caller can retry
or fall back to other cleanup logic without losing the source.
§Example
use mod_tempdir::{NamedTempFile, PersistAtomicError};
fn persist_or_log(f: NamedTempFile, target: &str) {
match f.persist_atomic(target) {
Ok(landed) => println!("persisted to {}", landed.display()),
Err(PersistAtomicError { error, file }) => {
eprintln!("persist failed: {error}");
// `file` is the original NamedTempFile, intact.
// It will be cleaned up on Drop, or you can retry.
drop(file);
}
}
}Fields§
§error: ErrorThe underlying I/O error that aborted the atomic persist.
file: NamedTempFileThe NamedTempFile that would have been moved, returned
intact so the caller can retry or drop it.
Trait Implementations§
Source§impl Debug for PersistAtomicError
impl Debug for PersistAtomicError
Source§impl Display for PersistAtomicError
impl Display for PersistAtomicError
Source§impl Error for PersistAtomicError
impl Error for PersistAtomicError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Source§impl From<PersistAtomicError> for Error
impl From<PersistAtomicError> for Error
Source§fn from(e: PersistAtomicError) -> Self
fn from(e: PersistAtomicError) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for PersistAtomicError
impl !RefUnwindSafe for PersistAtomicError
impl Send for PersistAtomicError
impl Sync for PersistAtomicError
impl Unpin for PersistAtomicError
impl UnsafeUnpin for PersistAtomicError
impl !UnwindSafe for PersistAtomicError
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