bss_oss_policy_engine/
engine.rs1use crate::bundling::BundleRule;
4use crate::eligibility::EligibilityRule;
5use crate::network::NetworkSelectionPolicy;
6use crate::sla::SLAPolicy;
7use async_trait::async_trait;
8
9#[async_trait]
11pub trait PolicyEngineTrait: Send + Sync {
12 async fn evaluate_pricing(
14 &self,
15 policy: &PricingPolicy,
16 context: &PricingContext,
17 ) -> Result<PricingResult, PolicyError>;
18
19 async fn check_eligibility(
21 &self,
22 rule: &EligibilityRule,
23 context: &EligibilityContext,
24 ) -> Result<bool, PolicyError>;
25
26 async fn evaluate_bundle(
28 &self,
29 rule: &BundleRule,
30 context: &BundleContext,
31 ) -> Result<BundleResult, PolicyError>;
32
33 async fn get_sla(&self, service_type: &str) -> Result<SLAPolicy, PolicyError>;
35
36 async fn select_network(
38 &self,
39 policy: &NetworkSelectionPolicy,
40 context: &NetworkContext,
41 ) -> Result<NetworkSelection, PolicyError>;
42}
43
44pub struct PolicyEngine {
46 }
48
49impl PolicyEngine {
50 pub fn new() -> Self {
51 Self {}
52 }
53}
54
55#[async_trait]
56impl PolicyEngineTrait for PolicyEngine {
57 async fn evaluate_pricing(
58 &self,
59 _policy: &PricingPolicy,
60 _context: &PricingContext,
61 ) -> Result<PricingResult, PolicyError> {
62 Err(PolicyError::NotImplemented)
64 }
65
66 async fn check_eligibility(
67 &self,
68 _rule: &EligibilityRule,
69 _context: &EligibilityContext,
70 ) -> Result<bool, PolicyError> {
71 Err(PolicyError::NotImplemented)
73 }
74
75 async fn evaluate_bundle(
76 &self,
77 _rule: &BundleRule,
78 _context: &BundleContext,
79 ) -> Result<BundleResult, PolicyError> {
80 Err(PolicyError::NotImplemented)
82 }
83
84 async fn get_sla(&self, _service_type: &str) -> Result<SLAPolicy, PolicyError> {
85 Err(PolicyError::NotImplemented)
87 }
88
89 async fn select_network(
90 &self,
91 _policy: &NetworkSelectionPolicy,
92 _context: &NetworkContext,
93 ) -> Result<NetworkSelection, PolicyError> {
94 Err(PolicyError::NotImplemented)
96 }
97}
98
99impl Default for PolicyEngine {
100 fn default() -> Self {
101 Self::new()
102 }
103}
104
105pub struct PricingPolicy;
107pub struct PricingContext;
108pub struct PricingResult;
109pub struct EligibilityContext;
110pub struct BundleContext;
111pub struct BundleResult;
112pub struct NetworkContext;
113pub struct NetworkSelection;
114
115#[derive(Debug, thiserror::Error)]
117pub enum PolicyError {
118 #[error("Policy not found")]
119 PolicyNotFound,
120 #[error("Invalid policy configuration")]
121 InvalidConfiguration,
122 #[error("Evaluation error: {0}")]
123 EvaluationError(String),
124 #[error("Not implemented")]
125 NotImplemented,
126}