pub struct ModuleProject { /* private fields */ }Expand description
A loaded module project rooted at an exact module.json path.
The project keeps the caller-selected manifest path, exposes the sibling
module-lock.json path even when the lockfile is absent, and keeps the
manifest in a lossless ManifestDocument so extension fields survive
future edits.
Implementations§
Source§impl ModuleProject
impl ModuleProject
Sourcepub fn validate(&self) -> Result<ContentHash, ProjectValidationError>
pub fn validate(&self) -> Result<ContentHash, ProjectValidationError>
Validates this project’s manifest-referenced files and content tree.
The returned digest can be reused for signature verification.
Source§impl ModuleProject
impl ModuleProject
Sourcepub fn load(path: impl Into<PathBuf>) -> Result<Self, ProjectError>
pub fn load(path: impl Into<PathBuf>) -> Result<Self, ProjectError>
Loads a project from the exact module.json path.
The returned value reloads this same path on later reads and derives
the sibling module-lock.json path beside it.
Sourcepub fn discover(start: &Path) -> Result<Option<Self>, ProjectError>
pub fn discover(start: &Path) -> Result<Option<Self>, ProjectError>
Discovers the nearest ancestor project starting from start.
This walks each ancestor directory, checking for module.json, and
stops at the first .git directory boundary. It returns Ok(None)
when no ancestor project exists before that boundary.
Sourcepub fn manifest_path(&self) -> &Path
pub fn manifest_path(&self) -> &Path
Returns the exact module.json path that loaded this project.
Sourcepub fn lockfile_path(&self) -> &Path
pub fn lockfile_path(&self) -> &Path
Returns the sibling module-lock.json path for this project.
The path is stable even when no lockfile exists yet.
Sourcepub fn document(&self) -> &ManifestDocument
pub fn document(&self) -> &ManifestDocument
Returns the lossless module.json document loaded from
Self::manifest_path.
Sourcepub fn manifest(&self) -> &Manifest
pub fn manifest(&self) -> &Manifest
Returns the validated manifest view of the current module.json
document.
Sourcepub fn reload(&mut self) -> Result<(), ProjectError>
pub fn reload(&mut self) -> Result<(), ProjectError>
Reloads the exact module.json path from disk.
This keeps the same project root and sibling lockfile path while replacing the in-memory manifest document with the latest bytes.
Sourcepub fn load_lockfile(&self) -> Result<Option<Lockfile>, ProjectError>
pub fn load_lockfile(&self) -> Result<Option<Lockfile>, ProjectError>
Loads the sibling module-lock.json when it exists.
See LockedLockfile::read for the locking and empty-file behavior.
Sourcepub fn write_manifest(
&self,
document: &ManifestDocument,
) -> Result<(), ProjectError>
pub fn write_manifest( &self, document: &ManifestDocument, ) -> Result<(), ProjectError>
Writes document to this project’s module.json.
The manifest is replaced by an atomic rename, so a reader sees either the previous file or the complete new one. No lock is taken, because a text editor or another tool may rewrite the manifest at any time; the last writer wins.
Trait Implementations§
Source§impl Clone for ModuleProject
impl Clone for ModuleProject
Source§fn clone(&self) -> ModuleProject
fn clone(&self) -> ModuleProject
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more