#[non_exhaustive]pub struct Package<Metadata = Value> {Show 28 fields
pub name: String,
pub version: Inheritable<String>,
pub edition: Inheritable<Edition>,
pub rust_version: Option<Inheritable<String>>,
pub build: Option<OptionalFile>,
pub workspace: Option<PathBuf>,
pub authors: Inheritable<Vec<String>>,
pub links: Option<String>,
pub description: Option<Inheritable<String>>,
pub homepage: Option<Inheritable<String>>,
pub documentation: Option<Inheritable<String>>,
pub readme: Inheritable<OptionalFile>,
pub keywords: Inheritable<Vec<String>>,
pub categories: Inheritable<Vec<String>>,
pub exclude: Inheritable<Vec<String>>,
pub include: Inheritable<Vec<String>>,
pub license: Option<Inheritable<String>>,
pub license_file: Option<Inheritable<PathBuf>>,
pub repository: Option<Inheritable<String>>,
pub default_run: Option<String>,
pub autobins: bool,
pub autolib: bool,
pub autoexamples: bool,
pub autotests: bool,
pub autobenches: bool,
pub publish: Inheritable<Publish>,
pub resolver: Option<Resolver>,
pub metadata: Option<Metadata>,
}
Expand description
The [package]
section of the Manifest
. This is where crate properties are.
Note that most of these properties can be inherited from a workspace, and therefore not available just from reading a single Cargo.toml
. See [Manifest::inherit_workspace
].
You can replace Metadata
generic type with your own
to parse into something more useful than a generic toml Value
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.name: String
Careful: some names are uppercase, case-sensitive. -
changes to _
when used as a Rust identifier.
version: Inheritable<String>
See the version()
getter for more info.
Must parse as semver, e.g. “1.9.0”
This field may have unknown value when using workspace inheritance,
and when the Manifest
has been loaded without its workspace.
edition: Inheritable<Edition>
Package’s edition opt-in. Use Package::edition()
to read it.
rust_version: Option<Inheritable<String>>
MSRV 1.x (beware: does not require semver formatting)
build: Option<OptionalFile>
Build script definition
workspace: Option<PathBuf>
Workspace this package is a member of (None
if it’s implicit)
e.g. ["Author <e@mail>", "etc"]
Deprecated.
links: Option<String>
It doesn’t link to anything
description: Option<Inheritable<String>>
A short blurb about the package. This is not rendered in any format when uploaded to crates.io (aka this is not markdown).
homepage: Option<Inheritable<String>>
Project’s homepage
documentation: Option<Inheritable<String>>
Path to your custom docs. Unnecssary if you rely on docs.rs.
readme: Inheritable<OptionalFile>
This points to a file under the package root (relative to this Cargo.toml
).
implied if README.md, README.txt or README exists.
keywords: Inheritable<Vec<String>>
Up to 5, for search
categories: Inheritable<Vec<String>>
This is a list of up to five categories where this crate would fit.
e.g. ["command-line-utilities", "development-tools::cargo-plugins"]
exclude: Inheritable<Vec<String>>
Don’t publish these files
include: Inheritable<Vec<String>>
Publish these files
license: Option<Inheritable<String>>
e.g. “MIT”
license_file: Option<Inheritable<PathBuf>>
If license
is not standard
repository: Option<Inheritable<String>>
(HTTPS) URL to crate’s repository
default_run: Option<String>
The default binary to run by cargo run.
autobins: bool
Discover binaries from the file system
This may be incorrectly set to true
if the crate uses 2015 edition and has explicit [[bin]]
sections
autolib: bool
Discover libraries from the file system
autoexamples: bool
Discover examples from the file system
This may be incorrectly set to true
if the crate uses 2015 edition and has explicit [[example]]
sections
autotests: bool
Discover tests from the file system
This may be incorrectly set to true
if the crate uses 2015 edition and has explicit [[test]]
sections
autobenches: bool
Discover benchmarks from the file system
This may be incorrectly set to true
if the crate uses 2015 edition and has explicit [[bench]]
sections
publish: Inheritable<Publish>
Disable publishing or select custom registries.
resolver: Option<Resolver>
The feature resolver version.
metadata: Option<Metadata>
Arbitrary metadata of any type, an extension point for 3rd party tools.
Implementations§
Source§impl<Metadata> Package<Metadata>
impl<Metadata> Package<Metadata>
Sourcepub fn new(name: impl Into<String>, version: impl Into<String>) -> Self
pub fn new(name: impl Into<String>, version: impl Into<String>) -> Self
Prefer creating it by parsing a Manifest
instead.
Sourcepub fn version(&self) -> &str
pub fn version(&self) -> &str
Panics if the field is not available (inherited from a workspace that hasn’t been loaded)
Manifest::from_str
does not know where the TOML data came from, so it has no way of
searching the file system (or tarball or git) for a matching
Cargo Workspace Manifest.
Without a workspace, properties that use inheritance are missing data, and therefore can’t be returned, and will panic.
You can access these properties directly, they are an Inheritable
enum.
The version will default to 0.0.0
if the version
field was absent in the manifest.
Panics if the field is not available (inherited from a workspace that hasn’t been loaded)
See version
for more information.
Sourcepub fn categories(&self) -> &[String]
pub fn categories(&self) -> &[String]
Panics if the field is not available (inherited from a workspace that hasn’t been loaded)
See version
for more information.
Sourcepub fn categories_mut(&mut self) -> &mut Vec<String>
pub fn categories_mut(&mut self) -> &mut Vec<String>
Panics if the field is not available (inherited from a workspace that hasn’t been loaded)
See version
for more information.
Sourcepub fn description(&self) -> Option<&str>
pub fn description(&self) -> Option<&str>
Panics if the field is not available (inherited from a workspace that hasn’t been loaded)
See version
for more information.
pub fn set_description(&mut self, description: Option<String>)
Sourcepub fn documentation(&self) -> Option<&str>
pub fn documentation(&self) -> Option<&str>
Panics if the field is not available (inherited from a workspace that hasn’t been loaded)
See version
for more information.
pub fn set_documentation(&mut self, documentation: Option<String>)
Sourcepub fn edition(&self) -> Edition
pub fn edition(&self) -> Edition
Panics if the field is not available (inherited from a workspace that hasn’t been loaded)
See version
for more information.
Sourcepub fn exclude(&self) -> &[String]
pub fn exclude(&self) -> &[String]
Panics if the field is not available (inherited from a workspace that hasn’t been loaded)
See version
for more information.
Sourcepub fn include(&self) -> &[String]
pub fn include(&self) -> &[String]
Panics if the field is not available (inherited from a workspace that hasn’t been loaded)
See version
for more information.
Sourcepub fn homepage(&self) -> Option<&str>
pub fn homepage(&self) -> Option<&str>
Panics if the field is not available (inherited from a workspace that hasn’t been loaded)
See version
for more information.
pub fn set_homepage(&mut self, homepage: Option<String>)
Sourcepub fn keywords(&self) -> &[String]
pub fn keywords(&self) -> &[String]
Panics if the field is not available (inherited from a workspace that hasn’t been loaded)
See version
for more information.
Sourcepub fn license(&self) -> Option<&str>
pub fn license(&self) -> Option<&str>
Panics if the field is not available (inherited from a workspace that hasn’t been loaded)
See version
for more information.
Sourcepub fn license_file(&self) -> Option<&Path>
pub fn license_file(&self) -> Option<&Path>
Panics if the field is not available (inherited from a workspace that hasn’t been loaded)
See version
for more information.
Sourcepub fn publish(&self) -> &Publish
pub fn publish(&self) -> &Publish
Panics if the field is not available (inherited from a workspace that hasn’t been loaded)
See version
for more information.
Sourcepub fn readme(&self) -> &OptionalFile
pub fn readme(&self) -> &OptionalFile
Panics if the field is not available (inherited from a workspace that hasn’t been loaded)
See version
for more information.
Sourcepub fn repository(&self) -> Option<&str>
pub fn repository(&self) -> Option<&str>
Panics if the field is not available (inherited from a workspace that hasn’t been loaded)
See version
for more information.
pub fn set_repository(&mut self, repository: Option<String>)
Sourcepub fn rust_version(&self) -> Option<&str>
pub fn rust_version(&self) -> Option<&str>
Panics if the field is not available (inherited from a workspace that hasn’t been loaded)
See version
for more information.