feat: add Identifier::random and some other tiny fixes
This commit is contained in:
parent
f462630eb4
commit
405cf8b368
8 changed files with 190 additions and 11 deletions
|
|
@ -7,6 +7,7 @@ use identifier::Identifier;
|
|||
use packet_data::PacketData;
|
||||
use std::convert::TryFrom;
|
||||
use std::fmt::Debug;
|
||||
use std::io::Read;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Packet {
|
||||
|
|
@ -23,7 +24,19 @@ pub enum Packet {
|
|||
impl Packet {
|
||||
pub fn packet_id(&self) -> Identifier {
|
||||
match self {
|
||||
Packet::V1 { packet_id, ..} => packet_id.clone()
|
||||
Packet::V1 { packet_id, .. } => packet_id.clone()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn command(&self) -> u8 {
|
||||
match self {
|
||||
Packet::V1 { command, .. } => command.clone()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn data(&self) -> PacketData {
|
||||
match self {
|
||||
Packet::V1 { data, .. } => data.clone()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -98,3 +111,7 @@ impl Into<Vec<u8>> for Packet {
|
|||
self.build_full_packet()
|
||||
}
|
||||
}
|
||||
|
||||
pub trait ToPacket {
|
||||
fn to_v1_packet(self, src: Identifier, dest: Identifier, packet_id: Identifier, reply_to: Identifier) -> Packet;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue