1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
use crate::Type;

/// Represents the possible cardinalities of a service dependency.
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum ServiceCardinality {
    /// Indicates a cardinality of zero or one (0:1).
    ZeroOrOne,

    /// Indicates a cardinality of exactly one (1:1).
    ExactlyOne,

    /// Indicates a cardinality of zero or more (0:*).
    ZeroOrMore,
}

/// Represents a service dependency.
#[derive(Clone, Debug, PartialEq)]
pub struct ServiceDependency {
    injected_type: Type,
    cardinality: ServiceCardinality,
}

impl ServiceDependency {
    /// Initializes a new service dependency.
    /// 
    /// # Arguments
    /// 
    /// * `injected_type` - The [injected type](crate::Type) of the service dependency
    /// * `cardinality` - The [cardinality](crate::ServiceCardinality) of the service dependency
    pub fn new(injected_type: Type, cardinality: ServiceCardinality) -> Self {
        Self {
            injected_type,
            cardinality,
        }
    }

    /// Gets the [injected type](crate::Type) associated with the service dependency.
    pub fn injected_type(&self) -> &Type {
        &self.injected_type
    }

    /// Gets the [cardinality](crate::ServiceCardinality) associated with the service dependency.
    pub fn cardinality(&self) -> ServiceCardinality {
        self.cardinality
    }
}