Get ImprovPacket directly from bytes
This commit is contained in:
parent
0288b49319
commit
9a3e034fce
@ -186,7 +186,7 @@ pub struct RawPacket {
|
||||
}
|
||||
|
||||
impl RawPacket {
|
||||
pub fn try_from_bytes(bytes: &Vec<u8>) -> Result<Self> {
|
||||
pub fn try_from_bytes(bytes: &[u8]) -> Result<Self> {
|
||||
if bytes.len() < 11 {
|
||||
bail!("Packet too small");
|
||||
}
|
||||
@ -256,6 +256,11 @@ impl ImprovPacket {
|
||||
_ => Err(anyhow!("Conversion into packet type not implemented")),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn try_from_bytes(bytes: &[u8]) -> Result<Self> {
|
||||
let raw_packet = RawPacket::try_from_bytes(bytes).context("Failed to deserialize bytes into raw packet")?;
|
||||
ImprovPacket::try_from_raw_packet(&raw_packet).context("Failed to get improv packet from raw packet")
|
||||
}
|
||||
}
|
||||
|
||||
pub struct CurrentStatePacket {
|
||||
|
Loading…
Reference in New Issue
Block a user