From e4832b4cf36ba0eaed298ee458498eddd7176590 Mon Sep 17 00:00:00 2001 From: FxQnLr Date: Sun, 11 Feb 2024 21:17:58 +0100 Subject: fix clippy --- src/wol.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/wol.rs') diff --git a/src/wol.rs b/src/wol.rs index 8755b21..83c0ee6 100644 --- a/src/wol.rs +++ b/src/wol.rs @@ -1,17 +1,17 @@ use std::net::{SocketAddr, UdpSocket}; -use crate::error::WebolError; +use crate::error::Error; /// Creates the magic packet from a mac address /// /// # Panics /// /// Panics if `mac_addr` is an invalid mac -pub fn create_buffer(mac_addr: &str) -> Result, WebolError> { +pub fn create_buffer(mac_addr: &str) -> Result, Error> { let mut mac = Vec::new(); let sp = mac_addr.split(':'); for f in sp { - mac.push(u8::from_str_radix(f, 16).map_err(WebolError::BufferParse)?); + mac.push(u8::from_str_radix(f, 16).map_err(Error::BufferParse)?); }; let mut buf = vec![255; 6]; for _ in 0..16 { @@ -23,8 +23,8 @@ pub fn create_buffer(mac_addr: &str) -> Result, WebolError> { } /// Sends a buffer on UDP broadcast -pub fn send_packet(bind_addr: &SocketAddr, broadcast_addr: &SocketAddr, buffer: Vec) -> Result { - let socket = UdpSocket::bind(bind_addr).map_err(WebolError::Broadcast)?; - socket.set_broadcast(true).map_err(WebolError::Broadcast)?; - socket.send_to(&buffer, broadcast_addr).map_err(WebolError::Broadcast) +pub fn send_packet(bind_addr: &SocketAddr, broadcast_addr: &SocketAddr, buffer: &[u8]) -> Result { + let socket = UdpSocket::bind(bind_addr).map_err(Error::Broadcast)?; + socket.set_broadcast(true).map_err(Error::Broadcast)?; + socket.send_to(buffer, broadcast_addr).map_err(Error::Broadcast) } -- cgit v1.2.3