Skip to main content

appcore_provider/
context.rs

1// =============================================================================
2//        #######
3//     ###       ###     F: context.rs
4//    ##   ## ##   ##    P: AppCore-Runtime
5//         ## ##
6//                       C: 2026/07/22 15:41:18 by dnettoRaw
7//    ##   ## ##   ##    U: 2026/07/22 15:41:18 by dnettoRaw
8//      ###########      S: 1.0.1-rc.8
9// =============================================================================
10
11use appcore_contracts::{ApplicationId, DeploymentManifestV1, InstallationId, RuntimeMode};
12
13/// Non-secret context supplied to every provider factory.
14#[derive(Debug, Clone, PartialEq, Eq)]
15pub struct ProviderContext {
16    application_id: ApplicationId,
17    installation_id: InstallationId,
18    runtime_mode: RuntimeMode,
19}
20
21impl ProviderContext {
22    /// Creates context from a validated deployment manifest.
23    pub fn from_manifest(manifest: &DeploymentManifestV1) -> Self {
24        Self {
25            application_id: manifest.application_id().clone(),
26            installation_id: manifest.installation_id().clone(),
27            runtime_mode: manifest.mode(),
28        }
29    }
30
31    /// Returns the installed application identity.
32    pub fn application_id(&self) -> &ApplicationId {
33        &self.application_id
34    }
35
36    /// Returns the installation identity.
37    pub fn installation_id(&self) -> &InstallationId {
38        &self.installation_id
39    }
40
41    /// Returns the explicit runtime mode.
42    pub fn runtime_mode(&self) -> RuntimeMode {
43        self.runtime_mode
44    }
45}