Skip to main content

canic_core/api/
component_runtime.rs

1//! Module: api::component_runtime
2//!
3//! Responsibility: expose managed Component Directory preparation and runtime activation.
4//! Does not own: validation, stable mutation, endpoint authorization, or root distribution.
5//! Boundary: maps typed internal failures into Canic's public error contract.
6
7use crate::{
8    dto::{
9        component_registry::{
10            ComponentRuntimeActivationRequest, ComponentRuntimeDirectoryPreparationRequest,
11            ComponentRuntimeStatusResponse,
12        },
13        error::Error,
14    },
15    workflow::component_runtime,
16};
17
18///
19/// ComponentRuntimeApi
20///
21
22pub struct ComponentRuntimeApi;
23
24impl ComponentRuntimeApi {
25    pub fn prepare_directory(
26        request: ComponentRuntimeDirectoryPreparationRequest,
27    ) -> Result<ComponentRuntimeStatusResponse, Error> {
28        component_runtime::prepare_directory(request).map_err(Error::from)
29    }
30
31    pub fn status() -> Result<ComponentRuntimeStatusResponse, Error> {
32        component_runtime::status().map_err(Error::from)
33    }
34
35    pub fn activate(
36        request: ComponentRuntimeActivationRequest,
37    ) -> Result<crate::view::fleet_activation::ComponentRuntimeActivationTransition, Error> {
38        component_runtime::activate(request).map_err(Error::from)
39    }
40}