Skip to main content

Staged

Struct Staged 

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

A private file beside a destination that parallel render workers may share (the CSS, a figure every page uses): written or converted there, then installed by one rename, so no reader sees a partial file and no writer touches another’s. Named .<stem>.tmp.<pid>.<seq>.<ext> (the stem bounded), its extension kept last for converters that read the format from it; registered with the watchdog’s exit sweep, and removed when dropped — after an install too, since a rename onto a hard link of the same file succeeds and leaves both names (POSIX rename(2); a destination an older binary hard-linked to a graphics-cache entry). A name some file already holds — a killed run’s leftover, perhaps a link to a cache entry, or a process with the same pid in another PID namespace sharing the cache — is skipped, never written through.

Implementations§

Source§

impl Staged

Source

pub fn beside(dest: &Path) -> Self

A fresh private path beside dest that no file holds, for a converter to write (nothing is created).

Source

pub fn alias(src: &Path) -> Result<Self>

A hard link to src, or a copy, under a short name in the temporary directory, lx.<pid>.<seq>.<ext> (the extension kept for converters that read the format from it): src’s bytes where its own path is out of reach.

Source

pub fn path(&self) -> &Path

Source

pub fn install(self, dest: &Path) -> Result<()>

Install the staged file as dest by rename. When the rename fails (Windows’ MoveFileExW refuses a file another worker holds open) but dest already holds these very bytes, a sibling installed the same output and the install stands; the bytes are compared before the temp is removed, so a stale file of the same length is never taken for it.

Trait Implementations§

Source§

impl Drop for Staged

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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.