pub struct MetadataCommand { /* private fields */ }
Expand description

A builder for configurating cargo metadata invocation.

Implementations§

source§

impl MetadataCommand

source

pub fn new() -> MetadataCommand

Creates a default cargo metadata command, which will look for Cargo.toml in the ancestors of the current directory.

source

pub fn cargo_path(&mut self, path: impl Into<PathBuf>) -> &mut MetadataCommand

Path to cargo executable. If not set, this will use the the $CARGO environment variable, and if that is not set, will simply be cargo.

source

pub fn manifest_path( &mut self, path: impl Into<PathBuf> ) -> &mut MetadataCommand

Path to Cargo.toml

source

pub fn current_dir(&mut self, path: impl Into<PathBuf>) -> &mut MetadataCommand

Current directory of the cargo metadata process.

source

pub fn no_deps(&mut self) -> &mut MetadataCommand

Output information only about the root package and don’t fetch dependencies.

source

pub fn features(&mut self, features: CargoOpt) -> &mut MetadataCommand

Which features to include.

Call this multiple times to specify advanced feature configurations:

MetadataCommand::new()
    .features(CargoOpt::NoDefaultFeatures)
    .features(CargoOpt::SomeFeatures(vec!["feat1".into(), "feat2".into()]))
    .features(CargoOpt::SomeFeatures(vec!["feat3".into()]))
    // ...
Panics

cargo metadata rejects multiple --no-default-features flags. Similarly, the features() method panics when specifying multiple CargoOpt::NoDefaultFeatures:

MetadataCommand::new()
    .features(CargoOpt::NoDefaultFeatures)
    .features(CargoOpt::NoDefaultFeatures) // <-- panic!
    // ...

The method also panics for multiple CargoOpt::AllFeatures arguments:

MetadataCommand::new()
    .features(CargoOpt::AllFeatures)
    .features(CargoOpt::AllFeatures) // <-- panic!
    // ...
source

pub fn other_options( &mut self, options: impl Into<Vec<String>> ) -> &mut MetadataCommand

Arbitrary command line flags to pass to cargo. These will be added to the end of the command line invocation.

source

pub fn cargo_command(&self) -> Command

Builds a command for cargo metadata. This is the first part of the work of exec.

source

pub fn parse<T: AsRef<str>>(data: T) -> Result<Metadata>

Parses cargo metadata output. data must have been produced by a command built with cargo_command.

source

pub fn exec(&self) -> Result<Metadata>

Runs configured cargo metadata and returns parsed Metadata.

Trait Implementations§

source§

impl Clone for MetadataCommand

source§

fn clone(&self) -> MetadataCommand

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 Debug for MetadataCommand

source§

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

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

impl Default for MetadataCommand

source§

fn default() -> MetadataCommand

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

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

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

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
source§

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

Performs the conversion.