pub struct Manifest<Metadata = Value> {Show 17 fields
pub package: Option<Package<Metadata>>,
pub workspace: Option<Workspace<Metadata>>,
pub dependencies: BTreeMap<String, Dependency>,
pub dev_dependencies: BTreeMap<String, Dependency>,
pub build_dependencies: BTreeMap<String, Dependency>,
pub target: BTreeMap<String, Target>,
pub features: BTreeMap<String, Vec<String>>,
pub replace: BTreeMap<String, Dependency>,
pub patch: BTreeMap<String, BTreeMap<String, Dependency>>,
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>,
pub lints: Option<Lints>,
}
Expand description
The top-level Cargo.toml
structure. This is the main type in this library.
The Metadata
is a generic 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>>
Package definition (a cargo crate)
workspace: Option<Workspace<Metadata>>
Workspace-wide settings
dependencies: BTreeMap<String, Dependency>
Normal dependencies
dev_dependencies: BTreeMap<String, Dependency>
Dev/test-only deps
build_dependencies: BTreeMap<String, Dependency>
Build-time deps
target: BTreeMap<String, Target>
[target.cfg.dependencies]
features: BTreeMap<String, Vec<String>>
The [features]
section. This set may be incomplete!
Optional dependencies may create implied Cargo features.
This features section also supports microsyntax with dep:
, /
, and ?
for managing dependencies and their features.io
This crate has an optional [features
] module for dealing with this
complexity and getting the real list of features.
replace: BTreeMap<String, Dependency>
Obsolete
patch: BTreeMap<String, BTreeMap<String, Dependency>>
[patch.crates-io]
section
lib: Option<Product>
Note that due to autolibs feature this is not the complete list
unless you run Manifest::complete_from_path
profile: Profiles
Compilation/optimization settings
badges: Badges
[badges]
section
bin: Vec<Product>
Note that due to autobins feature this is not the complete list
unless you run Manifest::complete_from_path
bench: Vec<Product>
Benchmarks
test: Vec<Product>
Integration tests
example: Vec<Product>
Examples
lints: Option<Lints>
Lints
Implementations§
Source§impl Manifest
impl Manifest
Sourcepub fn from_path(cargo_toml_path: impl AsRef<Path>) -> Result<Manifest, Error>
pub fn from_path(cargo_toml_path: impl AsRef<Path>) -> Result<Manifest, Error>
Parse contents from a Cargo.toml
file on disk.
Calls Manifest::complete_from_path
to discover implicit binaries, etc.
If needed, it will search the file system for a workspace, and fill in data inherited from the workspace.
Sourcepub fn from_slice(cargo_toml_content: &[u8]) -> Result<Manifest, Error>
pub fn from_slice(cargo_toml_content: &[u8]) -> Result<Manifest, Error>
Warning: this will make an incomplete manifest, which will be missing data and panic when using workspace inheritance.
Parse contents of a Cargo.toml
file already loaded as a byte slice. It’s not a file name, but file’s TOML-syntax content.
If you don’t call Manifest::complete_from_path
, it may be missing implicit data, and panic if workspace inheritance is used.
Sourcepub fn from_str(cargo_toml_content: &str) -> Result<Manifest, Error>
pub fn from_str(cargo_toml_content: &str) -> Result<Manifest, Error>
Warning: this will make an incomplete manifest, which will be missing data and panic when using workspace inheritance.
It parses contents of a Cargo.toml
file loaded as a string. It’s not a file name, but file’s TOML-syntax content.
For a more reliable method, see from_path
.
If you don’t call Manifest::complete_from_path
, it may be missing implicit data, and panic if workspace inheritance is used.
Source§impl<Metadata> Manifest<Metadata>where
Metadata: for<'a> Deserialize<'a>,
impl<Metadata> Manifest<Metadata>where
Metadata: for<'a> Deserialize<'a>,
Sourcepub fn from_slice_with_metadata(
cargo_toml_content: &[u8],
) -> Result<Manifest<Metadata>, Error>
pub fn from_slice_with_metadata( cargo_toml_content: &[u8], ) -> Result<Manifest<Metadata>, Error>
Warning: this will make an incomplete manifest, which will be missing data and panic when using workspace inheritance.
Parse Cargo.toml
, and parse its [package.metadata]
into a custom Serde-compatible type.
It does not call Manifest::complete_from_path
, so may be missing implicit data.
Sourcepub fn from_path_with_metadata<P>(
cargo_toml_path: P,
) -> Result<Manifest<Metadata>, Error>
pub fn from_path_with_metadata<P>( cargo_toml_path: P, ) -> Result<Manifest<Metadata>, Error>
Parse contents from Cargo.toml
file on disk, with custom Serde-compatible metadata type.
Calls Manifest::complete_from_path
, so it will load a workspace if necessary.
Source§impl<Metadata> Manifest<Metadata>
impl<Metadata> Manifest<Metadata>
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 Manifest::complete_from_path_and_workspace
to provide the workspace explicitly.
Sourcepub fn complete_from_path_and_workspace<PackageMetadataTypeDoesNotMatterHere>(
&mut self,
package_manifest_path: &Path,
workspace_manifest_and_path: Option<(&Manifest<PackageMetadataTypeDoesNotMatterHere>, &Path)>,
) -> Result<(), Error>
pub fn complete_from_path_and_workspace<PackageMetadataTypeDoesNotMatterHere>( &mut self, package_manifest_path: &Path, workspace_manifest_and_path: Option<(&Manifest<PackageMetadataTypeDoesNotMatterHere>, &Path)>, ) -> Result<(), Error>
Manifest::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<PackageMetadataTypeDoesNotMatterHere, Fs>(
&mut self,
fs: Fs,
workspace_manifest_and_path: Option<(&Manifest<PackageMetadataTypeDoesNotMatterHere>, &Path)>,
) -> Result<(), Error>where
Fs: AbstractFilesystem,
pub fn complete_from_abstract_filesystem<PackageMetadataTypeDoesNotMatterHere, Fs>(
&mut self,
fs: Fs,
workspace_manifest_and_path: Option<(&Manifest<PackageMetadataTypeDoesNotMatterHere>, &Path)>,
) -> Result<(), Error>where
Fs: AbstractFilesystem,
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.
Call it like complete_from_abstract_filesystem::<cargo_toml::Value, _>(…)
if the arguments are ambiguous.
Sourcepub fn needs_workspace_inheritance(&self) -> bool
pub fn needs_workspace_inheritance(&self) -> bool
If true
, some fields are unavailable. If false
, it’s fully usable as-is.
It is false
in manifests that use workspace inheritance, but had their data completed from the root manifest already.
Trait Implementations§
Source§impl<'de, Metadata> Deserialize<'de> for Manifest<Metadata>where
Metadata: Deserialize<'de>,
impl<'de, Metadata> Deserialize<'de> for Manifest<Metadata>where
Metadata: Deserialize<'de>,
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Manifest<Metadata>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Manifest<Metadata>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl<Metadata> Serialize for Manifest<Metadata>where
Metadata: Serialize,
impl<Metadata> Serialize for Manifest<Metadata>where
Metadata: Serialize,
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl<Metadata> StructuralPartialEq for Manifest<Metadata>
Auto Trait Implementations§
impl<Metadata> Freeze for Manifest<Metadata>where
Metadata: Freeze,
impl<Metadata> RefUnwindSafe for Manifest<Metadata>where
Metadata: RefUnwindSafe,
impl<Metadata> Send for Manifest<Metadata>where
Metadata: Send,
impl<Metadata> Sync for Manifest<Metadata>where
Metadata: Sync,
impl<Metadata> Unpin for Manifest<Metadata>where
Metadata: Unpin,
impl<Metadata> UnwindSafe for Manifest<Metadata>where
Metadata: UnwindSafe,
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
Source§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<I, T> ExtractContext<I, ()> for T
impl<I, T> ExtractContext<I, ()> for T
Source§fn extract_context(self, _original_input: I)
fn extract_context(self, _original_input: I)
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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 moreSource§impl<T, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<I> RecreateContext<I> for I
impl<I> RecreateContext<I> for I
Source§fn recreate_context(_original_input: I, tail: I) -> I
fn recreate_context(_original_input: I, tail: I) -> I
Source§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
Source§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
Source§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
T
. Read moreSource§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.Source§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
Source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from
.Source§impl<T, S> UniqueSaturatedInto<T> for S
impl<T, S> UniqueSaturatedInto<T> for S
Source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T
.