Convert ParsedPacket into Data
This commit is contained in:
parent
1bb043e10a
commit
cbb668c9da
1 changed files with 14 additions and 0 deletions
|
|
@ -5,6 +5,8 @@
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
||||||
|
use crate::error::{self, Error};
|
||||||
|
|
||||||
use super::PacketType;
|
use super::PacketType;
|
||||||
|
|
||||||
/// A "raw" packet.
|
/// A "raw" packet.
|
||||||
|
|
@ -227,6 +229,10 @@ impl ParsedPacket {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn into_data(self) -> error::Result<Data> {
|
||||||
|
self.content.map_err(Error::Euph)
|
||||||
|
}
|
||||||
|
|
||||||
/// Convert a [`Packet`] into a [`ParsedPacket`].
|
/// Convert a [`Packet`] into a [`ParsedPacket`].
|
||||||
///
|
///
|
||||||
/// This method may fail if the packet data is invalid.
|
/// This method may fail if the packet data is invalid.
|
||||||
|
|
@ -303,3 +309,11 @@ impl TryFrom<ParsedPacket> for Packet {
|
||||||
value.into_packet()
|
value.into_packet()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl TryFrom<ParsedPacket> for Data {
|
||||||
|
type Error = Error;
|
||||||
|
|
||||||
|
fn try_from(value: ParsedPacket) -> Result<Self, Self::Error> {
|
||||||
|
value.into_data()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue