use core::{
fmt::Debug,
hash::{Hash, Hasher},
};
use crate::{Endpoint, Message, MessageType};
#[derive(
zerocopy::Immutable,
zerocopy::FromBytes,
zerocopy::IntoBytes,
zerocopy::Unaligned,
zerocopy::KnownLayout,
)]
#[repr(C, packed)]
pub struct CallMeMaybe {
pub endpoints: [Endpoint],
}
impl Message for CallMeMaybe {
const TYPE: MessageType = MessageType::CallMeMaybe;
}
impl CallMeMaybe {
pub const fn size_for_endpoint_count(endpoint_count: usize) -> usize {
size_of::<Endpoint>() * endpoint_count
}
}
impl Debug for &CallMeMaybe {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_struct("CallMeMaybe")
.field("endpoints", &&self.endpoints)
.finish()
}
}
impl PartialEq for &CallMeMaybe {
fn eq(&self, other: &Self) -> bool {
self.endpoints.eq(&other.endpoints)
}
}
impl Eq for &CallMeMaybe {}
impl PartialOrd for &CallMeMaybe {
fn partial_cmp(&self, other: &Self) -> Option<core::cmp::Ordering> {
Some(self.cmp(other))
}
}
impl Ord for &CallMeMaybe {
fn cmp(&self, other: &Self) -> core::cmp::Ordering {
self.endpoints.cmp(&other.endpoints)
}
}
impl Hash for &CallMeMaybe {
fn hash<H: Hasher>(&self, state: &mut H) {
self.endpoints.hash(state);
}
}