Struct cargo_edit::Dependency
source · #[non_exhaustive]pub struct Dependency {
pub name: String,
pub optional: Option<bool>,
pub features: Option<Vec<String>>,
pub default_features: Option<bool>,
pub inherited_features: Option<Vec<String>>,
pub source: Option<Source>,
pub registry: Option<String>,
pub rename: Option<String>,
pub available_features: BTreeMap<String, Vec<String>>,
}
Expand description
A dependency handled by Cargo
None
means the field will be blank in TOML
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.name: String
The name of the dependency (as it is set in its Cargo.toml
and known to crates.io)
optional: Option<bool>
Whether the dependency is opted-in with a feature flag
features: Option<Vec<String>>
List of features to add (or None to keep features unchanged).
default_features: Option<bool>
Whether default features are enabled
inherited_features: Option<Vec<String>>
List of features inherited from a workspace dependency
source: Option<Source>
Where the dependency comes from
registry: Option<String>
Non-default registry
rename: Option<String>
If the dependency is renamed, this is the new name for the dependency as a string. None if it is not renamed.
available_features: BTreeMap<String, Vec<String>>
Features that are exposed by the dependency
Implementations§
source§impl Dependency
impl Dependency
sourcepub fn set_source(self, source: impl Into<Source>) -> Self
pub fn set_source(self, source: impl Into<Source>) -> Self
Set dependency to a given version
sourcepub fn set_available_features(
self,
available_features: BTreeMap<String, Vec<String>>,
) -> Self
pub fn set_available_features( self, available_features: BTreeMap<String, Vec<String>>, ) -> Self
Set the available features of the dependency to a given vec
sourcepub fn set_optional(self, opt: bool) -> Self
pub fn set_optional(self, opt: bool) -> Self
Set whether the dependency is optional
sourcepub fn set_features(self, features: Vec<String>) -> Self
pub fn set_features(self, features: Vec<String>) -> Self
Set features as an array of string (does some basic parsing)
sourcepub fn extend_features(self, features: impl IntoIterator<Item = String>) -> Self
pub fn extend_features(self, features: impl IntoIterator<Item = String>) -> Self
Set features as an array of string (does some basic parsing)
sourcepub fn set_default_features(self, default_features: bool) -> Self
pub fn set_default_features(self, default_features: bool) -> Self
Set the value of default-features for the dependency
sourcepub fn set_rename(self, rename: &str) -> Self
pub fn set_rename(self, rename: &str) -> Self
Set the alias for the dependency
sourcepub fn set_registry(self, registry: impl Into<String>) -> Self
pub fn set_registry(self, registry: impl Into<String>) -> Self
Set the value of registry for the dependency
sourcepub fn set_inherited_features(self, features: Vec<String>) -> Self
pub fn set_inherited_features(self, features: Vec<String>) -> Self
Set features as an array of string (does some basic parsing)
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) -> CargoResult<Self>
pub fn from_toml(crate_root: &Path, key: &str, item: &Item) -> CargoResult<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,
key: &mut KeyMut<'_>,
item: &mut Item,
)
pub fn update_toml( &self, crate_root: &Path, key: &mut KeyMut<'_>, 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 Display for Dependency
impl Display for 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 for Dependency
impl PartialEq for Dependency
source§impl PartialOrd for Dependency
impl PartialOrd for Dependency
impl Eq for Dependency
impl StructuralPartialEq for Dependency
Auto Trait Implementations§
impl Freeze for Dependency
impl RefUnwindSafe for Dependency
impl Send for Dependency
impl Sync for Dependency
impl Unpin for Dependency
impl UnwindSafe for Dependency
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.