#[non_exhaustive]pub struct Dependency {
pub name: String,
pub optional: Option<bool>,
pub public: Option<bool>,
pub features: Option<IndexSet<String>>,
pub default_features: Option<bool>,
pub inherited_features: Option<IndexSet<String>>,
pub source: Option<Source>,
pub registry: Option<String>,
pub rename: Option<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.
public: Option<bool>
Whether the dependency is marked as public.
features: Option<IndexSet<String>>
List of features to add (or None to keep features unchanged).
default_features: Option<bool>
Whether default features are enabled.
inherited_features: Option<IndexSet<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.
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 clear_version(self) -> Self
pub fn clear_version(self) -> Self
Remove the existing version requirement.
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: IndexSet<String>) -> Self
pub fn set_features(self, features: IndexSet<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: IndexSet<String>) -> Self
pub fn set_inherited_features(self, features: IndexSet<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.
sourcepub fn source_id(
&self,
gctx: &GlobalContext,
) -> CargoResult<MaybeWorkspace<SourceId>>
pub fn source_id( &self, gctx: &GlobalContext, ) -> CargoResult<MaybeWorkspace<SourceId>>
Get the SourceID for this dependency.
sourcepub fn query(
&self,
gctx: &GlobalContext,
) -> CargoResult<MaybeWorkspace<Dependency>>
pub fn query( &self, gctx: &GlobalContext, ) -> CargoResult<MaybeWorkspace<Dependency>>
Query to find this dependency.
source§impl Dependency
impl Dependency
sourcepub fn from_toml(
gctx: &GlobalContext,
workspace_root: &Path,
crate_root: &Path,
unstable_features: &Features,
key: &str,
item: &Item,
) -> CargoResult<Self>
pub fn from_toml( gctx: &GlobalContext, workspace_root: &Path, crate_root: &Path, unstable_features: &Features, 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<'a>(
&self,
gctx: &GlobalContext,
workspace_root: &Path,
crate_root: &Path,
unstable_features: &Features,
) -> CargoResult<Item>
pub fn to_toml<'a>( &self, gctx: &GlobalContext, workspace_root: &Path, crate_root: &Path, unstable_features: &Features, ) -> CargoResult<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<'k, 'a>(
&self,
gctx: &GlobalContext,
workspace_root: &Path,
crate_root: &Path,
unstable_features: &Features,
key: &mut KeyMut<'k>,
item: &mut Item,
) -> CargoResult<()>
pub fn update_toml<'k, 'a>( &self, gctx: &GlobalContext, workspace_root: &Path, crate_root: &Path, unstable_features: &Features, key: &mut KeyMut<'k>, item: &mut Item, ) -> CargoResult<()>
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<'s> From<&'s Summary> for Dependency
impl<'s> From<&'s Summary> for Dependency
source§impl From<Summary> for Dependency
impl From<Summary> for Dependency
source§impl PartialEq for Dependency
impl PartialEq 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
)§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 344 bytes