Struct Dependency

Source
pub struct Dependency { /* private fields */ }
Expand description

Information about a dependency requested by a Cargo manifest. Cheap to copy.

Implementations§

Source§

impl Dependency

Source

pub fn parse( name: impl Into<InternedString>, version: Option<&str>, source_id: SourceId, inside: PackageId, config: &Config, ) -> CargoResult<Dependency>

Attempt to create a Dependency from an entry in the manifest.

Source

pub fn parse_no_deprecated( 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 version_req(&self) -> &VersionReq

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: VersionReq) -> &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 is_locked(&self) -> bool

Returns true if this is a “locked” dependency, basically whether it has an exact version req.

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_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

Trait Implementations§

Source§

impl Clone for Dependency

Source§

fn clone(&self) -> Dependency

Returns a duplicate 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 Ord for Dependency

Source§

fn cmp(&self, other: &Dependency) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. 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 PartialOrd for Dependency

Source§

fn partial_cmp(&self, other: &Dependency) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for Dependency

Source§

fn serialize<S>(&self, s: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
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, dest: *mut u8)

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

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.
Source§

impl<T> ErasedDestructor for T
where T: 'static,