Struct cargo_edit_9::Dependency
source · pub struct Dependency {
pub name: String,
pub features: Option<Vec<String>>,
pub available_features: BTreeMap<String, Vec<String>>,
/* private fields */
}
Expand description
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).
available_features: BTreeMap<String, Vec<String>>
Features that are exposed by the dependency
Implementations§
source§impl Dependency
impl Dependency
sourcepub fn new(name: &str) -> Dependency
pub fn new(name: &str) -> Dependency
Create a new dependency with a name
sourcepub fn set_version(self, version: &str) -> Dependency
pub fn set_version(self, version: &str) -> Dependency
Set dependency to a given version
sourcepub fn clear_version(self) -> Dependency
pub fn clear_version(self) -> Dependency
Remove the existing version requirement
sourcepub fn set_available_features(
self,
available_features: BTreeMap<String, Vec<String>>
) -> Dependency
pub fn set_available_features( self, available_features: BTreeMap<String, Vec<String>> ) -> Dependency
Set the available features of the dependency to a given vec
sourcepub fn set_git(
self,
repo: &str,
branch: Option<String>,
tag: Option<String>,
rev: Option<String>
) -> Dependency
pub fn set_git( self, repo: &str, branch: Option<String>, tag: Option<String>, rev: Option<String> ) -> Dependency
Set dependency to a given repository
sourcepub fn set_path(self, path: PathBuf) -> Dependency
pub fn set_path(self, path: PathBuf) -> Dependency
sourcepub fn set_optional(self, opt: Option<bool>) -> Dependency
pub fn set_optional(self, opt: Option<bool>) -> Dependency
Set whether the dependency is optional
sourcepub fn set_features(self, features: Option<Vec<String>>) -> Dependency
pub fn set_features(self, features: Option<Vec<String>>) -> Dependency
Set features as an array of string (does some basic parsing)
sourcepub fn set_default_features(self, default_features: Option<bool>) -> Dependency
pub fn set_default_features(self, default_features: Option<bool>) -> Dependency
Set the value of default-features for the dependency
sourcepub fn set_rename(self, rename: &str) -> Dependency
pub fn set_rename(self, rename: &str) -> Dependency
Set the alias for the dependency
sourcepub fn set_registry(self, registry: &str) -> Dependency
pub fn set_registry(self, registry: &str) -> Dependency
Set the value of registry for the dependency
sourcepub fn default_features(&self) -> Option<bool>
pub fn default_features(&self) -> Option<bool>
Whether default features are activated
source§impl Dependency
impl Dependency
sourcepub fn from_toml(crate_root: &Path, key: &str, item: &Item) -> Option<Self>
pub fn from_toml(crate_root: &Path, key: &str, item: &Item) -> Option<Self>
Create a dependency from a TOML table entry
sourcepub fn toml_key(&self) -> &str
pub fn toml_key(&self) -> &str
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).
sourcepub fn to_toml(&self, crate_root: &Path) -> Item
pub fn to_toml(&self, crate_root: &Path) -> Item
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.)
Panic
Panics if the path is relative
sourcepub fn update_toml(&self, crate_root: &Path, item: &mut Item)
pub fn update_toml(&self, crate_root: &Path, item: &mut Item)
Modify existing entry to match this dependency
Trait Implementations§
source§impl Clone for Dependency
impl Clone for Dependency
source§fn clone(&self) -> Dependency
fn clone(&self) -> Dependency
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for Dependency
impl Debug for Dependency
source§impl Default for Dependency
impl Default for Dependency
source§fn default() -> Dependency
fn default() -> Dependency
source§impl Hash for Dependency
impl Hash for Dependency
source§impl Ord for Dependency
impl Ord for Dependency
source§fn cmp(&self, other: &Dependency) -> Ordering
fn cmp(&self, other: &Dependency) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere Self: Sized,
source§impl PartialEq<Dependency> for Dependency
impl PartialEq<Dependency> for Dependency
source§fn eq(&self, other: &Dependency) -> bool
fn eq(&self, other: &Dependency) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd<Dependency> for Dependency
impl PartialOrd<Dependency> for Dependency
source§fn partial_cmp(&self, other: &Dependency) -> Option<Ordering>
fn partial_cmp(&self, other: &Dependency) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moreimpl Eq for Dependency
impl StructuralEq for Dependency
impl StructuralPartialEq for Dependency
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§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.