fundamentum_sdk_mqtt/
device.rs1#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6pub struct Device {
7 serial: String,
9 project_id: u64,
11 region_id: u64,
13 registry_id: u64,
15}
16
17impl Device {
18 pub fn new<S: Into<String>>(
20 serial: S,
21 project_id: u64,
22 region_id: u64,
23 registry_id: u64,
24 ) -> Self {
25 Self {
26 serial: serial.into(),
27 project_id,
28 region_id,
29 registry_id,
30 }
31 }
32
33 #[must_use]
35 pub fn client_id(&self) -> String {
36 format!(
37 "projects/{}/regions/{}/registries/{}/devices/{}",
38 self.project_id, self.region_id, self.registry_id, self.serial
39 )
40 }
41
42 #[must_use]
44 pub fn serial(&self) -> &str {
45 self.serial.as_ref()
46 }
47
48 #[must_use]
50 pub const fn project_id(&self) -> u64 {
51 self.project_id
52 }
53
54 #[must_use]
56 pub const fn region_id(&self) -> u64 {
57 self.region_id
58 }
59
60 #[must_use]
62 pub const fn registry_id(&self) -> u64 {
63 self.registry_id
64 }
65}