use std::fmt::{write, Display};
use accessorise::impl_get;
use inc_dec::IntIncDecSelf;
use crate::ConnectionStateMessage;
pub type ConnectionStateIdNumberType = u8;
#[derive(Default, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Debug)]
pub struct ConnectionStateId
{
id_number: ConnectionStateIdNumberType
}
impl ConnectionStateId
{
pub fn new() -> ConnectionStateId
{
Self::default()
}
impl_get!(id_number, ConnectionStateIdNumberType, "Gets the current id number value.");
pub fn next(&mut self) -> ConnectionStateId
{
ConnectionStateId
{
id_number: self.id_number.wpp()
}
}
pub fn connection_state_message<T>(&self, message: T) -> ConnectionStateMessage<T>
{
ConnectionStateMessage::new(*self, message)
}
}
impl Display for ConnectionStateId
{
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result
{
write!(f, "{}", self.id_number)
}
}