pub fn wake_device<'a, O>(options: O) -> Result<()>where
O: Into<WakeOptions<'a>>,Expand description
Sends a Wake-on-LAN magic packet to a broadcast address for waking up a specific device
§Arguments
options- AWakeOptionsstruct containing the magic packet, broadcast address, and bind address
§Returns
A Result indicating success or failure of the operation
§Errors
Returns an error if the UDP socket cannot be bound, if the broadcast option cannot be set, or if sending the packet fails
§Examples
Create a magic packet and send it to the default broadcast address (255.255.255.255:9):
use waker::{create_magic_packet, wake_device, WakeOptions};
let packet = create_magic_packet("01:23:45:67:89:AB").unwrap();
wake_device(&packet).unwrap();Create a magic packet and send it to a specific broadcast address:
use waker::{create_magic_packet, wake_device, WakeOptions};
let packet = create_magic_packet("01:23:45:67:89:AB").unwrap();
let addr = "192.168.0.255:9"; // Replace with your broadcast address and port
wake_device(WakeOptions::new(&packet).broadcast_address(addr)).unwrap();Create a magic packet and send it to a specific bind address:
use waker::{create_magic_packet, wake_device, WakeOptions};
let packet = create_magic_packet("01:23:45:67:89:AB").unwrap();
let addr = "0.0.0.0:0"; // Replace with your bind address and port
wake_device(WakeOptions::new(&packet).bind_address(addr)).unwrap();