[][src]Struct cargo_edit::Dependency

pub struct Dependency {
    pub name: String,
    pub features: Option<Vec<String>>,
    // some fields omitted
}

A dependency handled by Cargo

Fields

name: String

The name of the dependency (as it is set in its Cargo.toml and known to crates.io)

features: Option<Vec<String>>

List of features to add (or None to keep features unchanged).

Methods

impl Dependency[src]

pub fn new(name: &str) -> Dependency[src]

Create a new dependency with a name

pub fn set_version(self, version: &str) -> Dependency[src]

Set dependency to a given version

pub fn set_git(self, repo: &str, branch: Option<String>) -> Dependency[src]

Set dependency to a given repository

pub fn set_path(self, path: &str) -> Dependency[src]

Set dependency to a given path

pub fn set_optional(self, opt: bool) -> Dependency[src]

Set whether the dependency is optional

pub fn set_features(self, features: Option<Vec<String>>) -> Dependency[src]

Set features as an array of string (does some basic parsing)

pub fn set_default_features(self, default_features: bool) -> Dependency[src]

Set the value of default-features for the dependency

pub fn set_rename(self, rename: &str) -> Dependency[src]

Set the alias for the dependency

pub fn name_in_manifest(&self) -> &str[src]

Get the dependency name as defined in the manifest, that is, either the alias (rename field if Some), or the official package name (name field).

pub fn set_registry(self, registry: &str) -> Dependency[src]

Set the value of registry for the dependency

pub fn version(&self) -> Option<&str>[src]

Get version of dependency

pub fn rename(&self) -> Option<&str>[src]

Get the alias for the dependency (if any)

pub fn to_toml(&self) -> (String, Item)[src]

Convert dependency to TOML

Returns a tuple with the dependency's name and either the version as a String or the path/git repository as an InlineTable. (If the dependency is set as optional or default-features is set to false, an InlineTable is returned in any case.)

Trait Implementations

impl Clone for Dependency[src]

impl Debug for Dependency[src]

impl Default for Dependency[src]

impl Eq for Dependency[src]

impl Hash for Dependency[src]

impl PartialEq<Dependency> for Dependency[src]

impl StructuralEq for Dependency[src]

impl StructuralPartialEq for Dependency[src]

Auto Trait Implementations

impl RefUnwindSafe for Dependency

impl Send for Dependency

impl Sync for Dependency

impl Unpin for Dependency

impl UnwindSafe for Dependency

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<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

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

impl<T, U> Into<U> for T where
    U: From<T>, 
[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.