diff options
author | FxQnLr <[email protected]> | 2024-02-11 21:17:58 +0100 |
---|---|---|
committer | FxQnLr <[email protected]> | 2024-02-11 21:17:58 +0100 |
commit | e4832b4cf36ba0eaed298ee458498eddd7176590 (patch) | |
tree | 98cb6e1e1d97f69be4f8379edc8c33f6eda4e621 /src/wol.rs | |
parent | 6f94a825485b1d622d8ebe88ddf3e2f426d1c69c (diff) | |
download | webol-e4832b4cf36ba0eaed298ee458498eddd7176590.tar webol-e4832b4cf36ba0eaed298ee458498eddd7176590.tar.gz webol-e4832b4cf36ba0eaed298ee458498eddd7176590.zip |
fix clippy
Diffstat (limited to 'src/wol.rs')
-rw-r--r-- | src/wol.rs | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -1,17 +1,17 @@ | |||
1 | use std::net::{SocketAddr, UdpSocket}; | 1 | use std::net::{SocketAddr, UdpSocket}; |
2 | 2 | ||
3 | use crate::error::WebolError; | 3 | use crate::error::Error; |
4 | 4 | ||
5 | /// Creates the magic packet from a mac address | 5 | /// Creates the magic packet from a mac address |
6 | /// | 6 | /// |
7 | /// # Panics | 7 | /// # Panics |
8 | /// | 8 | /// |
9 | /// Panics if `mac_addr` is an invalid mac | 9 | /// Panics if `mac_addr` is an invalid mac |
10 | pub fn create_buffer(mac_addr: &str) -> Result<Vec<u8>, WebolError> { | 10 | pub fn create_buffer(mac_addr: &str) -> Result<Vec<u8>, Error> { |
11 | let mut mac = Vec::new(); | 11 | let mut mac = Vec::new(); |
12 | let sp = mac_addr.split(':'); | 12 | let sp = mac_addr.split(':'); |
13 | for f in sp { | 13 | for f in sp { |
14 | mac.push(u8::from_str_radix(f, 16).map_err(WebolError::BufferParse)?); | 14 | mac.push(u8::from_str_radix(f, 16).map_err(Error::BufferParse)?); |
15 | }; | 15 | }; |
16 | let mut buf = vec![255; 6]; | 16 | let mut buf = vec![255; 6]; |
17 | for _ in 0..16 { | 17 | for _ in 0..16 { |
@@ -23,8 +23,8 @@ pub fn create_buffer(mac_addr: &str) -> Result<Vec<u8>, WebolError> { | |||
23 | } | 23 | } |
24 | 24 | ||
25 | /// Sends a buffer on UDP broadcast | 25 | /// Sends a buffer on UDP broadcast |
26 | pub fn send_packet(bind_addr: &SocketAddr, broadcast_addr: &SocketAddr, buffer: Vec<u8>) -> Result<usize, WebolError> { | 26 | pub fn send_packet(bind_addr: &SocketAddr, broadcast_addr: &SocketAddr, buffer: &[u8]) -> Result<usize, Error> { |
27 | let socket = UdpSocket::bind(bind_addr).map_err(WebolError::Broadcast)?; | 27 | let socket = UdpSocket::bind(bind_addr).map_err(Error::Broadcast)?; |
28 | socket.set_broadcast(true).map_err(WebolError::Broadcast)?; | 28 | socket.set_broadcast(true).map_err(Error::Broadcast)?; |
29 | socket.send_to(&buffer, broadcast_addr).map_err(WebolError::Broadcast) | 29 | socket.send_to(buffer, broadcast_addr).map_err(Error::Broadcast) |
30 | } | 30 | } |