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: PathBufCanonical selected source root; source-root aliases are resolved by callers.
root_identity: HandleRetained root object, preventing reuse of its old filesystem identity.
directory: PathBufAdmitted 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: StateAdmissionThe concrete operation boundary, never a process-global routing setting.
Implementations§
Source§impl ProjectStateGuard
impl ProjectStateGuard
Sourcepub(crate) fn preflight(
root: &Path,
database: Option<&Path>,
config: Option<&Path>,
) -> Result<Self>
pub(crate) fn preflight( root: &Path, database: Option<&Path>, config: Option<&Path>, ) -> Result<Self>
Inspect automatic destinations without creating files or SQLite sidecars.
Sourcepub(crate) fn preflight_database_path(
database: &Path,
selected_root: &Path,
) -> Result<Option<Self>>
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.
Sourcepub(crate) fn preflight_database_reset_path(
database: &Path,
selected_root: &Path,
) -> Result<Option<Self>>
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.
Sourcepub(crate) fn preflight_document(
root: &Path,
path: &Path,
) -> Result<Option<Self>>
pub(crate) fn preflight_document( root: &Path, path: &Path, ) -> Result<Option<Self>>
Admit one fixed document while preserving custom/external operator paths.
Sourcefn admit(
root: &Path,
database: Option<&Path>,
config: Option<&Path>,
admission: StateAdmission,
) -> Result<Self>
fn admit( root: &Path, database: Option<&Path>, config: Option<&Path>, admission: StateAdmission, ) -> Result<Self>
Capture the exact filesystem owner for one operation role.
Sourcepub(crate) fn sqlite_path(&self) -> Option<&Path>
pub(crate) fn sqlite_path(&self) -> Option<&Path>
Return the admitted SQLite spelling; Windows managed aliases share one cohort.
Sourcepub(crate) fn alternate_reset_paths(&self) -> Result<Vec<PathBuf>>
pub(crate) fn alternate_reset_paths(&self) -> Result<Vec<PathBuf>>
Enumerate only proven alternate recovery entries for an explicit reset.
Sourcepub(crate) fn verify(&self) -> Result<()>
pub(crate) fn verify(&self) -> Result<()>
Recheck the admitted objects and every automatic host/database output.
Sourcefn verify_directories(&self) -> Result<()>
fn verify_directories(&self) -> Result<()>
Check only retained directory objects, including before staging cleanup.
Sourcepub(crate) fn ensure_directory(&mut self) -> Result<()>
pub(crate) fn ensure_directory(&mut self) -> Result<()>
Create only the admitted direct state directory and retain its object.
Sourcepub(crate) fn write_generated(&self, path: &Path, bytes: &[u8]) -> Result<()>
pub(crate) fn write_generated(&self, path: &Path, bytes: &[u8]) -> Result<()>
Publish a generated entry without writing through an existing file alias.
Sourcepub(crate) fn write_new(&self, path: &Path, bytes: &[u8]) -> Result<()>
pub(crate) fn write_new(&self, path: &Path, bytes: &[u8]) -> Result<()>
Publish defaults without exposing partial bytes or replacing existing data.
Sourcepub(crate) fn write_document(&mut self, bytes: &[u8]) -> Result<()>
pub(crate) fn write_document(&mut self, bytes: &[u8]) -> Result<()>
Replace only the exact admitted document, preserving existing permissions.
Sourcepub(crate) fn create_document(&mut self, bytes: &[u8]) -> Result<bool>
pub(crate) fn create_document(&mut self, bytes: &[u8]) -> Result<bool>
Atomically create an admitted document, reporting a racing existing entry.
Sourcefn document_path(&self) -> Result<&Path>
fn document_path(&self) -> Result<&Path>
Keep document publication bound to its constructor-selected target.
Sourcepub(crate) fn owns_entry(&self, path: &Path) -> Result<bool>
pub(crate) fn owns_entry(&self, path: &Path) -> Result<bool>
Compare actual parent owners while preserving selected path spelling.
Sourcefn publish(
&self,
path: &Path,
bytes: &[u8],
publication: FilePublication,
before_publication: impl FnOnce() -> Result<()>,
) -> Result<bool>
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.
Sourcefn publish_with_stage_check(
&self,
path: &Path,
bytes: &[u8],
publication: FilePublication,
stage_check: impl FnOnce(&NamedTempFile) -> Result<()>,
before_publication: impl FnOnce() -> Result<()>,
) -> Result<bool>
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.
Sourcefn verify_staging_file(
&self,
temporary: &NamedTempFile,
directory_identity: &Handle,
) -> Result<()>
fn verify_staging_file( &self, temporary: &NamedTempFile, directory_identity: &Handle, ) -> Result<()>
Bind path-based metadata, publication and cleanup to the retained file.
Sourcefn discard_staging_probe(
&self,
temporary: NamedTempFile,
directory_identity: &Handle,
) -> Result<()>
fn discard_staging_probe( &self, temporary: NamedTempFile, directory_identity: &Handle, ) -> Result<()>
Retain file authority even when an explicit probe unlink fails.
Sourcefn verify_staging_entry(
&self,
path: &Path,
file: &File,
directory_identity: &Handle,
) -> Result<()>
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.
Sourcefn staging_failure(
&self,
temporary: &mut NamedTempFile,
operation: Error,
directory_identity: &Handle,
) -> Error
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§
impl Freeze for ProjectStateGuard
impl RefUnwindSafe for ProjectStateGuard
impl Send for ProjectStateGuard
impl Sync for ProjectStateGuard
impl Unpin for ProjectStateGuard
impl UnsafeUnpin for ProjectStateGuard
impl UnwindSafe for ProjectStateGuard
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<'a, T> FromIn<'a, T> for T
impl<'a, T> FromIn<'a, T> for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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