Crate tftp_packet

Source
Expand description

§An implementation of the tftp packet

This implements only conversion into and from bytes for a tftp packet and includes some generic enums and a custom Error type.

§Example

use tftp_packet::Packet;
use tftp_packet::Mode;

let packet = Packet::RRQ{ filename: "test.txt".to_string(), mode: Mode::Octet };
let bytes = packet.clone().to_bytes();
assert_eq!(bytes, [0, 1, 116, 101, 115, 116, 46, 116, 120, 116, 0, 111, 99, 116, 101, 116, 0]);
assert_eq!(Packet::from_bytes(&bytes).unwrap(), packet);

Enums§

ErrorCode
All error codes defined in rfc1350 for an ERROR packet
Mode
All modes defined in rfc1350
Opcode
All tftp opcodes defined in rfc1350
Packet
The tftp packet
PacketError
The error type for the tftp packet