#![allow(clippy::non_canonical_partial_ord_impl)]
use bitcode::{Decode, Encode};
use derivative::Derivative;
use dimas_core::enums::OperationState;
use std::fmt::Display;
use zenoh::config::Locator;
#[repr(C)]
#[derive(Encode, Decode, Derivative)]
#[derivative(Clone, Debug, PartialEq, PartialOrd, Eq, Ord)]
pub struct AboutEntity {
name: String,
kind: String,
zid: String,
state: OperationState,
}
impl Display for AboutEntity {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"name: {} kind: {} state: {} zid: {}",
&self.name, &self.kind, &self.state, &self.zid
)
}
}
impl AboutEntity {
#[must_use]
pub const fn new(name: String, kind: String, zid: String, state: OperationState) -> Self {
Self {
name,
kind,
zid,
state,
}
}
#[must_use]
pub fn name(&self) -> &str {
&self.name
}
#[must_use]
pub fn kind(&self) -> &str {
&self.kind
}
#[must_use]
pub fn zid(&self) -> &str {
&self.zid
}
#[must_use]
pub const fn state(&self) -> &OperationState {
&self.state
}
}
#[repr(C)]
#[derive(Encode, Decode, Derivative)]
#[derivative(Clone, Debug, PartialEq, PartialOrd, Eq, Ord)]
pub struct PingEntity {
name: String,
zid: String,
oneway: i64,
}
impl Display for PingEntity {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"name: {} zid: {} oneway: {}",
&self.name, &self.zid, &self.oneway
)
}
}
impl PingEntity {
#[must_use]
pub const fn new(name: String, zid: String, oneway: i64) -> Self {
Self { name, zid, oneway }
}
#[must_use]
pub fn name(&self) -> &str {
&self.name
}
#[must_use]
pub fn zid(&self) -> &str {
&self.zid
}
#[must_use]
pub const fn oneway(&self) -> i64 {
self.oneway
}
}
#[repr(C)]
#[derive(Derivative)]
#[derivative(Clone, Debug, PartialEq, PartialOrd, Eq, Ord)]
pub struct ScoutingEntity {
zid: String,
kind: String,
#[derivative(PartialOrd = "ignore", Ord = "ignore")]
locators: Vec<Locator>,
}
impl Display for ScoutingEntity {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("ScoutingEntity")
.field("zid", &self.zid)
.field("kind", &self.kind)
.field("locators", &self.locators)
.finish()
}
}
impl ScoutingEntity {
#[must_use]
pub fn new(zid: String, kind: String, locators: Vec<Locator>) -> Self {
Self {
zid,
kind,
locators,
}
}
#[must_use]
pub fn zid(&self) -> &str {
&self.zid
}
#[must_use]
pub fn kind(&self) -> &str {
&self.kind
}
#[must_use]
pub const fn locators(&self) -> &Vec<Locator> {
&self.locators
}
}