Struct cargo_toml::Package

source ·
#[non_exhaustive]
pub struct Package<Metadata = Value> {
Show 27 fields pub name: String, pub edition: Inheritable<Edition>, pub rust_version: Option<Inheritable<String>>, pub version: Inheritable<String>, pub build: Option<OptionalFile>, pub workspace: Option<String>, 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 autoexamples: bool, pub autotests: bool, pub autobenches: bool, pub publish: Inheritable<Publish>, pub resolver: Option<Resolver>, pub metadata: Option<Metadata>,
}
Expand description

You can replace Metadata 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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§name: String

Careful: some names are uppercase

§edition: Inheritable<Edition>§rust_version: Option<Inheritable<String>>

MSRV 1.x (beware: does not require semver formatting)

§version: Inheritable<String>

e.g. “1.9.0”

§build: Option<OptionalFile>§workspace: Option<String>

Workspace this package is a member of (None if it’s implicit)

§authors: Inheritable<Vec<String>>

e.g. [“Author e@mail”, “etc”] Deprecated.

§links: Option<String>§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>>§documentation: Option<Inheritable<String>>§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>>§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>>§include: Inheritable<Vec<String>>§license: Option<Inheritable<String>>

e.g. “MIT”

§license_file: Option<Inheritable<PathBuf>>§repository: Option<Inheritable<String>>§default_run: Option<String>

The default binary to run by cargo run.

§autobins: bool§autoexamples: bool§autotests: bool§autobenches: bool§publish: Inheritable<Publish>§resolver: Option<Resolver>

“2” is the only useful value

§metadata: Option<Metadata>

Implementations§

source§

impl<Metadata> Package<Metadata>

source

pub fn new(name: impl Into<String>, version: impl Into<String>) -> Self

Prefer creating it by parsing Manifest instead

source

pub fn authors(&self) -> &[String]

Panics if the field is not available (inherited from a workspace that hasn’t been loaded)

source

pub fn categories(&self) -> &[String]

Panics if the field is not available (inherited from a workspace that hasn’t been loaded)

source

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)

source

pub fn description(&self) -> Option<&str>

Panics if the field is not available (inherited from a workspace that hasn’t been loaded)

source

pub fn set_description(&mut self, description: Option<String>)

source

pub fn documentation(&self) -> Option<&str>

Panics if the field is not available (inherited from a workspace that hasn’t been loaded)

source

pub fn set_documentation(&mut self, documentation: Option<String>)

source

pub fn edition(&self) -> Edition

Panics if the field is not available (inherited from a workspace that hasn’t been loaded)

source

pub fn exclude(&self) -> &[String]

Panics if the field is not available (inherited from a workspace that hasn’t been loaded)

source

pub fn include(&self) -> &[String]

Panics if the field is not available (inherited from a workspace that hasn’t been loaded)

source

pub fn homepage(&self) -> Option<&str>

Panics if the field is not available (inherited from a workspace that hasn’t been loaded)

source

pub fn set_homepage(&mut self, homepage: Option<String>)

source

pub fn keywords(&self) -> &[String]

Panics if the field is not available (inherited from a workspace that hasn’t been loaded)

source

pub fn license(&self) -> Option<&str>

Panics if the field is not available (inherited from a workspace that hasn’t been loaded)

source

pub fn license_file(&self) -> Option<&Path>

Panics if the field is not available (inherited from a workspace that hasn’t been loaded)

source

pub fn publish(&self) -> &Publish

Panics if the field is not available (inherited from a workspace that hasn’t been loaded)

source

pub fn readme(&self) -> &OptionalFile

Panics if the field is not available (inherited from a workspace that hasn’t been loaded)

source

pub fn repository(&self) -> Option<&str>

Panics if the field is not available (inherited from a workspace that hasn’t been loaded)

source

pub fn set_repository(&mut self, repository: Option<String>)

source

pub fn rust_version(&self) -> Option<&str>

Panics if the field is not available (inherited from a workspace that hasn’t been loaded)

source

pub fn version(&self) -> &str

Panics if the field is not available (inherited from a workspace that hasn’t been loaded)

source

pub fn name(&self) -> &str

Trait Implementations§

source§

impl<Metadata: Clone> Clone for Package<Metadata>

source§

fn clone(&self) -> Package<Metadata>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<Metadata: Debug> Debug for Package<Metadata>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<Metadata: Default> Default for Package<Metadata>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<'de, Metadata> Deserialize<'de> for Package<Metadata>where
    Metadata: Deserialize<'de>,

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
    __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<Metadata: PartialEq> PartialEq<Package<Metadata>> for Package<Metadata>

source§

fn eq(&self, other: &Package<Metadata>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<Metadata> Serialize for Package<Metadata>where
    Metadata: Serialize,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where
    __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<Metadata: Eq> Eq for Package<Metadata>

source§

impl<Metadata> StructuralEq for Package<Metadata>

source§

impl<Metadata> StructuralPartialEq for Package<Metadata>

Auto Trait Implementations§

§

impl<Metadata> RefUnwindSafe for Package<Metadata>where
    Metadata: RefUnwindSafe,

§

impl<Metadata> Send for Package<Metadata>where
    Metadata: Send,

§

impl<Metadata> Sync for Package<Metadata>where
    Metadata: Sync,

§

impl<Metadata> Unpin for Package<Metadata>where
    Metadata: Unpin,

§

impl<Metadata> UnwindSafe for Package<Metadata>where
    Metadata: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere
    T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere
    T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere
    T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere
    U: From<T>,

const: unstable · 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> ToOwned for Twhere
    T: Clone,

§

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 Twhere
    U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere
    U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for Twhere
    T: for<'de> Deserialize<'de>,