Skip to content

Commit e1db5b9

Browse files
committed
apply suggestions, remove get_ prefixes
1 parent 649103b commit e1db5b9

1 file changed

Lines changed: 31 additions & 33 deletions

File tree

  • ctru-rs/src/services

ctru-rs/src/services/ac.rs

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -74,32 +74,30 @@ impl Ac {
7474
///
7575
/// let ac = Ac::new()?;
7676
///
77-
/// println!("Wi-Fi status: {:?}", ac.get_wifi_status()?);
77+
/// println!("Wi-Fi status: {:?}", ac.wifi_status()?);
7878
/// #
7979
/// # Ok(())
8080
/// # }
8181
/// ```
8282
#[doc(alias = "ACU_GetWifiStatus")]
83-
pub fn get_wifi_status(&self) -> crate::Result<NetworkStatus> {
83+
pub fn wifi_status(&self) -> crate::Result<NetworkStatus> {
8484
unsafe {
8585
let mut ret = 0u32;
8686
ResultCode(ctru_sys::ACU_GetStatus(&mut ret))?;
8787

88-
Ok(
89-
match ret {
90-
0 => NetworkStatus::None,
91-
1 => NetworkStatus::Idle,
92-
2 => NetworkStatus::LANConnected,
93-
3 => NetworkStatus::WANConnected,
94-
_ => Err(crate::Error::Other(format!("Unknown value {}", ret)))
95-
}
96-
)
88+
Ok(match ret {
89+
0 => NetworkStatus::None,
90+
1 => NetworkStatus::Idle,
91+
2 => NetworkStatus::LANConnected,
92+
3 => NetworkStatus::WANConnected,
93+
_ => return Err(crate::Error::Other(format!("Unknown value {}", ret))),
94+
})
9795
}
9896
}
9997

10098
/// Returns the [`SecurityMode`] of the currently connected network, or error if the console isn't connected to any network.
10199
///
102-
/// You can check if the console is connected to a network using [`Ac::get_wifi_status()`].
100+
/// You can check if the console is connected to a network using [`Ac::wifi_status()`].
103101
/// # Example
104102
///
105103
/// ```
@@ -111,16 +109,16 @@ impl Ac {
111109
///
112110
/// let ac = Ac::new()?;
113111
///
114-
/// if ac.get_wifi_status()? == NetworkStatus::WANConnected {
115-
/// println!("Network security: {:?}", ac.get_wifi_security()?);
112+
/// if ac.wifi_status()? == NetworkStatus::WANConnected {
113+
/// println!("Network security: {:?}", ac.wifi_security()?);
116114
/// }
117115
///
118116
/// #
119117
/// # Ok(())
120118
/// # }
121119
/// ```
122120
#[doc(alias = "ACU_GetWifiSecurityMode")]
123-
pub fn get_wifi_security(&self) -> crate::Result<SecurityMode> {
121+
pub fn wifi_security(&self) -> crate::Result<SecurityMode> {
124122
unsafe {
125123
let mut ret = 0u32;
126124
ResultCode(ctru_sys::ACU_GetSecurityMode(&mut ret))?;
@@ -139,14 +137,14 @@ impl Ac {
139137
6 => SecurityMode::WPA_AES,
140138
7 => SecurityMode::WPA2_AES,
141139

142-
_ => Err(crate::Error::Other(format!("Unknown value {}", ret)))
140+
_ => return Err(crate::Error::Other(format!("Unknown value {}", ret))),
143141
})
144142
}
145143
}
146144

147145
/// Returns the SSID of the Wi-Fi network the console is connected to, or error if the console isn't connected to any network.
148146
///
149-
/// You can check if the console is connected to a network using [`Ac::get_wifi_status()`].
147+
/// You can check if the console is connected to a network using [`Ac::wifi_status()`].
150148
///
151149
/// # Example
152150
///
@@ -159,13 +157,13 @@ impl Ac {
159157
///
160158
/// let ac = Ac::new()?;
161159
///
162-
/// println!("The console is connected to the network \"{}\"", ac.get_wifi_ssid().unwrap());
160+
/// println!("The console is connected to the network \"{}\"", ac.wifi_ssid().unwrap());
163161
/// #
164162
/// # Ok(())
165163
/// # }
166164
/// ```
167165
#[doc(alias = "ACU_GetSSID")]
168-
pub fn get_wifi_ssid(&self) -> crate::Result<String> {
166+
pub fn wifi_ssid(&self) -> crate::Result<String> {
169167
unsafe {
170168
let mut len = 0u32;
171169
ResultCode(ctru_sys::ACU_GetSSIDLength(&mut len))?;
@@ -189,14 +187,14 @@ impl Ac {
189187
///
190188
/// let ac = Ac::new()?;
191189
///
192-
/// println!("Proxy enabled: {}", ac.get_proxy_enabled()?);
190+
/// println!("Proxy enabled: {}", ac.proxy_enabled()?);
193191
///
194192
/// #
195193
/// # Ok(())
196194
/// # }
197195
/// ```
198196
#[doc(alias = "ACU_GetProxyEnable")]
199-
pub fn get_proxy_enabled(&self) -> crate::Result<bool> {
197+
pub fn proxy_enabled(&self) -> crate::Result<bool> {
200198
unsafe {
201199
let mut ret = false;
202200
ResultCode(ctru_sys::ACU_GetProxyEnable(&mut ret))?;
@@ -207,7 +205,7 @@ impl Ac {
207205

208206
/// Returns the connected network's proxy port, if present.
209207
///
210-
/// You can check if the console is using a proxy with [`Ac::get_proxy_enabled()`]
208+
/// You can check if the console is using a proxy with [`Ac::proxy_enabled()`]
211209
///
212210
/// # Example
213211
///
@@ -220,13 +218,13 @@ impl Ac {
220218
///
221219
/// let ac = Ac::new()?;
222220
///
223-
/// println!("Proxy port: {}", ac.get_proxy_port()?);
221+
/// println!("Proxy port: {}", ac.proxy_port()?);
224222
/// #
225223
/// # Ok(())
226224
/// # }
227225
/// ```
228226
#[doc(alias = "ACU_GetProxyPort")]
229-
pub fn get_proxy_port(&self) -> crate::Result<u32> {
227+
pub fn proxy_port(&self) -> crate::Result<u32> {
230228
unsafe {
231229
let mut ret = 0u32;
232230
ResultCode(ctru_sys::ACU_GetProxyPort(&mut ret))?;
@@ -237,7 +235,7 @@ impl Ac {
237235

238236
/// Returns the connected network's proxy username, if present.
239237
///
240-
/// You can check if the console is using a proxy with [`Ac::get_proxy_enabled()`]
238+
/// You can check if the console is using a proxy with [`Ac::proxy_enabled()`]
241239
///
242240
/// # Example
243241
///
@@ -250,14 +248,14 @@ impl Ac {
250248
///
251249
/// let ac = Ac::new()?;
252250
///
253-
/// println!("Proxy username: {}", ac.get_proxy_username()?);
251+
/// println!("Proxy username: {}", ac.proxy_username()?);
254252
///
255253
/// #
256254
/// # Ok(())
257255
/// # }
258256
/// ```
259257
#[doc(alias = "ACU_GetProxyUserName")]
260-
pub fn get_proxy_username(&self) -> crate::Result<String> {
258+
pub fn proxy_username(&self) -> crate::Result<String> {
261259
unsafe {
262260
let mut vec = vec![0u8; 0x20];
263261
ResultCode(ctru_sys::ACU_GetProxyUserName(vec.as_mut_ptr()))?;
@@ -268,7 +266,7 @@ impl Ac {
268266

269267
/// Returns the connected network's proxy password, if present.
270268
///
271-
/// You can check if the console is using a proxy with [`Ac::get_proxy_enabled()`]
269+
/// You can check if the console is using a proxy with [`Ac::proxy_enabled()`]
272270
///
273271
/// # Example
274272
///
@@ -281,18 +279,18 @@ impl Ac {
281279
///
282280
/// let ac = Ac::new()?;
283281
///
284-
/// println!("Proxy password: {}", ac.get_proxy_password()?);
282+
/// println!("Proxy password: {}", ac.proxy_password()?);
285283
/// #
286284
/// # Ok(())
287285
/// # }
288286
/// ```
289287
#[doc(alias = "ACU_GetProxyPassword")]
290-
pub fn get_proxy_password(&self) -> crate::Result<String> {
288+
pub fn proxy_password(&self) -> crate::Result<String> {
291289
unsafe {
292290
let mut vec = vec![0u8; 0x20];
293291
ResultCode(ctru_sys::ACU_GetProxyPassword(vec.as_mut_ptr()))?;
294292

295-
Ok(String::from_utf8(vec)?)
293+
Ok(String::from_utf8(vec))
296294
}
297295
}
298296

@@ -316,7 +314,7 @@ impl Ac {
316314
/// # }
317315
/// ```
318316
#[doc(alias = "ACI_LoadNetworkSetting")]
319-
pub fn load_network_slot(&self, slot: NetworkSlot) -> crate::Result<()> {
317+
pub fn load_network_slot(&mut self, slot: NetworkSlot) -> crate::Result<()> {
320318
unsafe {
321319
ResultCode(ctru_sys::ACI_LoadNetworkSetting(slot as u32))?;
322320
Ok(())
@@ -380,7 +378,7 @@ pub enum NetworkStatus {
380378
/// Connected, only LAN.
381379
LANConnected = 2,
382380
/// Connected to the Internet.
383-
WANConnected = 3
381+
WANConnected = 3,
384382
}
385383

386384
from_impl!(SecurityMode, ctru_sys::acSecurityMode);

0 commit comments

Comments
 (0)