pub struct AppRoot { /* private fields */ }Expand description
<Orthic Labs>/<App>, created private.
Implementations§
Source§impl AppRoot
impl AppRoot
pub fn new(suite: &Suite, app: &str) -> Result<AppRoot, AppRootError>
pub fn name(&self) -> &str
pub fn root(&self) -> &Path
Sourcepub fn path(&self, rel: impl AsRef<Path>) -> Result<PathBuf, AppRootError>
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.
Sourcepub fn data_dir(&self, rel: impl AsRef<Path>) -> Result<PathBuf, AppRootError>
pub fn data_dir(&self, rel: impl AsRef<Path>) -> Result<PathBuf, AppRootError>
A private directory at <app root>/<rel>, created if absent.
Sourcepub fn lock_writer(&self) -> Result<WriterLock, AppRootError>
pub fn lock_writer(&self) -> Result<WriterLock, AppRootError>
Take the single-writer lock for this app root. Err(WriterBusy) if another holder lives.
Sourcepub fn migrate_from(&self, src: &Path) -> Result<MigrationOutcome, AppRootError>
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.
Sourcepub fn migrate_from_with(
&self,
src: &Path,
opts: MigrateOptions,
) -> Result<MigrationReport, AppRootError>
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.
Sourcepub fn migration_state(
&self,
src: &Path,
) -> Result<Option<MigrationState>, AppRootError>
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.
Sourcepub fn migration_status(
&self,
src: &Path,
) -> Result<Option<MigrationStatus>, AppRootError>
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.