Enum cargo_toml::Dependency
source · pub enum Dependency {
Simple(String),
Inherited(InheritedDependencyDetail),
Detailed(Box<DependencyDetail>),
}
Expand description
Dependency definition. Note that this struct doesn’t carry it’s key/name, which you need to read from its section.
It can be simple version number, or detailed settings, or inherited.
Variants§
Simple(String)
Version requirement (e.g. ^1.5
)
Inherited(InheritedDependencyDetail)
Incomplete data
Detailed(Box<DependencyDetail>)
{ version = "^1.5", features = ["a", "b"] }
etc.
Implementations§
source§impl Dependency
impl Dependency
sourcepub fn detail(&self) -> Option<&DependencyDetail>
pub fn detail(&self) -> Option<&DependencyDetail>
Get object with special dependency settings if it’s not just a version number.
Returns None
if it’s inherited and the value is not available
sourcepub fn detail_mut(&mut self) -> &mut DependencyDetail
pub fn detail_mut(&mut self) -> &mut DependencyDetail
Panics if inherited value is not available
sourcepub fn try_detail_mut(&mut self) -> Result<&mut DependencyDetail, Error>
pub fn try_detail_mut(&mut self) -> Result<&mut DependencyDetail, Error>
Returns error if inherited value is not available
Makes it detailed otherwise
sourcepub fn try_req(&self) -> Result<&str, Error>
pub fn try_req(&self) -> Result<&str, Error>
Version requirement
Returns Error if inherited value is not available
sourcepub fn req_features(&self) -> &[String]
pub fn req_features(&self) -> &[String]
Enable extra features for this dep, in addition to the default
features controlled via default_features
.
sourcepub fn optional(&self) -> bool
pub fn optional(&self) -> bool
Is it optional. Note that optional deps can be used as features, unless features use dep:
/?
syntax for them.
See the features
module for more info.
sourcepub fn package(&self) -> Option<&str>
pub fn package(&self) -> Option<&str>
Some
if it overrides the package name.
If None
, use the dependency name as the package name.
sourcepub fn is_crates_io(&self) -> bool
pub fn is_crates_io(&self) -> bool
true
if it’s an usual crates.io dependency,
false
if git/path/alternative registry
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<'de> Deserialize<'de> for Dependency
impl<'de> Deserialize<'de> for Dependency
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl PartialEq for Dependency
impl PartialEq 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 ==
.