pub struct MagicPacket { /* private fields */ }
Expand description
A Wake-on-LAN magic packet.
Implementations§
Source§impl MagicPacket
impl MagicPacket
Sourcepub fn new(mac_address: &[u8; 6]) -> MagicPacket
pub fn new(mac_address: &[u8; 6]) -> MagicPacket
Creates a new MagicPacket
intended for mac_address
(but doesn’t send it yet).
Sourcepub fn send(&self) -> Result<()>
pub fn send(&self) -> Result<()>
Sends the magic packet via UDP to the broadcast address 255.255.255.255:9
.
Lets the operating system choose the source port and network interface.
Sourcepub fn send_to<A: ToSocketAddrs>(&self, to_addr: A, from_addr: A) -> Result<()>
pub fn send_to<A: ToSocketAddrs>(&self, to_addr: A, from_addr: A) -> Result<()>
Sends the magic packet via UDP to/from an IP address and port number of your choosing.
Sourcepub fn magic_bytes(&self) -> &[u8; 102]
pub fn magic_bytes(&self) -> &[u8; 102]
Returns the magic packet’s payload (6 repetitions of 0xFF
and 16 repetitions of the
target device’s MAC address). Send these bytes yourself over the network if you want to do
something more advanced (like reuse a single UDP socket when sending a large number of
magic packets).
Auto Trait Implementations§
impl Freeze for MagicPacket
impl RefUnwindSafe for MagicPacket
impl Send for MagicPacket
impl Sync for MagicPacket
impl Unpin for MagicPacket
impl UnwindSafe for MagicPacket
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more