cargo::core::dependency

Struct Dependency

Source
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

Source

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.

Source

pub fn new_override(name: InternedString, source_id: SourceId) -> Dependency

Source

pub fn serialized( &self, unstable_flags: &CliUnstable, features: &Features, ) -> SerializedDependency

Source

pub fn version_req(&self) -> &OptVersionReq

Source

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' }
Source

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' }
Source

pub fn source_id(&self) -> SourceId

Source

pub fn registry_id(&self) -> Option<SourceId>

Source

pub fn set_registry_id(&mut self, registry_id: SourceId) -> &mut Dependency

Source

pub fn kind(&self) -> DepKind

Source

pub fn is_public(&self) -> bool

Source

pub fn set_public(&mut self, public: bool) -> &mut Dependency

Sets whether the dependency is public.

Source

pub fn specified_req(&self) -> bool

Source

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.

Source

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.

Source

pub fn set_kind(&mut self, kind: DepKind) -> &mut Dependency

Source

pub fn set_features( &mut self, features: impl IntoIterator<Item = impl Into<InternedString>>, ) -> &mut Dependency

Sets the list of features requested for the package.

Source

pub fn set_default_features( &mut self, default_features: bool, ) -> &mut Dependency

Sets whether the dependency requests default features of the package.

Source

pub fn set_optional(&mut self, optional: bool) -> &mut Dependency

Sets whether the dependency is optional.

Source

pub fn set_source_id(&mut self, id: SourceId) -> &mut Dependency

Sets the source ID for this dependency.

Source

pub fn set_version_req(&mut self, req: OptVersionReq) -> &mut Dependency

Sets the version requirement for this dependency.

Source

pub fn set_platform(&mut self, platform: Option<Platform>) -> &mut Dependency

Source

pub fn set_explicit_name_in_toml( &mut self, name: impl Into<InternedString>, ) -> &mut Dependency

Source

pub fn lock_to(&mut self, id: PackageId) -> &mut Dependency

Locks this dependency to depending on the specified package ID.

Source

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.

Source

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.

Source

pub fn is_transitive(&self) -> bool

Returns false if the dependency is only used to build the local package.

Source

pub fn is_build(&self) -> bool

Source

pub fn is_optional(&self) -> bool

Source

pub fn uses_default_features(&self) -> bool

Returns true if the default features of the dependency are requested.

Source

pub fn features(&self) -> &[InternedString]

Returns the list of features that are requested by the dependency.

Source

pub fn matches(&self, sum: &Summary) -> bool

Returns true if the package (sum) can fulfill this dependency request.

Source

pub fn matches_prerelease(&self, sum: &Summary) -> bool

Source

pub fn matches_ignoring_source(&self, id: PackageId) -> bool

Returns true if the package (id) can fulfill this dependency request.

Source

pub fn matches_id(&self, id: PackageId) -> bool

Returns true if the package (id) can fulfill this dependency request.

Source

pub fn map_source( self, to_replace: SourceId, replace_with: SourceId, ) -> Dependency

Source

pub(crate) fn set_artifact(&mut self, artifact: Artifact)

Source

pub(crate) fn artifact(&self) -> Option<&Artifact>

Source

pub(crate) fn maybe_lib(&self) -> bool

Dependencies are potential rust libs if they are not artifacts or they are an artifact which allows to be seen as library. Previously, every dependency was potentially seen as library.

Trait Implementations§

Source§

impl Clone for Dependency

Source§

fn clone(&self) -> Dependency

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Dependency

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for Dependency

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Dependency

Source§

fn eq(&self, other: &Dependency) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Dependency

Source§

impl StructuralPartialEq for Dependency

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more

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