Skip to content

Commit

Permalink
Remove unnecessary mut from self in async methods
Browse files Browse the repository at this point in the history
  • Loading branch information
ollipa committed Oct 12, 2023
1 parent 5cce245 commit 03356e4
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions src/asynchronous.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl AsyncNlSocket {
Ok(Self { socket, nl_type })
}

pub async fn list_interfaces(&mut self) -> Result<Vec<WirelessInterface>> {
pub async fn list_interfaces(&self) -> Result<Vec<WirelessInterface>> {
let request = Nl80211Request::list_interfaces();
let recv = self.send(request).await?;
let mut responses = Vec::new();
Expand All @@ -45,34 +45,25 @@ impl AsyncNlSocket {
Ok(responses)
}

pub async fn set_interface(&mut self, if_index: u32, if_type: InterfaceType) -> Result<()> {
pub async fn set_interface(&self, if_index: u32, if_type: InterfaceType) -> Result<()> {
let request = Nl80211Request::set_interface(if_index, if_type);
let recv = self.send(request).await?;
Self::handle_ack_response(recv).await
}

pub async fn set_monitor_flags(
&mut self,
if_index: u32,
flags: Vec<MonitorFlags>,
) -> Result<()> {
pub async fn set_monitor_flags(&self, if_index: u32, flags: Vec<MonitorFlags>) -> Result<()> {
let request = Nl80211Request::set_monitor_flags(if_index, flags);
let recv = self.send(request).await?;
Self::handle_ack_response(recv).await
}

pub async fn set_channel(
&mut self,
if_index: u32,
freq: u32,
width: ChannelWidth,
) -> Result<()> {
pub async fn set_channel(&self, if_index: u32, freq: u32, width: ChannelWidth) -> Result<()> {
let request = Nl80211Request::set_channel(if_index, freq, width);
let recv = self.send(request).await?;
Self::handle_ack_response(recv).await
}

pub async fn list_stations(&mut self, if_index: u32) -> Result<Vec<WirelessStation>> {
pub async fn list_stations(&self, if_index: u32) -> Result<Vec<WirelessStation>> {
let request = Nl80211Request::list_stations(if_index);
let recv = self.send(request).await?;

Expand All @@ -85,7 +76,7 @@ impl AsyncNlSocket {
Ok(responses)
}

pub async fn list_physical_devices(&mut self) -> Result<Vec<PhysicalDevice>> {
pub async fn list_physical_devices(&self) -> Result<Vec<PhysicalDevice>> {
let request = Nl80211Request::list_physical_devices();
let recv = self.send(request).await?;

Expand All @@ -102,10 +93,7 @@ impl AsyncNlSocket {
Ok(responses.values().cloned().collect())
}

pub async fn get_physical_device(
&mut self,
wiphy_index: u32,
) -> Result<Option<PhysicalDevice>> {
pub async fn get_physical_device(&self, wiphy_index: u32) -> Result<Option<PhysicalDevice>> {
let request = Nl80211Request::get_physical_device(wiphy_index);
let recv = self.send(request).await?;

Expand All @@ -125,7 +113,7 @@ impl AsyncNlSocket {
Ok(result)
}

pub async fn get_regulatory_domain(&mut self) -> Result<Vec<RegulatoryDomain>> {
pub async fn get_regulatory_domain(&self) -> Result<Vec<RegulatoryDomain>> {
let request = Nl80211Request::get_regulatory_domain();
let recv = self.send(request).await?;

Expand All @@ -138,13 +126,13 @@ impl AsyncNlSocket {
Ok(responses)
}

pub async fn trigger_scan(&mut self, if_index: u32) -> Result<()> {
pub async fn trigger_scan(&self, if_index: u32) -> Result<()> {
let request = Nl80211Request::trigger_scan(if_index);
let recv = self.send(request).await?;
Self::handle_ack_response(recv).await
}

pub async fn abort_scan(&mut self, if_index: u32) -> Result<()> {
pub async fn abort_scan(&self, if_index: u32) -> Result<()> {
let request = Nl80211Request::abort_scan(if_index);
let recv = self.send(request).await?;
Self::handle_ack_response(recv).await
Expand Down

0 comments on commit 03356e4

Please sign in to comment.