pub struct SetupTransaction { /* private fields */ }Expand description
A staged multi-file write that either fully applies or fully rolls back.
Stage every file the setup step intends to write, then call commit. If
any single write fails, every already-applied write in the transaction is
restored to its pre-commit contents (or removed if it did not previously
exist), and the original error is returned. A transaction that is dropped
without committing leaves the filesystem untouched.
Implementations§
Source§impl SetupTransaction
impl SetupTransaction
Sourcepub fn stage(
&mut self,
path: impl Into<PathBuf>,
bytes: impl Into<Vec<u8>>,
) -> &mut Self
pub fn stage( &mut self, path: impl Into<PathBuf>, bytes: impl Into<Vec<u8>>, ) -> &mut Self
Stage bytes to be written to path on commit.
Staging touches nothing on disk. A later stage for the same path replaces an earlier one, so a step can revise its intended output before committing.
Sourcepub fn stage_json<T: Serialize>(
&mut self,
path: impl Into<PathBuf>,
value: &T,
) -> Result<&mut Self>
pub fn stage_json<T: Serialize>( &mut self, path: impl Into<PathBuf>, value: &T, ) -> Result<&mut Self>
Stage value serialized as pretty JSON (with trailing newline).
Trait Implementations§
Source§impl Debug for SetupTransaction
impl Debug for SetupTransaction
Source§impl Default for SetupTransaction
impl Default for SetupTransaction
Source§fn default() -> SetupTransaction
fn default() -> SetupTransaction
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for SetupTransaction
impl RefUnwindSafe for SetupTransaction
impl Send for SetupTransaction
impl Sync for SetupTransaction
impl Unpin for SetupTransaction
impl UnsafeUnpin for SetupTransaction
impl UnwindSafe for SetupTransaction
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