Struct cargo_toml::Manifest
source · pub struct Manifest<Metadata = Value> {Show 16 fields
pub package: Option<Package<Metadata>>,
pub workspace: Option<Workspace<Metadata>>,
pub dependencies: DepsSet,
pub dev_dependencies: DepsSet,
pub build_dependencies: DepsSet,
pub target: TargetDepsSet,
pub features: FeatureSet,
pub replace: DepsSet,
pub patch: PatchSet,
pub lib: Option<Product>,
pub profile: Profiles,
pub badges: Badges,
pub bin: Vec<Product>,
pub bench: Vec<Product>,
pub test: Vec<Product>,
pub example: Vec<Product>,
}
Expand description
The top-level Cargo.toml
structure
The Metadata
is a type for [package.metadata]
table. You can replace it with
your own struct type if you use the metadata and don’t want to use the catch-all Value
type.
Fields§
§package: Option<Package<Metadata>>
§workspace: Option<Workspace<Metadata>>
§dependencies: DepsSet
§dev_dependencies: DepsSet
§build_dependencies: DepsSet
§target: TargetDepsSet
§features: FeatureSet
§replace: DepsSet
patch: PatchSet
§lib: Option<Product>
Note that due to autolibs feature this is not the complete list
unless you run complete_from_path
profile: Profiles
§badges: Badges
§bin: Vec<Product>
Note that due to autobins feature this is not the complete list
unless you run complete_from_path
bench: Vec<Product>
§test: Vec<Product>
§example: Vec<Product>
Implementations§
source§impl Manifest<Value>
impl Manifest<Value>
sourcepub fn from_slice(cargo_toml_content: &[u8]) -> Result<Self, Error>
pub fn from_slice(cargo_toml_content: &[u8]) -> Result<Self, Error>
Parse contents of a Cargo.toml
file already loaded as a byte slice.
It does not call complete_from_path
, so may be missing implicit data.
source§impl<Metadata: for<'a> Deserialize<'a>> Manifest<Metadata>
impl<Metadata: for<'a> Deserialize<'a>> Manifest<Metadata>
sourcepub fn from_slice_with_metadata(
cargo_toml_content: &[u8]
) -> Result<Self, Error>
pub fn from_slice_with_metadata(
cargo_toml_content: &[u8]
) -> Result<Self, Error>
Parse Cargo.toml
, and parse its [package.metadata]
into a custom Serde-compatible type.package
It does not call complete_from_path
, so may be missing implicit data.
sourcepub fn from_path_with_metadata<P: AsRef<Path>>(
cargo_toml_path: P
) -> Result<Self, Error>
pub fn from_path_with_metadata<P: AsRef<Path>>(
cargo_toml_path: P
) -> Result<Self, Error>
Parse contents from Cargo.toml
file on disk, with custom Serde-compatible metadata type.
Calls [complete_from_path
]
sourcepub fn complete_from_path(&mut self, path: &Path) -> Result<(), Error>
pub fn complete_from_path(&mut self, path: &Path) -> Result<(), Error>
Cargo.toml
doesn’t contain explicit information about [lib]
and [[bin]]
,
which are inferred based on files on disk.
This scans the disk to make the data in the manifest as complete as possible.
It supports workspace inheritance and will search for a root workspace.
Use complete_from_path_and_workspace
to provide the workspace explicitly.
sourcepub fn complete_from_path_and_workspace<WorkspaceMetadataIgnored>(
&mut self,
package_manifest_path: &Path,
workspace_manifest_and_path: Option<(&Manifest<WorkspaceMetadataIgnored>, &Path)>
) -> Result<(), Error>
pub fn complete_from_path_and_workspace<WorkspaceMetadataIgnored>(
&mut self,
package_manifest_path: &Path,
workspace_manifest_and_path: Option<(&Manifest<WorkspaceMetadataIgnored>, &Path)>
) -> Result<(), Error>
[complete_from_path
], but allows passing workspace manifest explicitly.
workspace_manifest_and_path
is the root workspace manifest already parsed,
and the path is the path to the root workspace’s directory.
If it’s None
, the root workspace will be discovered automatically.
sourcepub fn complete_from_abstract_filesystem<WorkspaceMetadataIgnored, Fs: AbstractFilesystem>(
&mut self,
fs: Fs,
workspace_manifest_and_path: Option<(&Manifest<WorkspaceMetadataIgnored>, &Path)>
) -> Result<(), Error>
pub fn complete_from_abstract_filesystem<WorkspaceMetadataIgnored, Fs: AbstractFilesystem>(
&mut self,
fs: Fs,
workspace_manifest_and_path: Option<(&Manifest<WorkspaceMetadataIgnored>, &Path)>
) -> Result<(), Error>
Cargo.toml
doesn’t contain explicit information about [lib]
and [[bin]]
,
which are inferred based on files on disk.
You can provide any implementation of directory scan, which doesn’t have to be reading straight from disk (might scan a tarball or a git repo, for example).
If workspace_manifest_and_path
is set, it will inherit from this workspace.
If it’s None
, it will try to find a workspace if needed.
sourcepub fn inherit_workspace<Ignored>(
&mut self,
workspace_manifest: &Manifest<Ignored>,
workspace_base_path: &Path
) -> Result<(), Error>
👎Deprecated: this functionality has been merged into complete_from_path_and_workspace
or complete_from_abstract_filesystem
pub fn inherit_workspace<Ignored>(
&mut self,
workspace_manifest: &Manifest<Ignored>,
workspace_base_path: &Path
) -> Result<(), Error>
complete_from_path_and_workspace
or complete_from_abstract_filesystem
Copy workspace-inheritable properties from the workspace_manifest
.
workspace_base_path
should be an absolute path to a directory where the workspace manifest is located.
Used as a base for readme
and license-file
.