pub struct Dependency {
inner: Arc<Inner>,
}
Expand description
Information about a dependency requested by a Cargo manifest. Cheap to copy.
Fields§
§inner: Arc<Inner>
Implementations§
Source§impl Dependency
impl Dependency
Sourcepub fn parse(
name: impl Into<InternedString>,
version: Option<&str>,
source_id: SourceId,
) -> CargoResult<Dependency>
pub fn parse( name: impl Into<InternedString>, version: Option<&str>, source_id: SourceId, ) -> CargoResult<Dependency>
Attempt to create a Dependency
from an entry in the manifest.
pub fn new_override(name: InternedString, source_id: SourceId) -> Dependency
pub fn serialized( &self, unstable_flags: &CliUnstable, features: &Features, ) -> SerializedDependency
pub fn version_req(&self) -> &OptVersionReq
Sourcepub fn name_in_toml(&self) -> InternedString
pub fn name_in_toml(&self) -> InternedString
This is the name of this Dependency
as listed in Cargo.toml
.
Or in other words, this is what shows up in the [dependencies]
section
on the left hand side. This is not the name of the package that’s
being depended on as the dependency can be renamed. For that use
package_name
below.
Both of the dependencies below return foo
for name_in_toml
:
[dependencies]
foo = "0.1"
and …
[dependencies]
foo = { version = "0.1", package = 'bar' }
Sourcepub fn package_name(&self) -> InternedString
pub fn package_name(&self) -> InternedString
The name of the package that this Dependency
depends on.
Usually this is what’s written on the left hand side of a dependencies
section, but it can also be renamed via the package
key.
Both of the dependencies below return foo
for package_name
:
[dependencies]
foo = "0.1"
and …
[dependencies]
bar = { version = "0.1", package = 'foo' }
pub fn source_id(&self) -> SourceId
pub fn registry_id(&self) -> Option<SourceId>
pub fn set_registry_id(&mut self, registry_id: SourceId) -> &mut Dependency
pub fn kind(&self) -> DepKind
pub fn is_public(&self) -> bool
Sourcepub fn set_public(&mut self, public: bool) -> &mut Dependency
pub fn set_public(&mut self, public: bool) -> &mut Dependency
Sets whether the dependency is public.
pub fn specified_req(&self) -> bool
Sourcepub fn platform(&self) -> Option<&Platform>
pub fn platform(&self) -> Option<&Platform>
If none, this dependencies must be built for all platforms. If some, it must only be built for the specified platform.
Sourcepub fn explicit_name_in_toml(&self) -> Option<InternedString>
pub fn explicit_name_in_toml(&self) -> Option<InternedString>
The renamed name of this dependency, if any.
If the package
key is used in Cargo.toml
then this returns the same
value as name_in_toml
.
pub fn set_kind(&mut self, kind: DepKind) -> &mut Dependency
Sourcepub fn set_features(
&mut self,
features: impl IntoIterator<Item = impl Into<InternedString>>,
) -> &mut Dependency
pub fn set_features( &mut self, features: impl IntoIterator<Item = impl Into<InternedString>>, ) -> &mut Dependency
Sets the list of features requested for the package.
Sourcepub fn set_default_features(
&mut self,
default_features: bool,
) -> &mut Dependency
pub fn set_default_features( &mut self, default_features: bool, ) -> &mut Dependency
Sets whether the dependency requests default features of the package.
Sourcepub fn set_optional(&mut self, optional: bool) -> &mut Dependency
pub fn set_optional(&mut self, optional: bool) -> &mut Dependency
Sets whether the dependency is optional.
Sourcepub fn set_source_id(&mut self, id: SourceId) -> &mut Dependency
pub fn set_source_id(&mut self, id: SourceId) -> &mut Dependency
Sets the source ID for this dependency.
Sourcepub fn set_version_req(&mut self, req: OptVersionReq) -> &mut Dependency
pub fn set_version_req(&mut self, req: OptVersionReq) -> &mut Dependency
Sets the version requirement for this dependency.
pub fn set_platform(&mut self, platform: Option<Platform>) -> &mut Dependency
pub fn set_explicit_name_in_toml( &mut self, name: impl Into<InternedString>, ) -> &mut Dependency
Sourcepub fn lock_to(&mut self, id: PackageId) -> &mut Dependency
pub fn lock_to(&mut self, id: PackageId) -> &mut Dependency
Locks this dependency to depending on the specified package ID.
Sourcepub fn lock_version(&mut self, version: &Version) -> &mut Dependency
pub fn lock_version(&mut self, version: &Version) -> &mut Dependency
Locks this dependency to a specified version.
Mainly used in dependency patching like [patch]
or [replace]
, which
doesn’t need to lock the entire dependency to a specific PackageId
.
Sourcepub fn is_locked(&self) -> bool
pub fn is_locked(&self) -> bool
Returns true
if this is a “locked” dependency. Basically a locked
dependency has an exact version req, but not vice versa.
Sourcepub fn is_transitive(&self) -> bool
pub fn is_transitive(&self) -> bool
Returns false
if the dependency is only used to build the local package.
pub fn is_build(&self) -> bool
pub fn is_optional(&self) -> bool
Sourcepub fn uses_default_features(&self) -> bool
pub fn uses_default_features(&self) -> bool
Returns true
if the default features of the dependency are requested.
Sourcepub fn features(&self) -> &[InternedString]
pub fn features(&self) -> &[InternedString]
Returns the list of features that are requested by the dependency.
Sourcepub fn matches(&self, sum: &Summary) -> bool
pub fn matches(&self, sum: &Summary) -> bool
Returns true
if the package (sum
) can fulfill this dependency request.
pub fn matches_prerelease(&self, sum: &Summary) -> bool
Sourcepub fn matches_ignoring_source(&self, id: PackageId) -> bool
pub fn matches_ignoring_source(&self, id: PackageId) -> bool
Returns true
if the package (id
) can fulfill this dependency request.
Sourcepub fn matches_id(&self, id: PackageId) -> bool
pub fn matches_id(&self, id: PackageId) -> bool
Returns true
if the package (id
) can fulfill this dependency request.
pub fn map_source( self, to_replace: SourceId, replace_with: SourceId, ) -> Dependency
pub(crate) fn set_artifact(&mut self, artifact: Artifact)
pub(crate) fn artifact(&self) -> Option<&Artifact>
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 Hash for Dependency
impl Hash 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,
§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: 8 bytes