Struct cargo_edit::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
sourceimpl 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
sourceimpl 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
sourceimpl Clone for Dependency
impl Clone for Dependency
sourcefn clone(&self) -> Dependency
fn clone(&self) -> Dependency
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for Dependency
impl Debug for Dependency
sourceimpl Default for Dependency
impl Default for Dependency
sourcefn default() -> Dependency
fn default() -> Dependency
Returns the “default value” for a type. Read more
sourceimpl Hash for Dependency
impl Hash for Dependency
sourceimpl Ord for Dependency
impl Ord for Dependency
sourceimpl PartialEq<Dependency> for Dependency
impl PartialEq<Dependency> for Dependency
sourcefn eq(&self, other: &Dependency) -> bool
fn eq(&self, other: &Dependency) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &Dependency) -> bool
fn ne(&self, other: &Dependency) -> bool
This method tests for !=
.
sourceimpl PartialOrd<Dependency> for Dependency
impl PartialOrd<Dependency> for Dependency
sourcefn partial_cmp(&self, other: &Dependency) -> Option<Ordering>
fn partial_cmp(&self, other: &Dependency) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl 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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more