di/
dependency.rs

1use crate::Type;
2
3/// Represents the possible cardinalities of a service dependency.
4#[derive(Copy, Clone, Debug, PartialEq)]
5pub enum ServiceCardinality {
6    /// Indicates a cardinality of zero or one (0:1).
7    ZeroOrOne,
8
9    /// Indicates a cardinality of exactly one (1:1).
10    ExactlyOne,
11
12    /// Indicates a cardinality of zero or more (0:*).
13    ZeroOrMore,
14}
15
16/// Represents a service dependency.
17#[derive(Clone, Debug, PartialEq)]
18pub struct ServiceDependency {
19    injected_type: Type,
20    cardinality: ServiceCardinality,
21}
22
23impl ServiceDependency {
24    /// Initializes a new service dependency.
25    /// 
26    /// # Arguments
27    /// 
28    /// * `injected_type` - The [injected type](crate::Type) of the service dependency
29    /// * `cardinality` - The [cardinality](crate::ServiceCardinality) of the service dependency
30    pub fn new(injected_type: Type, cardinality: ServiceCardinality) -> Self {
31        Self {
32            injected_type,
33            cardinality,
34        }
35    }
36
37    /// Gets the [injected type](crate::Type) associated with the service dependency.
38    pub fn injected_type(&self) -> &Type {
39        &self.injected_type
40    }
41
42    /// Gets the [cardinality](crate::ServiceCardinality) associated with the service dependency.
43    pub fn cardinality(&self) -> ServiceCardinality {
44        self.cardinality
45    }
46}