Skip to content

Commit c26de0a

Browse files
committed
Return network strings as byte vectors
1 parent 728afdb commit c26de0a

File tree

1 file changed

+11
-11
lines changed
  • ctru-rs/src/services

1 file changed

+11
-11
lines changed

ctru-rs/src/services/ac.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ impl Ac {
119119
/// # use std::error::Error;
120120
/// # fn main() -> Result<(), Box<dyn Error>> {
121121
/// #
122-
/// use ctru::services::ac::Ac;
122+
/// use ctru::services::ac::{Ac, NetworkStatus};
123123
///
124124
/// let ac = Ac::new()?;
125125
///
@@ -171,20 +171,20 @@ impl Ac {
171171
///
172172
/// let ac = Ac::new()?;
173173
///
174-
/// println!("The console is connected to the network \"{}\"", ac.wifi_ssid().unwrap());
174+
/// println!("The console is connected to the network \"{}\"", String::from_utf8(ac.wifi_ssid()?)?);
175175
/// #
176176
/// # Ok(())
177177
/// # }
178178
/// ```
179179
#[doc(alias = "ACU_GetSSID")]
180-
pub fn wifi_ssid(&self) -> crate::Result<String> {
180+
pub fn wifi_ssid(&self) -> crate::Result<Vec<u8>> {
181181
unsafe {
182182
let mut len = 0u32;
183183
ResultCode(ctru_sys::ACU_GetSSIDLength(&mut len))?;
184184
// we don't really need space for the terminator
185185
let mut vec = vec![0u8; len as usize];
186186
ResultCode(ctru_sys::ACU_GetSSID(vec.as_mut_ptr()))?;
187-
Ok(String::from_utf8(vec)?)
187+
Ok(vec)
188188
}
189189
}
190190

@@ -262,19 +262,19 @@ impl Ac {
262262
///
263263
/// let ac = Ac::new()?;
264264
///
265-
/// println!("Proxy username: {}", ac.proxy_username()?);
265+
/// println!("Proxy username: {}", String::from_utf8(ac.proxy_username()?)?);
266266
///
267267
/// #
268268
/// # Ok(())
269269
/// # }
270270
/// ```
271271
#[doc(alias = "ACU_GetProxyUserName")]
272-
pub fn proxy_username(&self) -> crate::Result<String> {
272+
pub fn proxy_username(&self) -> crate::Result<Vec<u8>> {
273273
unsafe {
274274
let mut vec = vec![0u8; 0x20];
275275
ResultCode(ctru_sys::ACU_GetProxyUserName(vec.as_mut_ptr()))?;
276276

277-
Ok(String::from_utf8(vec)?)
277+
Ok(vec)
278278
}
279279
}
280280

@@ -293,18 +293,18 @@ impl Ac {
293293
///
294294
/// let ac = Ac::new()?;
295295
///
296-
/// println!("Proxy password: {}", ac.proxy_password()?);
296+
/// println!("Proxy password: {}", String::from_utf8(ac.proxy_password()?)?);
297297
/// #
298298
/// # Ok(())
299299
/// # }
300300
/// ```
301301
#[doc(alias = "ACU_GetProxyPassword")]
302-
pub fn proxy_password(&self) -> crate::Result<String> {
302+
pub fn proxy_password(&self) -> crate::Result<Vec<u8>> {
303303
unsafe {
304304
let mut vec = vec![0u8; 0x20];
305305
ResultCode(ctru_sys::ACU_GetProxyPassword(vec.as_mut_ptr()))?;
306306

307-
Ok(String::from_utf8(vec))
307+
Ok(vec)
308308
}
309309
}
310310

@@ -320,7 +320,7 @@ impl Ac {
320320
/// #
321321
/// use ctru::services::ac::{Ac, NetworkSlot};
322322
///
323-
/// let ac = Ac::new()?;
323+
/// let mut ac = Ac::new()?;
324324
///
325325
/// ac.load_network_slot(NetworkSlot::Second)?;
326326
/// #

0 commit comments

Comments
 (0)