Skip to main content

ModuleProject

Struct ModuleProject 

Source
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

Source

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

Source

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.

Source

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.

Source

pub fn root(&self) -> &Path

Returns the directory containing the loaded module.json.

Source

pub fn manifest_path(&self) -> &Path

Returns the exact module.json path that loaded this project.

Source

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.

Source

pub fn document(&self) -> &ManifestDocument

Returns the lossless module.json document loaded from Self::manifest_path.

Source

pub fn manifest(&self) -> &Manifest

Returns the validated manifest view of the current module.json document.

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> ModuleProject

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 ModuleProject

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> Same for T

Source§

type Output = T

Should always be Self
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, <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.