Skip to main content

AppRoot

Struct AppRoot 

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

<Orthic Labs>/<App>, created private.

Implementations§

Source§

impl AppRoot

Source

pub fn new(suite: &Suite, app: &str) -> Result<AppRoot, AppRootError>

Source

pub fn name(&self) -> &str

Source

pub fn root(&self) -> &Path

Source

pub fn path(&self, rel: impl AsRef<Path>) -> Result<PathBuf, AppRootError>

<app root>/<rel> without creating anything. rel must be relative and made only of normal components (no .., ., root, prefix or empty); any existing ancestor that is a symlink must still resolve inside the app root.

Source

pub fn data_dir(&self, rel: impl AsRef<Path>) -> Result<PathBuf, AppRootError>

A private directory at <app root>/<rel>, created if absent.

Source

pub fn lock_writer(&self) -> Result<WriterLock, AppRootError>

Take the single-writer lock for this app root. Err(WriterBusy) if another holder lives.

Source

pub fn migrate_from(&self, src: &Path) -> Result<MigrationOutcome, AppRootError>

Copy the old root src into this app root, verify every byte, then commit. Restart-safe: files land under a temporary name and are renamed only when fully written; a rerun after any interruption re-copies missing or partial files, accepts files already identical, and refuses (never overwrites) a differing destination file. Directories, including empty ones, are migrated. The versioned state (MIGRATION_STATE) is Incomplete from before the destination is first touched until the copy is verified; the historical marker (MIGRATION_MARKER) is written last, and once present for this source the call is a no-op. src is never changed or deleted. Symlinks, junctions and special files in src are refused (strict); use AppRoot::migrate_from_with to opt in to links, ephemeral specials and skipped reparse points. Takes the writer lock.

Source

pub fn migrate_from_with( &self, src: &Path, opts: MigrateOptions, ) -> Result<MigrationReport, AppRootError>

AppRoot::migrate_from with opt-in behaviour. Lock, restart, collision handling and the marker-last ordering are the same in every mode; MigrateOptions::strict() is exactly migrate_from. See MigrateOptions for how links, ephemeral specials and reparse points are handled. Returns a MigrationReport (its outcome() is what migrate_from returns).

A required link that the destination cannot create returns the retryable AppRootError::link_not_created error and leaves the state Incomplete: the old tree is untouched, no historical marker exists, and the incomplete destination is never treated as migrated by this or an earlier version. A rerun finishes the copy. When the state is ReadyWithOmissions a rerun retries only the omitted links; it neither re-verifies files nor fails on files the app changed since.

Source

pub fn migration_state( &self, src: &Path, ) -> Result<Option<MigrationState>, AppRootError>

The completion state of the migration of src into this app root: None when no migration of src has started here (or src does not exist), otherwise what the last run left. Incomplete means the destination must not be used and the old root stays the authority. A historical marker written by an earlier version counts as Ready (as ReadyWithOmissions when it records "complete": false). A state file written by a newer version is an error (AppRootError::Io, InvalidData). Malformed metadata also fails rather than falling back to a historical marker. Takes no lock and changes nothing.

Source

pub fn migration_status( &self, src: &Path, ) -> Result<Option<MigrationStatus>, AppRootError>

Read persisted state & scope without taking a lock or changing files. Missing source or metadata returns None; valid metadata for another source also returns None. Malformed, unknown-version or invalid-scope metadata is an error, never evidence that a destination is untracked. A historical marker is consulted only when state is absent.

Trait Implementations§

Source§

impl Clone for AppRoot

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AppRoot

Source§

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

Formats the value using the given formatter. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.