1use crate::{
2 PublicError,
3 cdk::api::canister_self,
4 dto::{canister::CanisterStatusView, icts::CanisterMetadataView},
5 workflow::ic::mgmt::MgmtWorkflow,
6};
7
8pub struct IctsApi;
13
14impl IctsApi {
15 #[must_use]
16 pub fn name() -> String {
17 env!("CARGO_PKG_NAME").to_string()
18 }
19
20 #[must_use]
21 pub fn version() -> String {
22 env!("CARGO_PKG_VERSION").to_string()
23 }
24
25 #[must_use]
26 pub fn description() -> String {
27 env!("CARGO_PKG_DESCRIPTION").to_string()
28 }
29
30 #[must_use]
31 pub fn metadata() -> CanisterMetadataView {
32 CanisterMetadataView {
33 name: Self::name(),
34 version: Self::version(),
35 description: Self::description(),
36 }
37 }
38
39 pub async fn canister_status() -> Result<CanisterStatusView, PublicError> {
41 MgmtWorkflow::canister_status_view(canister_self())
42 .await
43 .map_err(PublicError::from)
44 }
45}