Skip to main content

ProjectStateGuard

Struct ProjectStateGuard 

Source
pub(crate) struct ProjectStateGuard {
    root: PathBuf,
    root_identity: Handle,
    directory: PathBuf,
    directory_identity: Option<Handle>,
    automatic_database: Option<PathBuf>,
    automatic_document: Option<PathBuf>,
    admission: StateAdmission,
}
Expand description

Retain the admitted root and existing state-directory objects during writes.

These checks are repeated at mutation boundaries. They do not lock arbitrary ancestors against a hostile concurrent filesystem actor.

Fields§

§root: PathBuf

Canonical selected source root; source-root aliases are resolved by callers.

§root_identity: Handle

Retained root object, preventing reuse of its old filesystem identity.

§directory: PathBuf

Admitted publication directory: the root or its direct private directory.

§directory_identity: Option<Handle>

Existing state-directory object, when one was present at admission.

§automatic_database: Option<PathBuf>

Selected automatic database; external operator paths remain independent.

§automatic_document: Option<PathBuf>

Exact automatic document; explicit custom/external paths are not inferred.

§admission: StateAdmission

The concrete operation boundary, never a process-global routing setting.

Implementations§

Source§

impl ProjectStateGuard

Source

pub(crate) fn preflight( root: &Path, database: Option<&Path>, config: Option<&Path>, ) -> Result<Self>

Inspect automatic destinations without creating files or SQLite sidecars.

Source

pub(crate) fn preflight_database_path( database: &Path, selected_root: &Path, ) -> Result<Option<Self>>

Admit an exact managed database before even reading its stored root.

Arbitrary external DB names/locations remain operator-selected, including conventional-looking names under a different root. Resolve only the known selected root; resolving .projectatlas here would trust its alias.

Source

pub(crate) fn preflight_database_reset_path( database: &Path, selected_root: &Path, ) -> Result<Option<Self>>

Admit explicit reset without reading SQLite or refusing recoverable cohorts.

Source

pub(crate) fn preflight_document( root: &Path, path: &Path, ) -> Result<Option<Self>>

Admit one fixed document while preserving custom/external operator paths.

Source

fn admit( root: &Path, database: Option<&Path>, config: Option<&Path>, admission: StateAdmission, ) -> Result<Self>

Capture the exact filesystem owner for one operation role.

Source

pub(crate) fn sqlite_path(&self) -> Option<&Path>

Return the admitted SQLite spelling; Windows managed aliases share one cohort.

Source

pub(crate) fn alternate_reset_paths(&self) -> Result<Vec<PathBuf>>

Enumerate only proven alternate recovery entries for an explicit reset.

Source

pub(crate) fn verify(&self) -> Result<()>

Recheck the admitted objects and every automatic host/database output.

Source

fn verify_directories(&self) -> Result<()>

Check only retained directory objects, including before staging cleanup.

Source

pub(crate) fn ensure_directory(&mut self) -> Result<()>

Create only the admitted direct state directory and retain its object.

Source

pub(crate) fn write_generated(&self, path: &Path, bytes: &[u8]) -> Result<()>

Publish a generated entry without writing through an existing file alias.

Source

pub(crate) fn write_new(&self, path: &Path, bytes: &[u8]) -> Result<()>

Publish defaults without exposing partial bytes or replacing existing data.

Source

pub(crate) fn write_document(&mut self, bytes: &[u8]) -> Result<()>

Replace only the exact admitted document, preserving existing permissions.

Source

pub(crate) fn create_document(&mut self, bytes: &[u8]) -> Result<bool>

Atomically create an admitted document, reporting a racing existing entry.

Source

fn document_path(&self) -> Result<&Path>

Keep document publication bound to its constructor-selected target.

Source

pub(crate) fn owns_entry(&self, path: &Path) -> Result<bool>

Compare actual parent owners while preserving selected path spelling.

Source

fn publish( &self, path: &Path, bytes: &[u8], publication: FilePublication, before_publication: impl FnOnce() -> Result<()>, ) -> Result<bool>

Share atomic publication and a scoped failure boundary across file roles.

Source

fn publish_with_stage_check( &self, path: &Path, bytes: &[u8], publication: FilePublication, stage_check: impl FnOnce(&NamedTempFile) -> Result<()>, before_publication: impl FnOnce() -> Result<()>, ) -> Result<bool>

Observe the real protected stage through a local causal-test seam.

Source

fn verify_staging_file( &self, temporary: &NamedTempFile, directory_identity: &Handle, ) -> Result<()>

Bind path-based metadata, publication and cleanup to the retained file.

Source

fn discard_staging_probe( &self, temporary: NamedTempFile, directory_identity: &Handle, ) -> Result<()>

Retain file authority even when an explicit probe unlink fails.

Source

fn verify_staging_entry( &self, path: &Path, file: &File, directory_identity: &Handle, ) -> Result<()>

Verify a direct stage name against both retained directory and file objects.

Source

fn staging_failure( &self, temporary: &mut NamedTempFile, operation: Error, directory_identity: &Handle, ) -> Error

Never unlink a temporary pathname through a changed directory or file owner.

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.

§

impl<'a, T> FromIn<'a, T> for T

§

fn from_in(t: T, _: &'a Allocator) -> T

Converts to this type from the input type within the given allocator.
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<'a, T, U> IntoIn<'a, U> for T
where U: FromIn<'a, T>,

§

fn into_in(self, allocator: &'a Allocator) -> U

Converts this type into the (usually inferred) input type within the given allocator.
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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 = 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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more