Skip to main content

edgehog_device_runtime/
lib.rs

1// This file is part of Edgehog.
2//
3// Copyright 2022 - 2025 SECO Mind Srl
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9//    http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16//
17// SPDX-License-Identifier: Apache-2.0
18
19use std::path::PathBuf;
20
21use serde::Deserialize;
22
23pub use self::controller::Runtime;
24use self::data::astarte_device_sdk_lib::AstarteDeviceSdkConfigOptions;
25use self::telemetry::TelemetryInterfaceConfig;
26
27cfg_if::cfg_if! {
28    if #[cfg(test)] {
29        // Used for the mocks
30        pub use astarte_device_sdk_mock::Client;
31    } else {
32        pub use astarte_device_sdk::Client;
33    }
34}
35
36mod commands;
37#[cfg(feature = "containers")]
38pub mod containers;
39mod controller;
40pub mod data;
41#[cfg(all(feature = "zbus", target_os = "linux"))]
42mod device;
43pub mod error;
44#[cfg(feature = "forwarder")]
45mod forwarder;
46#[cfg(all(feature = "zbus", target_os = "linux"))]
47mod led_behavior;
48#[cfg(all(feature = "zbus", target_os = "linux"))]
49pub mod ota;
50mod power_management;
51pub mod repository;
52#[cfg(feature = "systemd")]
53pub mod systemd_wrapper;
54pub mod telemetry;
55
56#[derive(Deserialize, Debug, Clone)]
57pub enum AstarteLibrary {
58    #[serde(rename = "astarte-device-sdk")]
59    AstarteDeviceSdk,
60    #[cfg(feature = "message-hub")]
61    #[serde(rename = "astarte-message-hub")]
62    AstarteMessageHub,
63}
64
65#[derive(Debug, Deserialize, Clone)]
66pub struct DeviceManagerOptions {
67    pub astarte_library: AstarteLibrary,
68    pub astarte_device_sdk: Option<AstarteDeviceSdkConfigOptions>,
69    #[cfg(feature = "message-hub")]
70    pub astarte_message_hub: Option<data::astarte_message_hub_node::AstarteMessageHubOptions>,
71    #[cfg(feature = "containers")]
72    pub containers: containers::ContainersConfig,
73    #[cfg(feature = "service")]
74    pub service: Option<edgehog_service::config::Config>,
75    #[cfg(all(feature = "zbus", target_os = "linux"))]
76    pub ota: self::ota::config::OtaConfig,
77    pub interfaces_directory: PathBuf,
78    pub store_directory: PathBuf,
79    pub download_directory: PathBuf,
80    pub telemetry_config: Option<Vec<TelemetryInterfaceConfig<'static>>>,
81}