fundamentum_edge_mcu_http_client/models/provision_request.rs
1//! Provision request data structures.
2
3use serde::Serialize;
4
5/// Provisioning Scheme. More information in the [documentation][provision-doc].
6///
7/// [provision-doc]: https://dimonoff.atlassian.net/wiki/spaces/F2/pages/306166693917/Provisioning#Provisioning-API-V3
8#[derive(Serialize)]
9#[cfg_attr(feature = "log", derive(defmt::Format))]
10pub struct ProvisionRequestV3<'a> {
11 /// Project id on the Hub
12 pub project_id: u32,
13 /// Region id on the Hub
14 pub region_id: u32,
15 /// Registry id on the Hub
16 pub registry_id: u32,
17 /// Device's serial number
18 pub serial_number: &'a str,
19 /// Type of the device
20 pub asset_type_id: i32,
21 /// Provisioning token obtained from a registry's token file
22 pub access_token: &'a str,
23 /// Cryptography algorithm
24 pub algorithm: &'a DeviceIdentityTag,
25 /// The secret used to authenticate the device
26 pub secret: &'a str,
27}
28
29/// Algorithm and public secret to identify the device from the cloud.
30pub enum DeviceIdentity<'a> {
31 /// RSA 256 bits asymmetric encryption
32 Rsa256 {
33 /// RSA public key to authenticate the device.
34 public_key: &'a str,
35 },
36}
37
38/// Tags for the [`DeviceIdentity`] enumeration.
39#[derive(Serialize)]
40#[cfg_attr(feature = "log", derive(defmt::Format))]
41pub enum DeviceIdentityTag {
42 /// RSA 256 bits asymmetric encryption
43 RS256,
44}
45
46impl DeviceIdentity<'_> {
47 /// Access the enumeration tag only.
48 #[must_use]
49 pub const fn tag(&self) -> DeviceIdentityTag {
50 match *self {
51 Self::Rsa256 { .. } => DeviceIdentityTag::RS256,
52 }
53 }
54}