dimas_commands/messages/
about_entity.rs

1// Copyright © 2024 Stephan Kunz
2#![allow(clippy::non_canonical_partial_ord_impl)]
3
4//! The `About` information of an agent.
5
6#[doc(hidden)]
7extern crate alloc;
8
9// region:		--- modules
10use alloc::string::String;
11use bitcode::{Decode, Encode};
12use core::fmt::Display;
13use dimas_core::enums::OperationState;
14// endregion:	--- modules
15
16// region:		--- AboutEntity
17/// A `DiMAS` entity
18#[repr(C)]
19#[derive(Encode, Clone, Decode)]
20pub struct AboutEntity {
21	name: String,
22	kind: String,
23	zid: String,
24	state: OperationState,
25}
26
27impl Display for AboutEntity {
28	fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
29		write!(
30			f,
31			"name: {} kind: {} state: {} zid: {}",
32			&self.name, &self.kind, &self.state, &self.zid
33		)
34	}
35}
36
37impl AboutEntity {
38	/// Constructor
39	#[must_use]
40	pub const fn new(name: String, kind: String, zid: String, state: OperationState) -> Self {
41		Self {
42			name,
43			kind,
44			zid,
45			state,
46		}
47	}
48
49	/// Get the Name
50	#[must_use]
51	pub fn name(&self) -> &str {
52		&self.name
53	}
54
55	/// Get the Kind
56	#[must_use]
57	pub fn kind(&self) -> &str {
58		&self.kind
59	}
60
61	/// Get the Zenoh ID
62	#[must_use]
63	pub fn zid(&self) -> &str {
64		&self.zid
65	}
66
67	/// Get the state
68	#[must_use]
69	pub const fn state(&self) -> &OperationState {
70		&self.state
71	}
72}
73// endregion:	--- AboutEntity