use core::fmt::{self, Debug, Display};
use minicbor::{Decode, Encode};
use serde::{Deserialize, Serialize};
#[derive(
Serialize, Deserialize, Decode, Encode, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash,
)]
#[serde(transparent)]
#[cbor(transparent)]
pub struct TransportType(#[n(0)] u8);
pub const LOCAL: TransportType = TransportType::new(0);
impl TransportType {
pub const fn new(n: u8) -> Self {
TransportType(n)
}
pub fn is_local(self) -> bool {
self == LOCAL
}
}
impl Display for TransportType {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.0)
}
}
impl From<TransportType> for u8 {
fn from(ty: TransportType) -> Self {
ty.0
}
}