Opcode

Enum Opcode 

Source
#[repr(u16)]
pub enum Opcode { Rrq = 1, Wrq = 2, Data = 3, Ack = 4, Error = 5, Oack = 6, }
Expand description

Opcode enum represents the opcodes used in the TFTP definition.

This enum has function implementations for converting u16s to Opcodes and Opcodes to u8 arrays.

§Example

use tftpd::Opcode;

assert_eq!(Opcode::from_u16(3).unwrap(), Opcode::Data);
assert_eq!(Opcode::Ack.as_bytes(), [0x00, 0x04]);

Variants§

§

Rrq = 1

Read request opcode

§

Wrq = 2

Write request opcode

§

Data = 3

Data opcode

§

Ack = 4

Acknowledgement opcode

§

Error = 5

Error opcode

§

Oack = 6

Option acknowledgement opcode

Implementations§

Source§

impl Opcode

Source

pub fn from_u16(val: u16) -> Result<Opcode, &'static str>

Converts a u16 to an Opcode.

Source

pub const fn as_bytes(self) -> [u8; 2]

Converts a u16 to a u8 array with 2 elements.

Trait Implementations§

Source§

impl Debug for Opcode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Opcode

Source§

fn eq(&self, other: &Opcode) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Opcode

Auto Trait Implementations§

§

impl Freeze for Opcode

§

impl RefUnwindSafe for Opcode

§

impl Send for Opcode

§

impl Sync for Opcode

§

impl Unpin for Opcode

§

impl UnwindSafe for Opcode

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.