Struct guppy::MetadataCommand[][src]

pub struct MetadataCommand { /* fields omitted */ }

A builder for configuring cargo metadata invocations.

This is the most common entry point for constructing a PackageGraph.

Examples

Build a PackageGraph for the Cargo workspace in the current directory:

use guppy::MetadataCommand;
use guppy::graph::PackageGraph;

let mut cmd = MetadataCommand::new();
let package_graph = PackageGraph::from_command(&mut cmd);

Implementations

impl MetadataCommand[src]

pub fn new() -> Self[src]

Creates a default cargo metadata command builder.

By default, this will look for Cargo.toml in the ancestors of this process’s current directory.

pub fn cargo_path(&mut self, path: impl Into<PathBuf>) -> &mut Self[src]

Sets the path to the cargo executable.

If unset, this will use the $CARGO environment variable, or else cargo from $PATH.

pub fn manifest_path(&mut self, path: impl Into<PathBuf>) -> &mut Self[src]

Sets the path to Cargo.toml.

By default, this will look for Cargo.toml in the ancestors of the current directory. Note that this doesn’t need to be the root Cargo.toml in a workspace – any member of the workspace is fine.

pub fn current_dir(&mut self, path: impl Into<PathBuf>) -> &mut Self[src]

Sets the current directory of the cargo metadata process.

By default, the current directory will be inherited from this process.

pub fn other_options(
    &mut self,
    options: impl IntoIterator<Item = impl Into<String>>
) -> &mut Self
[src]

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

Note that guppy internally:

  • uses --format-version 1 as its metadata format.
  • passes in --all-features, so that guppy has a full view of the dependency graph.
  • does not pass in --no-deps, so that guppy knows about non-workspace dependencies.

Attempting to override either of those options may lead to unexpected results.

pub fn exec(&self) -> Result<CargoMetadata, Error>[src]

Runs the configured cargo metadata and returns a deserialized CargoMetadata.

pub fn build_graph(&self) -> Result<PackageGraph, Error>[src]

Runs the configured cargo metadata and returns a parsed PackageGraph.

Trait Implementations

impl Clone for MetadataCommand[src]

impl Debug for MetadataCommand[src]

impl Default for MetadataCommand[src]

impl<'a> TryFrom<&'a MetadataCommand> for PackageGraph[src]

type Error = Error

The type returned in the event of a conversion error.

impl TryFrom<MetadataCommand> for PackageGraph[src]

Although consuming a MetadataCommand is not required for building a PackageGraph, this impl is provided for convenience.

type Error = Error

The type returned in the event of a conversion error.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<'a, T> DefaultFeatures<'a> for T where
    T: 'a + Clone + Send + Sync
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<'a, T> NonSyncFeatures<'a> for T where
    T: 'a + Clone
[src]

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T> SafeBorrow<T> for T where
    T: ?Sized
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,