uv_types/requirements.rs
1use uv_distribution_types::Requirement;
2use uv_normalize::ExtraName;
3
4/// A set of requirements as requested by a parent requirement.
5///
6/// For example, given `flask[dotenv]`, the `RequestedRequirements` would include the `dotenv`
7/// extra, along with all of the requirements that are included in the `flask` distribution
8/// including their unevaluated markers.
9#[derive(Debug, Clone)]
10pub struct RequestedRequirements {
11 /// The set of extras included on the originating requirement.
12 extras: Box<[ExtraName]>,
13 /// The set of requirements that were requested by the originating requirement.
14 requirements: Box<[Requirement]>,
15 /// Whether the dependencies were direct or transitive.
16 direct: bool,
17}
18
19impl RequestedRequirements {
20 /// Instantiate a [`RequestedRequirements`] with the given `extras` and `requirements`.
21 pub fn new(extras: Box<[ExtraName]>, requirements: Box<[Requirement]>, direct: bool) -> Self {
22 Self {
23 extras,
24 requirements,
25 direct,
26 }
27 }
28
29 /// Return the extras that were included on the originating requirement.
30 pub fn extras(&self) -> &[ExtraName] {
31 &self.extras
32 }
33
34 /// Return the requirements that were included on the originating requirement.
35 pub fn requirements(&self) -> &[Requirement] {
36 &self.requirements
37 }
38
39 /// Return whether the dependencies were direct or transitive.
40 pub fn direct(&self) -> bool {
41 self.direct
42 }
43}