Browse Source

Revert accidental formatting changes

pull/135/head
Ian Chamberlain 1 year ago
parent
commit
33268566c8
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. 7
      ctru-rs/src/applets/swkbd.rs
  13. 3
      ctru-rs/src/error.rs
  14. 3
      ctru-rs/src/lib.rs
  15. 10
      ctru-rs/src/prelude.rs
  16. 3
      ctru-rs/src/services/am.rs
  17. 8
      ctru-rs/src/services/cam.rs
  18. 32
      ctru-rs/src/services/fs.rs
  19. 3
      ctru-rs/src/services/hid.rs
  20. 11
      ctru-rs/src/services/ndsp/mod.rs
  21. 6
      ctru-rs/src/services/ndsp/wave.rs
  22. 3
      ctru-rs/src/services/reference.rs
  23. 2
      ctru-rs/src/services/romfs.rs
  24. 3
      ctru-rs/src/services/soc.rs

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

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

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

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

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

@ -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 //! 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). //! 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::fs::DirEntry;
use std::os::horizon::fs::MetadataExt; use std::os::horizon::fs::MetadataExt;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use ctru::applets::swkbd::{Button, SoftwareKeyboard};
use ctru::prelude::*;
fn main() { fn main() {
ctru::use_panic_handler(); ctru::use_panic_handler();

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -5,15 +5,14 @@
// TODO: Split the Parental PIN lock operations into a different type. // TODO: Split the Parental PIN lock operations into a different type.
#![doc(alias = "keyboard")] #![doc(alias = "keyboard")]
use std::fmt::Display;
use std::iter::once;
use std::str;
use bitflags::bitflags; use bitflags::bitflags;
use ctru_sys::{ use ctru_sys::{
self, swkbdInit, swkbdInputText, swkbdSetButton, swkbdSetFeatures, swkbdSetHintText, SwkbdState, self, swkbdInit, swkbdInputText, swkbdSetButton, swkbdSetFeatures, swkbdSetHintText, SwkbdState,
}; };
use libc; use libc;
use std::fmt::Display;
use std::iter::once;
use std::str;
/// Configuration structure to setup the Software Keyboard applet. /// Configuration structure to setup the Software Keyboard applet.
#[doc(alias = "SwkbdState")] #[doc(alias = "SwkbdState")]

3
ctru-rs/src/error.rs

@ -3,9 +3,10 @@
//! This module holds the generic error and result types to interface with `ctru_sys` and the [`ctru-rs`](crate) safe wrapper. //! 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::borrow::Cow;
use std::error;
use std::ffi::CStr; use std::ffi::CStr;
use std::fmt;
use std::ops::{ControlFlow, FromResidual, Try}; use std::ops::{ControlFlow, FromResidual, Try};
use std::{error, fmt};
use ctru_sys::result::{R_DESCRIPTION, R_LEVEL, R_MODULE, R_SUMMARY}; use ctru_sys::result::{R_DESCRIPTION, R_LEVEL, R_MODULE, R_SUMMARY};

3
ctru-rs/src/lib.rs

@ -76,9 +76,8 @@ pub fn use_panic_handler() {
/// When `test` is enabled, this function will be ignored. /// When `test` is enabled, this function will be ignored.
#[cfg(not(test))] #[cfg(not(test))]
fn panic_hook_setup() { fn panic_hook_setup() {
use std::panic::PanicInfo;
use crate::services::hid::{Hid, KeyPad}; use crate::services::hid::{Hid, KeyPad};
use std::panic::PanicInfo;
let main_thread = std::thread::current().id(); let main_thread = std::thread::current().id();

10
ctru-rs/src/prelude.rs

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

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

@ -8,10 +8,9 @@
#![doc(alias = "app")] #![doc(alias = "app")]
#![doc(alias = "manager")] #![doc(alias = "manager")]
use std::marker::PhantomData;
use crate::error::ResultCode; use crate::error::ResultCode;
use crate::services::fs::FsMediaType; use crate::services::fs::FsMediaType;
use std::marker::PhantomData;
/// General information about a specific title entry. /// General information about a specific title entry.
#[doc(alias = "AM_TitleEntry")] #[doc(alias = "AM_TitleEntry")]

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

@ -4,12 +4,10 @@
//! in the form of byte vectors which can be displayed to the screen or used in other ways. //! in the form of byte vectors which can be displayed to the screen or used in other ways.
#![doc(alias = "camera")] #![doc(alias = "camera")]
use std::time::Duration;
use ctru_sys::Handle;
use crate::error::{Error, ResultCode}; use crate::error::{Error, ResultCode};
use crate::services::gspgpu::FramebufferFormat; use crate::services::gspgpu::FramebufferFormat;
use ctru_sys::Handle;
use std::time::Duration;
/// Handle to the Camera service. /// Handle to the Camera service.
#[non_exhaustive] #[non_exhaustive]
@ -864,7 +862,7 @@ pub trait Camera {
/// inward.set_auto_white_balance(true)?; /// inward.set_auto_white_balance(true)?;
/// ///
/// // Size of the top screen buffer at 2 bytes per pixel (RGB565). /// // 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. /// // Take picture with 3 seconds of timeout.
/// inward.take_picture(&mut buffer, 400, 240, Duration::from_secs(3)); /// inward.take_picture(&mut buffer, 400, 240, Duration::from_secs(3));

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

@ -5,15 +5,17 @@
// TODO: Refactor service to accomodate for various changes (such as SMDH support). Properly document the public API. // TODO: Refactor service to accomodate for various changes (such as SMDH support). Properly document the public API.
#![doc(alias = "filesystem")] #![doc(alias = "filesystem")]
use bitflags::bitflags;
use std::ffi::OsString; use std::ffi::OsString;
use std::io::{ use std::io::Error as IoError;
Error as IoError, ErrorKind as IoErrorKind, Read, Result as IoResult, Seek, SeekFrom, Write, use std::io::ErrorKind as IoErrorKind;
}; use std::io::Result as IoResult;
use std::io::{Read, Seek, SeekFrom, Write};
use std::mem;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::ptr;
use std::slice;
use std::sync::Arc; use std::sync::Arc;
use std::{mem, ptr, slice};
use bitflags::bitflags;
use widestring::{WideCStr, WideCString}; use widestring::{WideCStr, WideCString};
bitflags! { bitflags! {
@ -259,8 +261,8 @@ pub struct Metadata {
/// let mut fs = Fs::new().unwrap(); /// let mut fs = Fs::new().unwrap();
/// let mut sdmc_archive = fs.sdmc().unwrap(); /// let mut sdmc_archive = fs.sdmc().unwrap();
/// let result = OpenOptions::new() /// let result = OpenOptions::new()
/// .read(true) /// .read(true)
/// .archive(&sdmc_archive) /// .archive(&sdmc_archive)
/// .open("foo.txt"); /// .open("foo.txt");
/// ///
/// assert!(result.is_err()); /// assert!(result.is_err());
@ -276,12 +278,12 @@ pub struct Metadata {
/// let mut fs = Fs::new().unwrap(); /// let mut fs = Fs::new().unwrap();
/// let mut sdmc_archive = fs.sdmc().unwrap(); /// let mut sdmc_archive = fs.sdmc().unwrap();
/// let file = OpenOptions::new() /// let file = OpenOptions::new()
/// .read(true) /// .read(true)
/// .write(true) /// .write(true)
/// .create(true) /// .create(true)
/// .archive(&sdmc_archive) /// .archive(&sdmc_archive)
/// .open("/foo.txt") /// .open("/foo.txt")
/// .unwrap(); /// .unwrap();
/// ``` /// ```
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub struct OpenOptions { pub struct OpenOptions {
@ -392,7 +394,7 @@ impl File {
/// # let _runner = test_runner::GdbRunner::default(); /// # let _runner = test_runner::GdbRunner::default();
/// use ctru::services::fs::{File, Fs}; /// 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 sdmc_archive = fs.sdmc().unwrap();
/// // Non-existent file: /// // Non-existent file:
/// assert!(File::open(&sdmc_archive, "/foo.txt").is_err()); /// assert!(File::open(&sdmc_archive, "/foo.txt").is_err());
@ -421,7 +423,7 @@ impl File {
/// # let _runner = test_runner::GdbRunner::default(); /// # let _runner = test_runner::GdbRunner::default();
/// use ctru::services::fs::{File, Fs}; /// 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 sdmc_archive = fs.sdmc().unwrap();
/// let mut f = File::create(&mut sdmc_archive, "/foo.txt").unwrap(); /// let mut f = File::create(&mut sdmc_archive, "/foo.txt").unwrap();
/// ``` /// ```

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

@ -7,9 +7,8 @@
#![doc(alias = "controller")] #![doc(alias = "controller")]
#![doc(alias = "gamepad")] #![doc(alias = "gamepad")]
use bitflags::bitflags;
use crate::error::ResultCode; use crate::error::ResultCode;
use bitflags::bitflags;
bitflags! { bitflags! {
/// A set of flags corresponding to the button and directional pad inputs present on the 3DS. /// A set of flags corresponding to the button and directional pad inputs present on the 3DS.

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

@ -15,16 +15,17 @@
// https://github.com/citra-emu/citra/issues/6111 // https://github.com/citra-emu/citra/issues/6111
pub mod wave; 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 wave::{Status, Wave};
use crate::error::ResultCode; use crate::error::ResultCode;
use crate::services::ServiceReference; 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; const NUMBER_OF_CHANNELS: u8 = 24;
/// Audio output mode. /// Audio output mode.

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

@ -42,8 +42,7 @@ impl Wave {
/// # let _runner = test_runner::GdbRunner::default(); /// # let _runner = test_runner::GdbRunner::default();
/// # /// #
/// use ctru::linear::LinearAllocator; /// use ctru::linear::LinearAllocator;
/// use ctru::services::ndsp::wave::Wave; /// use ctru::services::ndsp::{AudioFormat, wave::Wave};
/// use ctru::services::ndsp::AudioFormat;
/// ///
/// // Zeroed box allocated in the LINEAR memory. /// // Zeroed box allocated in the LINEAR memory.
/// let audio_data = Box::new_in([0u8; 96], LinearAllocator); /// let audio_data = Box::new_in([0u8; 96], LinearAllocator);
@ -120,8 +119,7 @@ impl Wave {
/// # use ctru::linear::LinearAllocator; /// # use ctru::linear::LinearAllocator;
/// # let _audio_data = Box::new_in([0u8; 96], LinearAllocator); /// # let _audio_data = Box::new_in([0u8; 96], LinearAllocator);
/// # /// #
/// use ctru::services::ndsp::wave::{Status, Wave}; /// use ctru::services::ndsp::{AudioFormat, wave::{Wave, Status}};
/// use ctru::services::ndsp::AudioFormat;
/// ///
/// // Provide your own audio data. /// // Provide your own audio data.
/// let wave = Wave::new(_audio_data, AudioFormat::PCM16Stereo, false); /// let wave = Wave::new(_audio_data, AudioFormat::PCM16Stereo, false);

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

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

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

@ -27,10 +27,10 @@
#![doc(alias = "embed")] #![doc(alias = "embed")]
#![doc(alias = "filesystem")] #![doc(alias = "filesystem")]
use crate::error::ResultCode;
use std::ffi::CStr; use std::ffi::CStr;
use std::sync::Mutex; use std::sync::Mutex;
use crate::error::ResultCode;
use crate::services::ServiceReference; use crate::services::ServiceReference;
/// Handle to the RomFS service. /// Handle to the RomFS service.

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

@ -5,11 +5,10 @@
#![doc(alias = "socket")] #![doc(alias = "socket")]
#![doc(alias = "network")] #![doc(alias = "network")]
use libc::memalign;
use std::net::Ipv4Addr; use std::net::Ipv4Addr;
use std::sync::Mutex; use std::sync::Mutex;
use libc::memalign;
use crate::error::ResultCode; use crate::error::ResultCode;
use crate::services::ServiceReference; use crate::services::ServiceReference;
use crate::Error; use crate::Error;

Loading…
Cancel
Save