pub enum Packet {
Rrq {
filename: String,
mode: String,
options: Vec<TransferOption>,
},
Wrq {
filename: String,
mode: String,
options: Vec<TransferOption>,
},
Data {
block_num: u16,
data: Vec<u8>,
},
Ack(u16),
Error {
code: ErrorCode,
msg: String,
},
Oack(Vec<TransferOption>),
}Expand description
Packet enum represents the valid TFTP packet types.
This enum has function implementaions for serializing Packets into
Vec<u8>s and deserializing u8 slices to Packets.
§Example
use tftpd::Packet;
let packet = Packet::Data { block_num: 15, data: vec![0x01, 0x02, 0x03] };
assert_eq!(packet.serialize().unwrap(), vec![0x00, 0x03, 0x00, 0x0F, 0x01, 0x02, 0x03]);
assert_eq!(Packet::deserialize(&[0x00, 0x03, 0x00, 0x0F, 0x01, 0x02, 0x03]).unwrap(), packet);Variants§
Rrq
Read Request struct
Fields
§
options: Vec<TransferOption>Transfer options
Wrq
Write Request struct
Fields
§
options: Vec<TransferOption>Transfer options
Data
Data struct
Ack(u16)
Acknowledgement tuple with block number
Error
Error struct
Oack(Vec<TransferOption>)
Option acknowledgement tuple with transfer options
Implementations§
Trait Implementations§
impl StructuralPartialEq for Packet
Auto Trait Implementations§
impl Freeze for Packet
impl RefUnwindSafe for Packet
impl Send for Packet
impl Sync for Packet
impl Unpin for Packet
impl UnwindSafe for Packet
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more