dimas_commands/messages/
scouting_entity.rs

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