#[repr(u8)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum MessageType {
PoolUpdate = 0x01,
Subscribe = 0x02,
Subscribed = 0x03,
Unsubscribe = 0x04,
PriorityFees = 0x05,
Blockhash = 0x06,
Quote = 0x07,
QuoteSubscribed = 0x08,
SubscribeQuote = 0x09,
UnsubscribeQuote = 0x0A,
Ping = 0x0B,
Pong = 0x0C,
Heartbeat = 0x0D,
PoolUpdateBatch = 0x0E,
Error = 0xFF,
}
impl TryFrom<u8> for MessageType {
type Error = u8;
fn try_from(value: u8) -> Result<Self, <Self as TryFrom<u8>>::Error> {
match value {
0x01 => Ok(Self::PoolUpdate),
0x02 => Ok(Self::Subscribe),
0x03 => Ok(Self::Subscribed),
0x04 => Ok(Self::Unsubscribe),
0x05 => Ok(Self::PriorityFees),
0x06 => Ok(Self::Blockhash),
0x07 => Ok(Self::Quote),
0x08 => Ok(Self::QuoteSubscribed),
0x09 => Ok(Self::SubscribeQuote),
0x0A => Ok(Self::UnsubscribeQuote),
0x0B => Ok(Self::Ping),
0x0C => Ok(Self::Pong),
0x0D => Ok(Self::Heartbeat),
0x0E => Ok(Self::PoolUpdateBatch),
0xFF => Ok(Self::Error),
other => Err(other),
}
}
}