Browse Source

Enable running all tests and fix issues

We had a couple `fs` examples unwrapping expected errors, but mostly
everything passed!
pull/135/head
Ian Chamberlain 1 year ago
parent
commit
ee68d9d806
No known key found for this signature in database
GPG Key ID: AE5484D09405AA60
  1. 6
      ctru-rs/examples/audio-filters.rs
  2. 4
      ctru-rs/examples/camera-image.rs
  3. 6
      ctru-rs/examples/file-explorer.rs
  4. 4
      ctru-rs/examples/futures-basic.rs
  5. 4
      ctru-rs/examples/futures-tokio.rs
  6. 3
      ctru-rs/examples/hello-world.rs
  7. 4
      ctru-rs/examples/network-sockets.rs
  8. 4
      ctru-rs/examples/thread-basic.rs
  9. 4
      ctru-rs/examples/thread-info.rs
  10. 4
      ctru-rs/examples/thread-locals.rs
  11. 28
      ctru-rs/src/applets/mii_selector.rs
  12. 34
      ctru-rs/src/applets/swkbd.rs
  13. 11
      ctru-rs/src/console.rs
  14. 8
      ctru-rs/src/error.rs
  15. 10
      ctru-rs/src/prelude.rs
  16. 18
      ctru-rs/src/services/am.rs
  17. 6
      ctru-rs/src/services/apt.rs
  18. 25
      ctru-rs/src/services/cam.rs
  19. 18
      ctru-rs/src/services/cfgu.rs
  20. 83
      ctru-rs/src/services/fs.rs
  21. 21
      ctru-rs/src/services/gfx.rs
  22. 24
      ctru-rs/src/services/hid.rs
  23. 59
      ctru-rs/src/services/ndsp/mod.rs
  24. 12
      ctru-rs/src/services/ndsp/wave.rs
  25. 12
      ctru-rs/src/services/ps.rs
  26. 3
      ctru-rs/src/services/reference.rs
  27. 3
      ctru-rs/src/services/romfs.rs
  28. 15
      ctru-rs/src/services/soc.rs
  29. 3
      ctru-rs/src/services/sslc.rs

6
ctru-rs/examples/audio-filters.rs

@ -8,10 +8,8 @@ use std::f32::consts::PI; @@ -8,10 +8,8 @@ use std::f32::consts::PI;
use ctru::linear::LinearAllocator;
use ctru::prelude::*;
use ctru::services::ndsp::{
wave::{Status, Wave},
AudioFormat, AudioMix, InterpolationType, Ndsp, OutputMode,
};
use ctru::services::ndsp::wave::{Status, Wave};
use ctru::services::ndsp::{AudioFormat, AudioMix, InterpolationType, Ndsp, OutputMode};
// Configuration for the NDSP process and channels.
const SAMPLE_RATE: usize = 22050;

4
ctru-rs/examples/camera-image.rs

@ -2,13 +2,13 @@ @@ -2,13 +2,13 @@
//!
//! This example demonstrates how to use the built-in cameras to take a picture and display it to the screen.
use std::time::Duration;
use ctru::prelude::*;
use ctru::services::cam::{Cam, Camera, OutputFormat, ShutterSound, ViewSize};
use ctru::services::gfx::{Flush, Screen, Swap};
use ctru::services::gspgpu::FramebufferFormat;
use std::time::Duration;
const WIDTH: usize = 400;
const HEIGHT: usize = 240;

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

@ -3,13 +3,13 @@ @@ -3,13 +3,13 @@
//! This (rather complex) example creates a working text-based file explorer which shows off using standard library file system APIs to
//! read the SD card and RomFS (if properly read via the `romfs:/` prefix).
use ctru::applets::swkbd::{Button, SoftwareKeyboard};
use ctru::prelude::*;
use std::fs::DirEntry;
use std::os::horizon::fs::MetadataExt;
use std::path::{Path, PathBuf};
use ctru::applets::swkbd::{Button, SoftwareKeyboard};
use ctru::prelude::*;
fn main() {
ctru::use_panic_handler();

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

@ -7,10 +7,10 @@ @@ -7,10 +7,10 @@
#![feature(horizon_thread_ext)]
use ctru::prelude::*;
use std::os::horizon::thread::BuilderExt;
use ctru::prelude::*;
use futures::StreamExt;
use std::os::horizon::thread::BuilderExt;
fn main() {
ctru::use_panic_handler();

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

@ -1,10 +1,10 @@ @@ -1,10 +1,10 @@
#![feature(horizon_thread_ext)]
use ctru::prelude::*;
use std::os::horizon::thread::BuilderExt;
use std::time::Duration;
use ctru::prelude::*;
fn main() {
ctru::use_panic_handler();

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

@ -2,9 +2,10 @@ @@ -2,9 +2,10 @@
//!
//! Simple "Hello World" application to showcase the basic setup needed for any user-oriented app to work.
use ctru::prelude::*;
use std::io::BufWriter;
use ctru::prelude::*;
fn main() {
// Setup the custom panic handler in case any errors arise.
// Thanks to it the user will get promptly notified of any panics.

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

@ -2,12 +2,12 @@ @@ -2,12 +2,12 @@
//!
//! This example showcases the use of network sockets via the `Soc` service and the standard library's implementations.
use ctru::prelude::*;
use std::io::{self, Read, Write};
use std::net::{Shutdown, TcpListener};
use std::time::Duration;
use ctru::prelude::*;
fn main() {
ctru::use_panic_handler();

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

@ -1,10 +1,10 @@ @@ -1,10 +1,10 @@
#![feature(horizon_thread_ext)]
use ctru::prelude::*;
use std::os::horizon::thread::BuilderExt;
use std::time::Duration;
use ctru::prelude::*;
fn main() {
ctru::use_panic_handler();

4
ctru-rs/examples/thread-info.rs

@ -2,10 +2,10 @@ @@ -2,10 +2,10 @@
#![feature(horizon_thread_ext)]
use ctru::prelude::*;
use std::os::horizon::thread::BuilderExt;
use ctru::prelude::*;
fn main() {
ctru::use_panic_handler();

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

@ -1,10 +1,10 @@ @@ -1,10 +1,10 @@
#![feature(horizon_thread_ext)]
use ctru::prelude::*;
use std::cell::RefCell;
use std::os::horizon::thread::BuilderExt;
use ctru::prelude::*;
std::thread_local! {
static MY_LOCAL: RefCell<&'static str> = RefCell::new("initial value");
}

28
ctru-rs/src/applets/mii_selector.rs

@ -3,9 +3,12 @@ @@ -3,9 +3,12 @@
//! This applet opens a window which lets the player/user choose a Mii from the ones present on their console.
//! The selected Mii is readable as a [`Mii`](crate::mii::Mii).
use crate::mii::Mii;
use std::ffi::CString;
use std::fmt;
use bitflags::bitflags;
use std::{ffi::CString, fmt};
use crate::mii::Mii;
/// Index of a Mii on the [`MiiSelector`] interface.
///
@ -97,7 +100,8 @@ impl MiiSelector { @@ -97,7 +100,8 @@ impl MiiSelector {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # fn main() {
/// use ctru::applets::mii_selector::MiiSelector;
///
@ -121,7 +125,8 @@ impl MiiSelector { @@ -121,7 +125,8 @@ impl MiiSelector {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # fn main() {
/// use ctru::applets::mii_selector::{MiiSelector, Options};
/// let mut mii_selector = MiiSelector::new();
@ -145,7 +150,8 @@ impl MiiSelector { @@ -145,7 +150,8 @@ impl MiiSelector {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # fn main() {
/// #
/// use ctru::applets::mii_selector::{Index, MiiSelector};
@ -174,7 +180,8 @@ impl MiiSelector { @@ -174,7 +180,8 @@ impl MiiSelector {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # fn main() {
/// #
/// use ctru::applets::mii_selector::{Index, MiiSelector};
@ -198,7 +205,8 @@ impl MiiSelector { @@ -198,7 +205,8 @@ impl MiiSelector {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # fn main() {
/// #
/// use ctru::applets::mii_selector::{Index, MiiSelector};
@ -222,7 +230,8 @@ impl MiiSelector { @@ -222,7 +230,8 @@ impl MiiSelector {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # fn main() {
/// #
/// use ctru::applets::mii_selector::{Index, MiiSelector};
@ -260,7 +269,8 @@ impl MiiSelector { @@ -260,7 +269,8 @@ impl MiiSelector {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #

34
ctru-rs/src/applets/swkbd.rs

@ -5,14 +5,15 @@ @@ -5,14 +5,15 @@
// TODO: Split the Parental PIN lock operations into a different type.
#![doc(alias = "keyboard")]
use std::fmt::Display;
use std::iter::once;
use std::str;
use bitflags::bitflags;
use ctru_sys::{
self, swkbdInit, swkbdInputText, swkbdSetButton, swkbdSetFeatures, swkbdSetHintText, SwkbdState,
};
use libc;
use std::fmt::Display;
use std::iter::once;
use std::str;
/// Configuration structure to setup the Software Keyboard applet.
#[doc(alias = "SwkbdState")]
@ -160,7 +161,8 @@ impl SoftwareKeyboard { @@ -160,7 +161,8 @@ impl SoftwareKeyboard {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # fn main() {
/// #
/// use ctru::applets::swkbd::{SoftwareKeyboard, Kind};
@ -191,7 +193,8 @@ impl SoftwareKeyboard { @@ -191,7 +193,8 @@ impl SoftwareKeyboard {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
@ -235,7 +238,8 @@ impl SoftwareKeyboard { @@ -235,7 +238,8 @@ impl SoftwareKeyboard {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
@ -266,7 +270,8 @@ impl SoftwareKeyboard { @@ -266,7 +270,8 @@ impl SoftwareKeyboard {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # fn main() {
/// #
/// use ctru::applets::swkbd::{SoftwareKeyboard, Features};
@ -286,7 +291,8 @@ impl SoftwareKeyboard { @@ -286,7 +291,8 @@ impl SoftwareKeyboard {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # fn main() {
/// #
/// use ctru::applets::swkbd::{SoftwareKeyboard, ValidInput, Filters};
@ -309,7 +315,8 @@ impl SoftwareKeyboard { @@ -309,7 +315,8 @@ impl SoftwareKeyboard {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # fn main() {
/// #
/// use ctru::applets::swkbd::{SoftwareKeyboard, ValidInput, Filters};
@ -336,7 +343,8 @@ impl SoftwareKeyboard { @@ -336,7 +343,8 @@ impl SoftwareKeyboard {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # fn main() {
/// #
/// use ctru::applets::swkbd::SoftwareKeyboard;
@ -363,7 +371,8 @@ impl SoftwareKeyboard { @@ -363,7 +371,8 @@ impl SoftwareKeyboard {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # fn main() {
/// #
/// use ctru::applets::swkbd::{SoftwareKeyboard, Button, Kind};
@ -402,7 +411,8 @@ impl SoftwareKeyboard { @@ -402,7 +411,8 @@ impl SoftwareKeyboard {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # fn main() {
/// #
/// use ctru::applets::swkbd::{SoftwareKeyboard, Button, Kind};

11
ctru-rs/src/console.rs

@ -52,12 +52,13 @@ impl<'screen> Console<'screen> { @@ -52,12 +52,13 @@ impl<'screen> Console<'screen> {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
/// use ctru::services::gfx::Gfx;
/// use ctru::console::Console;
/// use ctru::services::gfx::Gfx;
///
/// // Initialize graphics.
/// let gfx = Gfx::new()?;
@ -94,7 +95,8 @@ impl<'screen> Console<'screen> { @@ -94,7 +95,8 @@ impl<'screen> Console<'screen> {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
@ -131,7 +133,8 @@ impl<'screen> Console<'screen> { @@ -131,7 +133,8 @@ impl<'screen> Console<'screen> {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #

8
ctru-rs/src/error.rs

@ -3,10 +3,9 @@ @@ -3,10 +3,9 @@
//! This module holds the generic error and result types to interface with `ctru_sys` and the [`ctru-rs`](crate) safe wrapper.
use std::borrow::Cow;
use std::error;
use std::ffi::CStr;
use std::fmt;
use std::ops::{ControlFlow, FromResidual, Try};
use std::{error, fmt};
use ctru_sys::result::{R_DESCRIPTION, R_LEVEL, R_MODULE, R_SUMMARY};
@ -21,10 +20,11 @@ pub type Result<T> = ::std::result::Result<T, Error>; @@ -21,10 +20,11 @@ pub type Result<T> = ::std::result::Result<T, Error>;
///
/// # Example
///
/// ```no_run
/// ```
/// use ctru::error::{Result, ResultCode};
///
/// pub fn hid_init() -> Result<()> {
/// pub fn main() -> Result<()> {
/// # let _runner = test_runner::GdbRunner::default();
/// // We run an unsafe function which returns a `ctru_sys::Result`.
/// let result: ctru_sys::Result = unsafe { ctru_sys::hidInit() };
///

10
ctru-rs/src/prelude.rs

@ -3,9 +3,7 @@ @@ -3,9 +3,7 @@
//! Particularly useful when writing very small applications.
pub use crate::console::Console;
pub use crate::services::{
apt::Apt,
gfx::Gfx,
hid::{Hid, KeyPad},
soc::Soc,
};
pub use crate::services::apt::Apt;
pub use crate::services::gfx::Gfx;
pub use crate::services::hid::{Hid, KeyPad};
pub use crate::services::soc::Soc;

18
ctru-rs/src/services/am.rs

@ -8,9 +8,10 @@ @@ -8,9 +8,10 @@
#![doc(alias = "app")]
#![doc(alias = "manager")]
use std::marker::PhantomData;
use crate::error::ResultCode;
use crate::services::fs::FsMediaType;
use std::marker::PhantomData;
/// General information about a specific title entry.
#[doc(alias = "AM_TitleEntry")]
@ -61,7 +62,8 @@ impl Am { @@ -61,7 +62,8 @@ impl Am {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
@ -84,11 +86,13 @@ impl Am { @@ -84,11 +86,13 @@ impl Am {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
/// use ctru::services::{fs::FsMediaType, am::Am};
/// use ctru::services::am::Am;
/// use ctru::services::fs::FsMediaType;
/// let app_manager = Am::new()?;
///
/// // Number of titles installed on the Nand storage.
@ -113,11 +117,13 @@ impl Am { @@ -113,11 +117,13 @@ impl Am {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
/// use ctru::services::{fs::FsMediaType, am::Am};
/// use ctru::services::am::Am;
/// use ctru::services::fs::FsMediaType;
/// let app_manager = Am::new()?;
///
/// // Number of apps installed on the SD card storage

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

@ -16,7 +16,8 @@ impl Apt { @@ -16,7 +16,8 @@ impl Apt {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
@ -44,7 +45,8 @@ impl Apt { @@ -44,7 +45,8 @@ impl Apt {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// use std::error::Error;
/// use ctru::services::apt::Apt;
///

25
ctru-rs/src/services/cam.rs

@ -4,10 +4,12 @@ @@ -4,10 +4,12 @@
//! in the form of byte vectors which can be displayed to the screen or used in other ways.
#![doc(alias = "camera")]
use std::time::Duration;
use ctru_sys::Handle;
use crate::error::{Error, ResultCode};
use crate::services::gspgpu::FramebufferFormat;
use ctru_sys::Handle;
use std::time::Duration;
/// Handle to the Camera service.
#[non_exhaustive]
@ -343,7 +345,8 @@ pub trait Camera { @@ -343,7 +345,8 @@ pub trait Camera {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
@ -372,7 +375,8 @@ pub trait Camera { @@ -372,7 +375,8 @@ pub trait Camera {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
@ -841,12 +845,13 @@ pub trait Camera { @@ -841,12 +845,13 @@ pub trait Camera {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # use std::time::Duration;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
/// use ctru::services::cam::{Cam, Camera, ViewSize, OutputFormat};
/// use ctru::services::cam::{Cam, Camera, OutputFormat, ViewSize};
/// let mut cam = Cam::new()?;
///
/// // We borrow the inward facing `Camera`.
@ -859,7 +864,7 @@ pub trait Camera { @@ -859,7 +864,7 @@ pub trait Camera {
/// inward.set_auto_white_balance(true)?;
///
/// // Size of the top screen buffer at 2 bytes per pixel (RGB565).
/// let mut buffer = vec![0; 400*240*2];
/// let mut buffer = vec![0; 400 * 240 * 2];
///
/// // Take picture with 3 seconds of timeout.
/// inward.take_picture(&mut buffer, 400, 240, Duration::from_secs(3));
@ -951,7 +956,8 @@ impl Cam { @@ -951,7 +956,8 @@ impl Cam {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
@ -984,7 +990,8 @@ impl Cam { @@ -984,7 +990,8 @@ impl Cam {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #

18
ctru-rs/src/services/cfgu.rs

@ -84,7 +84,8 @@ impl Cfgu { @@ -84,7 +84,8 @@ impl Cfgu {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
@ -105,7 +106,8 @@ impl Cfgu { @@ -105,7 +106,8 @@ impl Cfgu {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
@ -129,7 +131,8 @@ impl Cfgu { @@ -129,7 +131,8 @@ impl Cfgu {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
@ -153,7 +156,8 @@ impl Cfgu { @@ -153,7 +156,8 @@ impl Cfgu {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
@ -177,7 +181,8 @@ impl Cfgu { @@ -177,7 +181,8 @@ impl Cfgu {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
@ -205,7 +210,8 @@ impl Cfgu { @@ -205,7 +210,8 @@ impl Cfgu {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #

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

@ -5,17 +5,15 @@ @@ -5,17 +5,15 @@
// TODO: Refactor service to accomodate for various changes (such as SMDH support). Properly document the public API.
#![doc(alias = "filesystem")]
use bitflags::bitflags;
use std::ffi::OsString;
use std::io::Error as IoError;
use std::io::ErrorKind as IoErrorKind;
use std::io::Result as IoResult;
use std::io::{Read, Seek, SeekFrom, Write};
use std::mem;
use std::io::{
Error as IoError, ErrorKind as IoErrorKind, Read, Result as IoResult, Seek, SeekFrom, Write,
};
use std::path::{Path, PathBuf};
use std::ptr;
use std::slice;
use std::sync::Arc;
use std::{mem, ptr, slice};
use bitflags::bitflags;
use widestring::{WideCStr, WideCString};
bitflags! {
@ -136,7 +134,8 @@ pub struct Fs(()); @@ -136,7 +134,8 @@ pub struct Fs(());
///
/// # Examples
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// use ctru::services::fs::Fs;
///
/// let mut fs = Fs::new().unwrap();
@ -158,12 +157,14 @@ pub struct Archive { @@ -158,12 +157,14 @@ pub struct Archive {
///
/// Create a new file and write bytes to it:
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
/// use std::io::prelude::*;
/// use ctru::services::fs::{Fs, File};
///
/// use ctru::services::fs::{File, Fs};
///
/// let mut fs = Fs::new()?;
/// let mut sdmc = fs.sdmc()?;
@ -174,12 +175,14 @@ pub struct Archive { @@ -174,12 +175,14 @@ pub struct Archive {
///
/// Read the contents of a file into a `String`::
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
/// use std::io::prelude::*;
/// use ctru::services::fs::{Fs, File};
///
/// use ctru::services::fs::{File, Fs};
///
/// let mut fs = Fs::new()?;
/// let mut sdmc = fs.sdmc()?;
@ -196,13 +199,15 @@ pub struct Archive { @@ -196,13 +199,15 @@ pub struct Archive {
/// It can be more efficient to read the contents of a file with a buffered
/// `Read`er. This can be accomplished with `BufReader<R>`:
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
/// use std::io::BufReader;
/// use std::io::prelude::*;
/// use ctru::services::fs::{Fs, File};
/// use std::io::BufReader;
///
/// use ctru::services::fs::{File, Fs};
///
/// let mut fs = Fs::new()?;
/// let mut sdmc = fs.sdmc()?;
@ -247,33 +252,36 @@ pub struct Metadata { @@ -247,33 +252,36 @@ pub struct Metadata {
///
/// Opening a file to read:
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// use ctru::services::fs::{Fs, OpenOptions};
///
/// let mut fs = Fs::new().unwrap();
/// let mut sdmc_archive = fs.sdmc().unwrap();
/// let file = OpenOptions::new()
/// .read(true)
/// .archive(&sdmc_archive)
/// .open("foo.txt")
/// .unwrap();
/// let result = OpenOptions::new()
/// .read(true)
/// .archive(&sdmc_archive)
/// .open("foo.txt");
///
/// assert!(result.is_err());
/// ```
///
/// Opening a file for both reading and writing, as well as creating it if it
/// doesn't exist:
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// use ctru::services::fs::{Fs, OpenOptions};
///
/// let mut fs = Fs::new().unwrap();
/// let mut sdmc_archive = fs.sdmc().unwrap();
/// let file = OpenOptions::new()
/// .read(true)
/// .write(true)
/// .create(true)
/// .archive(&sdmc_archive)
/// .open("foo.txt")
/// .unwrap();
/// .read(true)
/// .write(true)
/// .create(true)
/// .archive(&sdmc_archive)
/// .open("/foo.txt")
/// .unwrap();
/// ```
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub struct OpenOptions {
@ -380,12 +388,14 @@ impl File { @@ -380,12 +388,14 @@ impl File {
///
/// # Examples
///
/// ```no_run
/// use ctru::services::fs::{Fs, File};
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// use ctru::services::fs::{File, Fs};
///
/// let mut fs = Fs::new().unwrap();
/// let mut fs = Fs::new().unwrap();
/// let mut sdmc_archive = fs.sdmc().unwrap();
/// let mut f = File::open(&sdmc_archive, "/foo.txt").unwrap();
/// // Non-existent file:
/// assert!(File::open(&sdmc_archive, "/foo.txt").is_err());
/// ```
pub fn open<P: AsRef<Path>>(arch: &Archive, path: P) -> IoResult<File> {
OpenOptions::new()
@ -407,10 +417,11 @@ impl File { @@ -407,10 +417,11 @@ impl File {
///
/// # Examples
///
/// ```no_run
/// use ctru::services::fs::{Fs, File};
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// use ctru::services::fs::{File, Fs};
///
/// let mut fs = Fs::new().unwrap();
/// let mut fs = Fs::new().unwrap();
/// let mut sdmc_archive = fs.sdmc().unwrap();
/// let mut f = File::create(&mut sdmc_archive, "/foo.txt").unwrap();
/// ```

21
ctru-rs/src/services/gfx.rs

@ -253,7 +253,8 @@ impl Gfx { @@ -253,7 +253,8 @@ impl Gfx {
///
/// It's the same as calling:
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
@ -268,7 +269,8 @@ impl Gfx { @@ -268,7 +269,8 @@ impl Gfx {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
@ -290,11 +292,13 @@ impl Gfx { @@ -290,11 +292,13 @@ impl Gfx {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
/// use ctru::services::{gfx::Gfx, gspgpu::FramebufferFormat};
/// use ctru::services::gfx::Gfx;
/// use ctru::services::gspgpu::FramebufferFormat;
///
/// // Top screen uses RGBA8, bottom screen uses RGB565.
/// // The screen buffers are allocated in the standard HEAP memory, and not in VRAM.
@ -333,11 +337,13 @@ impl Gfx { @@ -333,11 +337,13 @@ impl Gfx {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
/// use ctru::services::{apt::Apt, gfx::Gfx};
/// use ctru::services::apt::Apt;
/// use ctru::services::gfx::Gfx;
/// let apt = Apt::new()?;
/// let gfx = Gfx::new()?;
///
@ -376,7 +382,8 @@ impl TopScreen3D<'_> { @@ -376,7 +382,8 @@ impl TopScreen3D<'_> {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #

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

@ -7,9 +7,10 @@ @@ -7,9 +7,10 @@
#![doc(alias = "controller")]
#![doc(alias = "gamepad")]
use crate::error::ResultCode;
use bitflags::bitflags;
use crate::error::ResultCode;
bitflags! {
/// A set of flags corresponding to the button and directional pad inputs present on the 3DS.
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)]
@ -87,7 +88,8 @@ impl Hid { @@ -87,7 +88,8 @@ impl Hid {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
@ -113,7 +115,8 @@ impl Hid { @@ -113,7 +115,8 @@ impl Hid {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
@ -135,7 +138,8 @@ impl Hid { @@ -135,7 +138,8 @@ impl Hid {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
@ -164,7 +168,8 @@ impl Hid { @@ -164,7 +168,8 @@ impl Hid {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
@ -193,7 +198,8 @@ impl Hid { @@ -193,7 +198,8 @@ impl Hid {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
@ -225,7 +231,8 @@ impl Hid { @@ -225,7 +231,8 @@ impl Hid {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
@ -258,7 +265,8 @@ impl Hid { @@ -258,7 +265,8 @@ impl Hid {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #

59
ctru-rs/src/services/ndsp/mod.rs

@ -6,17 +6,16 @@ @@ -6,17 +6,16 @@
#![doc(alias = "audio")]
pub mod wave;
use std::cell::{RefCell, RefMut};
use std::default::Default;
use std::sync::Mutex;
use std::{error, fmt};
use wave::{Status, Wave};
use crate::error::ResultCode;
use crate::services::ServiceReference;
use std::cell::{RefCell, RefMut};
use std::default::Default;
use std::error;
use std::fmt;
use std::sync::Mutex;
const NUMBER_OF_CHANNELS: u8 = 24;
/// Audio output mode.
@ -118,7 +117,8 @@ impl Ndsp { @@ -118,7 +117,8 @@ impl Ndsp {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
@ -158,7 +158,8 @@ impl Ndsp { @@ -158,7 +158,8 @@ impl Ndsp {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
@ -189,7 +190,8 @@ impl Ndsp { @@ -189,7 +190,8 @@ impl Ndsp {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
@ -213,7 +215,8 @@ impl Channel<'_> { @@ -213,7 +215,8 @@ impl Channel<'_> {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
@ -235,7 +238,8 @@ impl Channel<'_> { @@ -235,7 +238,8 @@ impl Channel<'_> {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
@ -257,7 +261,8 @@ impl Channel<'_> { @@ -257,7 +261,8 @@ impl Channel<'_> {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
@ -280,7 +285,8 @@ impl Channel<'_> { @@ -280,7 +285,8 @@ impl Channel<'_> {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
@ -303,7 +309,8 @@ impl Channel<'_> { @@ -303,7 +309,8 @@ impl Channel<'_> {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
@ -339,7 +346,8 @@ impl Channel<'_> { @@ -339,7 +346,8 @@ impl Channel<'_> {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
@ -366,7 +374,8 @@ impl Channel<'_> { @@ -366,7 +374,8 @@ impl Channel<'_> {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
@ -390,7 +399,8 @@ impl Channel<'_> { @@ -390,7 +399,8 @@ impl Channel<'_> {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
@ -415,7 +425,8 @@ impl Channel<'_> { @@ -415,7 +425,8 @@ impl Channel<'_> {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # use std::default::Default;
/// # fn main() -> Result<(), Box<dyn Error>> {
@ -439,7 +450,8 @@ impl Channel<'_> { @@ -439,7 +450,8 @@ impl Channel<'_> {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
@ -464,7 +476,8 @@ impl Channel<'_> { @@ -464,7 +476,8 @@ impl Channel<'_> {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
@ -493,13 +506,15 @@ impl Channel<'_> { @@ -493,13 +506,15 @@ impl Channel<'_> {
///
/// # Example
///
/// ```no_run
/// ```
/// # #![feature(allocator_api)]
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// # let _runner = test_runner::GdbRunner::default();
/// #
/// # use ctru::linear::LinearAllocator;
/// use ctru::services::ndsp::{AudioFormat, Ndsp, wave::Wave};
/// use ctru::services::ndsp::wave::Wave;
/// use ctru::services::ndsp::{AudioFormat, Ndsp};
/// let ndsp = Ndsp::new()?;
/// let mut channel_0 = ndsp.channel(0)?;
///

12
ctru-rs/src/services/ndsp/wave.rs

@ -36,12 +36,14 @@ impl Wave { @@ -36,12 +36,14 @@ impl Wave {
///
/// # Example
///
/// ```no_run
/// ```
/// # #![feature(allocator_api)]
/// # fn main() {
/// # let _runner = test_runner::GdbRunner::default();
/// #
/// use ctru::linear::LinearAllocator;
/// use ctru::services::ndsp::{AudioFormat, wave::Wave};
/// use ctru::services::ndsp::wave::Wave;
/// use ctru::services::ndsp::AudioFormat;
///
/// // Zeroed box allocated in the LINEAR memory.
/// let audio_data = Box::new_in([0u8; 96], LinearAllocator);
@ -110,14 +112,16 @@ impl Wave { @@ -110,14 +112,16 @@ impl Wave {
///
/// # Example
///
/// ```no_run
/// ```
/// # #![feature(allocator_api)]
/// # fn main() {
/// # let _runner = test_runner::GdbRunner::default();
/// #
/// # use ctru::linear::LinearAllocator;
/// # let _audio_data = Box::new_in([0u8; 96], LinearAllocator);
/// #
/// use ctru::services::ndsp::{AudioFormat, wave::{Wave, Status}};
/// use ctru::services::ndsp::wave::{Status, Wave};
/// use ctru::services::ndsp::AudioFormat;
///
/// // Provide your own audio data.
/// let wave = Wave::new(_audio_data, AudioFormat::PCM16Stereo, false);

12
ctru-rs/src/services/ps.rs

@ -63,7 +63,8 @@ impl Ps { @@ -63,7 +63,8 @@ impl Ps {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
@ -86,7 +87,8 @@ impl Ps { @@ -86,7 +87,8 @@ impl Ps {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
@ -110,7 +112,8 @@ impl Ps { @@ -110,7 +112,8 @@ impl Ps {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
@ -134,7 +137,8 @@ impl Ps { @@ -134,7 +137,8 @@ impl Ps {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #

3
ctru-rs/src/services/reference.rs

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
use crate::Error;
use std::sync::Mutex;
use crate::Error;
pub(crate) struct ServiceReference {
counter: &'static Mutex<usize>,
close: Box<dyn Fn() + Send + Sync>,

3
ctru-rs/src/services/romfs.rs

@ -45,7 +45,8 @@ impl RomFS { @@ -45,7 +45,8 @@ impl RomFS {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #

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

@ -5,10 +5,11 @@ @@ -5,10 +5,11 @@
#![doc(alias = "socket")]
#![doc(alias = "network")]
use libc::memalign;
use std::net::Ipv4Addr;
use std::sync::Mutex;
use libc::memalign;
use crate::error::ResultCode;
use crate::services::ServiceReference;
use crate::Error;
@ -30,7 +31,8 @@ impl Soc { @@ -30,7 +31,8 @@ impl Soc {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
@ -56,7 +58,8 @@ impl Soc { @@ -56,7 +58,8 @@ impl Soc {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
@ -97,7 +100,8 @@ impl Soc { @@ -97,7 +100,8 @@ impl Soc {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
@ -130,7 +134,8 @@ impl Soc { @@ -130,7 +134,8 @@ impl Soc {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #

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

@ -12,7 +12,8 @@ impl SslC { @@ -12,7 +12,8 @@ impl SslC {
///
/// # Example
///
/// ```no_run
/// ```
/// # let _runner = test_runner::GdbRunner::default();
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #

Loading…
Cancel
Save