pub struct WolPacket { /* private fields */ }
Expand description
Wake-on-LAN packet
Implementations§
source§impl WolPacket
impl WolPacket
sourcepub fn from_bytes(mac: &[u8]) -> Result<WolPacket>
pub fn from_bytes(mac: &[u8]) -> Result<WolPacket>
Creates WOL packet from byte MAC representation
Example
let wol = wakey::WolPacket::from_bytes(&vec![0x00, 0x01, 0x02, 0x03, 0x04, 0x05]);
sourcepub fn send_magic(&self) -> Result<()>
pub fn send_magic(&self) -> Result<()>
Broadcasts the magic packet from / to default address Source: 0.0.0.0:0 Destination 255.255.255.255:9
Example
let wol = wakey::WolPacket::from_bytes(&vec![0x00, 0x01, 0x02, 0x03, 0x04, 0x05]).unwrap();
wol.send_magic();
sourcepub fn send_magic_to<A: ToSocketAddrs>(&self, src: A, dst: A) -> Result<()>
pub fn send_magic_to<A: ToSocketAddrs>(&self, src: A, dst: A) -> Result<()>
Broadcasts the magic packet from / to specified address.
Example
use std::net::SocketAddr;
let wol = wakey::WolPacket::from_bytes(&vec![0x00, 0x01, 0x02, 0x03, 0x04, 0x05]).unwrap();
let src = SocketAddr::from(([0,0,0,0], 0));
let dst = SocketAddr::from(([255,255,255,255], 9));
wol.send_magic_to(src, dst);
sourcepub fn into_inner(self) -> ArrayVec<u8, PACKET_LEN>
pub fn into_inner(self) -> ArrayVec<u8, PACKET_LEN>
Returns the underlying WoL packet bytes