Browse Source

Fixed typos, nits and small issues

pull/50/head
Andrea Ciliberti 3 years ago
parent
commit
447ef1eaa2
  1. 2
      ctru-rs/examples/buttons.rs
  2. 2
      ctru-rs/examples/file-explorer.rs
  3. 2
      ctru-rs/examples/futures-basic.rs
  4. 2
      ctru-rs/examples/futures-tokio.rs
  5. 2
      ctru-rs/examples/gfx-wide-mode.rs
  6. 2
      ctru-rs/examples/graphics-bitmap.rs
  7. 2
      ctru-rs/examples/hashmaps.rs
  8. 2
      ctru-rs/examples/hello-both-screens.rs
  9. 2
      ctru-rs/examples/hello-world.rs
  10. 2
      ctru-rs/examples/network-sockets.rs
  11. 2
      ctru-rs/examples/romfs.rs
  12. 2
      ctru-rs/examples/software-keyboard.rs
  13. 2
      ctru-rs/examples/thread-basic.rs
  14. 2
      ctru-rs/examples/thread-locals.rs
  15. 2
      ctru-rs/examples/time-rtc.rs
  16. 5
      ctru-rs/src/error.rs
  17. 17
      ctru-rs/src/gfx.rs
  18. 7
      ctru-rs/src/romfs.rs
  19. 10
      ctru-rs/src/services/apt.rs
  20. 8
      ctru-rs/src/services/fs.rs
  21. 7
      ctru-rs/src/services/hid.rs
  22. 7
      ctru-rs/src/services/soc.rs
  23. 8
      ctru-rs/src/services/sslc.rs
  24. 7
      ctru-rs/src/srv.rs
  25. 2
      ctru-rs/src/test_runner.rs

2
ctru-rs/examples/buttons.rs

@ -8,7 +8,7 @@ fn main() { @@ -8,7 +8,7 @@ fn main() {
ctru::init();
let apt = Apt::init().unwrap();
let hid = Hid::init().unwrap();
let gfx = Gfx::init_default().unwrap();
let gfx = Gfx::init().unwrap();
let console = Console::init(gfx.top_screen.borrow_mut());
println!("Hi there! Try pressing a button");

2
ctru-rs/examples/file-explorer.rs

@ -14,7 +14,7 @@ fn main() { @@ -14,7 +14,7 @@ fn main() {
ctru::init();
let apt = Apt::init().unwrap();
let hid = Hid::init().unwrap();
let gfx = Gfx::init_default().unwrap();
let gfx = Gfx::init().unwrap();
#[cfg(all(feature = "romfs", romfs_exists))]
let _romfs = ctru::romfs::RomFS::init().unwrap();

2
ctru-rs/examples/futures-basic.rs

@ -13,7 +13,7 @@ use futures::StreamExt; @@ -13,7 +13,7 @@ use futures::StreamExt;
fn main() {
ctru::init();
let gfx = Gfx::init_default().expect("Couldn't obtaint GFX controller");
let gfx = Gfx::init().expect("Couldn't obtain GFX controller");
let hid = Hid::init().expect("Couldn't obtain HID controller");
let apt = Apt::init().expect("Couldn't obtain APT controller");
let _console = Console::init(gfx.top_screen.borrow_mut());

2
ctru-rs/examples/futures-tokio.rs

@ -6,7 +6,7 @@ use std::time::Duration; @@ -6,7 +6,7 @@ use std::time::Duration;
fn main() {
ctru::init();
let gfx = Gfx::init_default().expect("Couldn't obtaint GFX controller");
let gfx = Gfx::init().expect("Couldn't obtain GFX controller");
let hid = Hid::init().expect("Couldn't obtain HID controller");
let apt = Apt::init().expect("Couldn't obtain APT controller");
let _console = Console::init(gfx.top_screen.borrow_mut());

2
ctru-rs/examples/gfx-wide-mode.rs

@ -7,7 +7,7 @@ fn main() { @@ -7,7 +7,7 @@ fn main() {
ctru::init();
let apt = Apt::init().unwrap();
let hid = Hid::init().unwrap();
let gfx = Gfx::init_default().unwrap();
let gfx = Gfx::init().unwrap();
let mut console = Console::init(gfx.top_screen.borrow_mut());
println!("Press A to enable/disable wide screen mode.");

2
ctru-rs/examples/graphics-bitmap.rs

@ -19,7 +19,7 @@ static IMAGE: &[u8] = include_bytes!("assets/ferris.rgb"); @@ -19,7 +19,7 @@ static IMAGE: &[u8] = include_bytes!("assets/ferris.rgb");
fn main() {
ctru::init();
let gfx = Gfx::init_default().expect("Couldn't obtaint GFX controller");
let gfx = Gfx::init().expect("Couldn't obtain GFX controller");
let hid = Hid::init().expect("Couldn't obtain HID controller");
let apt = Apt::init().expect("Couldn't obtain APT controller");
let _console = Console::init(gfx.top_screen.borrow_mut());

2
ctru-rs/examples/hashmaps.rs

@ -12,7 +12,7 @@ fn main() { @@ -12,7 +12,7 @@ fn main() {
ctru::init();
let apt = Apt::init().unwrap();
let hid = Hid::init().unwrap();
let gfx = Gfx::init_default().unwrap();
let gfx = Gfx::init().unwrap();
let _console = Console::init(gfx.top_screen.borrow_mut());
let mut map = std::collections::HashMap::new();

2
ctru-rs/examples/hello-both-screens.rs

@ -8,7 +8,7 @@ fn main() { @@ -8,7 +8,7 @@ fn main() {
ctru::init();
let apt = Apt::init().unwrap();
let hid = Hid::init().unwrap();
let gfx = Gfx::init_default().unwrap();
let gfx = Gfx::init().unwrap();
// Start a console on the top screen
let top_screen = Console::init(gfx.top_screen.borrow_mut());

2
ctru-rs/examples/hello-world.rs

@ -7,7 +7,7 @@ use std::io::BufWriter; @@ -7,7 +7,7 @@ use std::io::BufWriter;
fn main() {
ctru::init();
let gfx = Gfx::init_default().expect("Couldn't obtain GFX controller");
let gfx = Gfx::init().expect("Couldn't obtain GFX controller");
let hid = Hid::init().expect("Couldn't obtain HID controller");
let apt = Apt::init().expect("Couldn't obtain APT controller");
let _console = Console::init(gfx.top_screen.borrow_mut());

2
ctru-rs/examples/network-sockets.rs

@ -10,7 +10,7 @@ use std::time::Duration; @@ -10,7 +10,7 @@ use std::time::Duration;
fn main() {
ctru::init();
let gfx = Gfx::init_default().unwrap();
let gfx = Gfx::init().unwrap();
let _console = Console::init(gfx.top_screen.borrow_mut());
let hid = Hid::init().unwrap();
let apt = Apt::init().unwrap();

2
ctru-rs/examples/romfs.rs

@ -5,7 +5,7 @@ use ctru::services::hid::{Hid, KeyPad}; @@ -5,7 +5,7 @@ use ctru::services::hid::{Hid, KeyPad};
fn main() {
ctru::init();
let gfx = Gfx::init_default().expect("Couldn't obtaint GFX controller");
let gfx = Gfx::init().expect("Couldn't obtain GFX controller");
let hid = Hid::init().expect("Couldn't obtain HID controller");
let apt = Apt::init().expect("Couldn't obtain APT controller");
let _console = Console::init(gfx.top_screen.borrow_mut());

2
ctru-rs/examples/software-keyboard.rs

@ -8,7 +8,7 @@ fn main() { @@ -8,7 +8,7 @@ fn main() {
ctru::init();
let apt = Apt::init().unwrap();
let hid = Hid::init().unwrap();
let gfx = Gfx::default();
let gfx = Gfx::init().unwrap();
let _console = Console::init(gfx.top_screen.borrow_mut());
println!("Press A to enter some text or press Start to quit");

2
ctru-rs/examples/thread-basic.rs

@ -11,7 +11,7 @@ fn main() { @@ -11,7 +11,7 @@ fn main() {
ctru::init();
let apt = Apt::init().unwrap();
let hid = Hid::init().unwrap();
let gfx = Gfx::init_default().unwrap();
let gfx = Gfx::init().unwrap();
let _console = Console::init(gfx.top_screen.borrow_mut());
let prio = thread::current().priority();

2
ctru-rs/examples/thread-locals.rs

@ -10,7 +10,7 @@ std::thread_local! { @@ -10,7 +10,7 @@ std::thread_local! {
fn main() {
ctru::init();
let gfx = Gfx::init_default().expect("Couldn't obtaint GFX controller");
let gfx = Gfx::init().expect("Couldn't obtain GFX controller");
gfx.top_screen.borrow_mut().set_wide_mode(true);
let hid = Hid::init().expect("Couldn't obtain HID controller");
let apt = Apt::init().expect("Couldn't obtain APT controller");

2
ctru-rs/examples/time-rtc.rs

@ -6,7 +6,7 @@ use ctru::services::hid::{Hid, KeyPad}; @@ -6,7 +6,7 @@ use ctru::services::hid::{Hid, KeyPad};
fn main() {
ctru::init();
let gfx = Gfx::init_default().expect("Couldn't obtaint GFX controller");
let gfx = Gfx::init().expect("Couldn't obtain GFX controller");
let hid = Hid::init().expect("Couldn't obtain HID controller");
let apt = Apt::init().expect("Couldn't obtain APT controller");

5
ctru-rs/src/error.rs

@ -29,7 +29,10 @@ impl fmt::Debug for Error { @@ -29,7 +29,10 @@ impl fmt::Debug for Error {
.field("summary", &R_SUMMARY(err))
.field("level", &R_LEVEL(err))
.finish(),
Error::ServiceAlreadyActive(service) => write!(f, "Service {service} already active"),
Error::ServiceAlreadyActive(service) => f
.debug_tuple("ServiceAlreadyActive")
.field(&String::from(service))
.finish(),
}
}
}

17
ctru-rs/src/gfx.rs

@ -80,8 +80,8 @@ impl Gfx { @@ -80,8 +80,8 @@ impl Gfx {
/// Initialize the Gfx module with the chosen framebuffer formats for the top and bottom
/// screens
///
/// Use `Gfx::init_default()` instead of this function to initialize the module with default parameters
pub fn init(
/// Use `Gfx::init()` instead of this function to initialize the module with default parameters
pub fn with_formats(
top_fb_fmt: FramebufferFormat,
bottom_fb_fmt: FramebufferFormat,
use_vram_buffers: bool,
@ -102,9 +102,9 @@ impl Gfx { @@ -102,9 +102,9 @@ impl Gfx {
}
/// Creates a new Gfx instance with default init values
/// It's the same as calling: `Gfx::init(FramebufferFormat::Bgr8, FramebufferFormat::Bgr8, false)
pub fn init_default() -> Result<Self> {
Gfx::init(FramebufferFormat::Bgr8, FramebufferFormat::Bgr8, false)
/// It's the same as calling: `Gfx::with_formats(FramebufferFormat::Bgr8, FramebufferFormat::Bgr8, false)
pub fn init() -> Result<Self> {
Gfx::with_formats(FramebufferFormat::Bgr8, FramebufferFormat::Bgr8, false)
}
/// Flushes the current framebuffers
@ -216,7 +216,7 @@ impl Drop for Gfx { @@ -216,7 +216,7 @@ impl Drop for Gfx {
fn drop(&mut self) {
unsafe { ctru_sys::gfxExit() };
GFX_ACTIVE.store(false, Ordering::Release);
GFX_ACTIVE.store(false, Ordering::SeqCst);
}
}
@ -227,6 +227,9 @@ mod tests { @@ -227,6 +227,9 @@ mod tests {
#[test]
fn gfx_duplicate() {
// We don't need to build a `Gfx` because the test runner has one already
assert!(Gfx::init_default().is_err());
match Gfx::init() {
Err(Error::ServiceAlreadyActive("Gfx")) => return,
_ => panic!(),
}
}
}

7
ctru-rs/src/romfs.rs

@ -43,7 +43,7 @@ impl Drop for RomFS { @@ -43,7 +43,7 @@ impl Drop for RomFS {
let mount_name = CStr::from_bytes_with_nul(b"romfs\0").unwrap();
unsafe { ctru_sys::romfsUnmount(mount_name.as_ptr()) };
ROMFS_ACTIVE.store(false, Ordering::Release);
ROMFS_ACTIVE.store(false, Ordering::SeqCst);
}
}
@ -55,6 +55,9 @@ mod tests { @@ -55,6 +55,9 @@ mod tests {
fn romfs_duplicate() {
let _romfs = RomFS::init().unwrap();
assert!(RomFS::init().is_err());
match RomFS::init() {
Err(Error::ServiceAlreadyActive("RomFS")) => return,
_ => panic!(),
}
}
}

10
ctru-rs/src/services/apt.rs

@ -40,7 +40,7 @@ impl Drop for Apt { @@ -40,7 +40,7 @@ impl Drop for Apt {
fn drop(&mut self) {
unsafe { ctru_sys::aptExit() };
APT_ACTIVE.store(false, Ordering::Release);
APT_ACTIVE.store(false, Ordering::SeqCst);
}
}
@ -49,9 +49,11 @@ mod tests { @@ -49,9 +49,11 @@ mod tests {
use super::*;
#[test]
fn gfx_duplicate() {
fn apt_duplicate() {
// We don't need to build a `Apt` because the test runner has one already
assert!(Apt::init().is_err());
match Apt::init() {
Err(Error::ServiceAlreadyActive("Apt")) => return,
_ => panic!(),
}
}
}

8
ctru-rs/src/services/fs.rs

@ -1004,7 +1004,7 @@ impl Drop for Fs { @@ -1004,7 +1004,7 @@ impl Drop for Fs {
ctru_sys::fsExit();
}
FS_ACTIVE.store(false, Ordering::Release);
FS_ACTIVE.store(false, Ordering::SeqCst);
}
}
@ -1083,7 +1083,9 @@ mod tests { @@ -1083,7 +1083,9 @@ mod tests {
fn fs_duplicate() {
let _fs = Fs::init().unwrap();
assert!(Fs::init().is_err());
match Fs::init() {
Err(Error::ServiceAlreadyActive("Fs")) => return,
_ => panic!(),
}
}
}

7
ctru-rs/src/services/hid.rs

@ -164,7 +164,7 @@ impl Drop for Hid { @@ -164,7 +164,7 @@ impl Drop for Hid {
fn drop(&mut self) {
unsafe { ctru_sys::hidExit() };
HID_ACTIVE.store(false, Ordering::Release);
HID_ACTIVE.store(false, Ordering::SeqCst);
}
}
@ -175,6 +175,9 @@ mod tests { @@ -175,6 +175,9 @@ mod tests {
#[test]
fn hid_duplicate() {
// We don't need to build a `Hid` because the test runner has one already
assert!(Hid::init().is_err());
match Hid::init() {
Err(Error::ServiceAlreadyActive("Hid")) => return,
_ => panic!(),
}
}
}

7
ctru-rs/src/services/soc.rs

@ -61,7 +61,7 @@ impl Drop for Soc { @@ -61,7 +61,7 @@ impl Drop for Soc {
free(self.soc_mem as *mut _);
}
SOC_ACTIVE.store(false, Ordering::Release);
SOC_ACTIVE.store(false, Ordering::SeqCst);
}
}
@ -73,6 +73,9 @@ mod tests { @@ -73,6 +73,9 @@ mod tests {
fn soc_duplicate() {
let _soc = Soc::init().unwrap();
assert!(Soc::init().is_err());
match Soc::init() {
Err(Error::ServiceAlreadyActive("Soc")) => return,
_ => panic!(),
}
}
}

8
ctru-rs/src/services/sslc.rs

@ -40,7 +40,7 @@ impl Drop for SslC { @@ -40,7 +40,7 @@ impl Drop for SslC {
fn drop(&mut self) {
unsafe { ctru_sys::sslcExit() };
SSLC_ACTIVE.store(false, Ordering::Release);
SSLC_ACTIVE.store(false, Ordering::SeqCst);
}
}
@ -52,7 +52,9 @@ mod tests { @@ -52,7 +52,9 @@ mod tests {
fn sslc_duplicate() {
let _sslc = SslC::init().unwrap();
assert!(SslC::init().is_err());
match SslC::init() {
Err(Error::ServiceAlreadyActive("SslC")) => return,
_ => panic!(),
}
}
}

7
ctru-rs/src/srv.rs

@ -27,7 +27,7 @@ impl Drop for Srv { @@ -27,7 +27,7 @@ impl Drop for Srv {
fn drop(&mut self) {
unsafe { ctru_sys::srvExit() };
SRV_ACTIVE.store(false, Ordering::Release);
SRV_ACTIVE.store(false, Ordering::SeqCst);
}
}
@ -39,6 +39,9 @@ mod tests { @@ -39,6 +39,9 @@ mod tests {
fn srv_duplicate() {
let _srv = Srv::init().unwrap();
assert!(Srv::init().is_err());
match Srv::init() {
Err(Error::ServiceAlreadyActive("Srv")) => return,
_ => panic!(),
}
}
}

2
ctru-rs/src/test_runner.rs

@ -17,7 +17,7 @@ use crate::services::Apt; @@ -17,7 +17,7 @@ use crate::services::Apt;
pub(crate) fn run(tests: &[&TestDescAndFn]) {
crate::init();
let gfx = Gfx::init_default().unwrap();
let gfx = Gfx::init().unwrap();
let hid = Hid::init().unwrap();
let apt = Apt::init().unwrap();

Loading…
Cancel
Save