Struct Packet

Source
pub struct Packet {
    pub address: Option<u8>,
    pub command: u8,
    pub data: Option<Vec<u8>>,
}
Expand description

Wake packet: address, command, and data

Fields§

§address: Option<u8>

Device address (optional) [0 - 127]

§command: u8

Command [0 - 127]

§data: Option<Vec<u8>>

Data load (optional)

Trait Implementations§

Source§

impl Default for Packet

Source§

fn default() -> Packet

Returns the “default value” for a type. Read more
Source§

impl Display for Packet

Source§

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

Show error in human readable format

Source§

impl Encode for Packet

Encode packet to wake format

Source§

fn encode(&self) -> Result<Vec<u8>, WakeError>

§Input
  • Wake packet structure with address, command code and data. Address and data are optional.
§Output
  • Vec<u8> - Encoded data in wake format
§Example
extern crate wake_rs;
use wake_rs::Encode;

let p = wake_rs::Packet{address: Some(0x12), command: 3, data: Some(vec!{0x00, 0xeb})};
let encoded_packet: Vec<u8> = p.encode().unwrap();

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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.