pub struct Manifest {
pub manifest_file: ManifestFile,
pub data: Document,
}Expand description
Hold manifest data.
Fields§
§manifest_file: ManifestFilePath to Cargo.toml
data: DocumentStrict type of Cargo.toml manifest.
Implementations§
Source§impl Manifest
impl Manifest
Sourcepub fn data(&mut self) -> &mut Document
pub fn data(&mut self) -> &mut Document
Returns a mutable reference to the TOML document.
If the TOML document has not been loaded yet, this function will load it
by calling the load method. If loading fails, this function will panic.
§Returns
A mutable reference to the TOML document.
Sourcepub fn manifest_file(&self) -> &AbsolutePath
pub fn manifest_file(&self) -> &AbsolutePath
Returns path to Cargo.toml.
Sourcepub fn package_is(&self) -> bool
pub fn package_is(&self) -> bool
Check that the current manifest is the manifest of the package (can also be a virtual workspace).
Sourcepub fn local_is(&self) -> bool
pub fn local_is(&self) -> bool
Check that module is local.
The package is defined as local if the publish field is set to false or the registers are specified.
Sourcepub fn resolve_workspace_field(
&self,
field_name: &str,
) -> Result<String, ManifestError>
pub fn resolve_workspace_field( &self, field_name: &str, ) -> Result<String, ManifestError>
Resolves workspace-inherited field value.
When a package uses workspace inheritance (e.g., version.workspace = true),
this function locates the workspace root Cargo.toml and extracts the value
from [workspace.package] section.
§Arguments
field_name- Name of the field to resolve (e.g., “version”, “edition”, “license”)
§Returns
Returns the resolved field value as a string if found.
§Errors
Returns error if:
- Cannot locate workspace root manifest
- Cannot read workspace manifest file
- Field not found in workspace.package section
- Field value is not a string
Sourcepub fn version(&self) -> Result<String, ManifestError>
pub fn version(&self) -> Result<String, ManifestError>
Gets package version, handling both direct and workspace-inherited values.
This function properly resolves the version field whether it’s:
- A direct string value:
version = "0.2.0" - Workspace-inherited:
version.workspace = true
§Returns
Returns the version string if found.
§Errors
Returns error if:
- Version field is missing
- Version field has invalid format
- Workspace inheritance is declared but cannot be resolved
Trait Implementations§
Source§impl TryFrom<ManifestFile> for Manifest
impl TryFrom<ManifestFile> for Manifest
Source§type Error = ManifestError
type Error = ManifestError
Auto Trait Implementations§
impl Freeze for Manifest
impl RefUnwindSafe for Manifest
impl Send for Manifest
impl Sync for Manifest
impl Unpin for Manifest
impl UnwindSafe for Manifest
Blanket Implementations§
Source§impl<S> AssignWithType for S
impl<S> AssignWithType for S
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)Source§impl<C, E> EntryToVal<C> for Ewhere
C: Collection<Entry = E>,
impl<C, E> EntryToVal<C> for Ewhere
C: Collection<Entry = E>,
Source§type Val = <C as Collection>::Val
type Val = <C as Collection>::Val
Entry in complex collections.
For example, in a HashMap, while Entry might be a ( key, value ) tuple, Val might only be the value part.Source§fn entry_to_val(self) -> <E as EntryToVal<C>>::Val
fn entry_to_val(self) -> <E as EntryToVal<C>>::Val
Source§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
type Err = Infallible
fn into_result(self) -> Result<T, <T as IntoResult<T>>::Err>
Source§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
type Err = Infallible
fn into_result(self) -> Result<T, <T as IntoResult<T>>::Err>
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<Initial, Error, Final> TransitiveTryFrom<Error, Initial> for Final
impl<Initial, Error, Final> TransitiveTryFrom<Error, Initial> for Final
Source§impl<Error, Final, Initial> TransitiveTryInto<Error, Final> for Initial
impl<Error, Final, Initial> TransitiveTryInto<Error, Final> for Initial
Source§impl<C, Val> ValToEntry<C> for Valwhere
C: CollectionValToEntry<Val>,
impl<C, Val> ValToEntry<C> for Valwhere
C: CollectionValToEntry<Val>,
Source§fn val_to_entry(self) -> <C as CollectionValToEntry<Val>>::Entry
fn val_to_entry(self) -> <C as CollectionValToEntry<Val>>::Entry
Invokes the val_to_entry function of the CollectionValToEntry trait to convert the value to an entry.
Source§type Entry = <C as CollectionValToEntry<Val>>::Entry
type Entry = <C as CollectionValToEntry<Val>>::Entry
Entry is defined by the Collection trait.