dimas_commands/messages/
ping_entity.rs

1// Copyright © 2024 Stephan Kunz
2#![allow(clippy::non_canonical_partial_ord_impl)]
3
4//! The `Ping` 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;
13// endregion:	--- modules
14
15// region:		--- PingEntity
16/// A `DiMAS` entity
17#[repr(C)]
18#[derive(Encode, Clone, Decode)]
19pub struct PingEntity {
20	name: String,
21	zid: String,
22	oneway: i64,
23}
24
25impl Display for PingEntity {
26	fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
27		write!(
28			f,
29			"name: {} zid: {} oneway: {}",
30			&self.name, &self.zid, &self.oneway
31		)
32	}
33}
34
35impl PingEntity {
36	/// Constructor
37	#[must_use]
38	pub const fn new(name: String, zid: String, oneway: i64) -> Self {
39		Self { name, zid, oneway }
40	}
41
42	/// Get the Name
43	#[must_use]
44	pub fn name(&self) -> &str {
45		&self.name
46	}
47
48	/// Get the Zenoh ID
49	#[must_use]
50	pub fn zid(&self) -> &str {
51		&self.zid
52	}
53
54	/// Get the oneway time
55	#[must_use]
56	pub const fn oneway(&self) -> i64 {
57		self.oneway
58	}
59}
60// endregion:	--- PingEntity