Skip to main content

Decode

Trait Decode 

Source
pub trait Decode {
    // Required method
    fn decode(&self) -> Result<Packet, WakeError>;
}
Expand description

Decode data from wake format to wake packet structure

Required Methods§

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Decode for Vec<u8>

Decode Vec from wake format to wake packet structure

Source§

fn decode(&self) -> Result<Packet, WakeError>

§Output
  • Result<Packet, WakeError> - command, data or error
§Example
extern crate wake_rs;
use wake_rs::Decode;

let encoded_packet = vec![0xC0, 0x03, 0x05, 1, 2, 3, 4, 5, 0x6b];
let decoded_packet = encoded_packet.decode();
match decoded_packet {
    Ok(w) => {
        println!("Decoded packet\t: {}", w);
    },
    Err(err) => println!("Error: {:?}", err),
}

Implementors§