Skip to main content

Staged

Struct Staged 

Source
pub struct Staged { /* private fields */ }
Expand description

A body written to a sibling temporary file, not yet in place.

The two-phase shape exists so a multi-file install is all-or-nothing at the only point where that is achievable. Guarding four paths and then writing four files leaves a window in which the third write fails and the repository holds two new dispatchers and two old ones — the state bake_repo_hooks’s own comment claims to prevent and did not. Staging all four first moves every failure that can be anticipated (no space, no permission, a read-only directory) BEFORE the first destination is touched.

It is not a transaction and does not pretend to be: commit_all can still fail on its third rename. What it gives is that the failure is reported with the exact list of what landed and what did not, instead of a count.

Implementations§

Source§

impl Staged

Source

pub fn dest(&self) -> &Path

Source

pub fn tmp(&self) -> &Path

Trait Implementations§

Source§

impl Debug for Staged

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Staged

A staged file that never landed is litter in somebody’s .git/hooks, where it is both confusing and — being executable and named like a hook — worth not leaving. Drop runs on the early return from commit_all and on any ? between stage and commit_all.

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.