Browse Source

Fixed all compiler warnings for docs

pull/134/head
Andrea Ciliberti 1 year ago
parent
commit
4124df8612
  1. 5
      ctru-rs/src/applets/mii_selector.rs
  2. 5
      ctru-rs/src/applets/mod.rs
  3. 4
      ctru-rs/src/applets/swkbd.rs
  4. 16
      ctru-rs/src/console.rs
  5. 4
      ctru-rs/src/prelude.rs
  6. 2
      ctru-rs/src/services/gfx.rs
  7. 2
      ctru-rs/src/services/hid.rs
  8. 19
      ctru-rs/src/services/ndsp/mod.rs
  9. 2
      ctru-rs/src/services/ndsp/wave.rs
  10. 5
      ctru-rs/src/services/ps.rs
  11. 7
      ctru-rs/src/services/romfs.rs

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

@ -1,6 +1,7 @@
//! Mii Selector applet //! Mii Selector applet.
//! //!
//! This module contains the methods to launch the Mii Selector. //! This applet opens a window on the console's bottom screen which lets the player/user choose a Mii from the ones present on their console.
//! The application can access the selected Mii's data via the use of the [`mii`](crate::mii) module.
use crate::mii::MiiData; use crate::mii::MiiData;
use bitflags::bitflags; use bitflags::bitflags;

5
ctru-rs/src/applets/mod.rs

@ -1,2 +1,7 @@
//! System Applets.
//!
//! Applets are small integrated programs that the OS makes available to the developer to streamline commonly needed functionality.
//! Thanks to these integrations the developer can avoid wasting time re-implementing common features and instead use a more reliable base for their application.
pub mod mii_selector; pub mod mii_selector;
pub mod swkbd; pub mod swkbd;

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

@ -1,3 +1,7 @@
//! Software Keyboard applet.
//!
//! This applet opens a virtual keyboard on the console's bottom screen which lets the player/user write UTF-16 valid text.
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,

16
ctru-rs/src/console.rs

@ -1,3 +1,5 @@
//! Virtual text console.
use std::cell::RefMut; use std::cell::RefMut;
use std::default::Default; use std::default::Default;
@ -7,6 +9,20 @@ use crate::services::gfx::Screen;
static mut EMPTY_CONSOLE: PrintConsole = unsafe { const_zero::const_zero!(PrintConsole) }; static mut EMPTY_CONSOLE: PrintConsole = unsafe { const_zero::const_zero!(PrintConsole) };
/// Virtual printable console.
///
/// [`Console`] lets the application redirect `stdout` to a simple text displayer on the 3DS screen.
/// This means that any text written to `stdout` (e.g. using [`println!`] or [`dbg!`]) will become visible in the area taken by the console.
///
/// # Notes
///
/// The console will take full possession of the screen handed to it as long as it stays alive. It also supports ANSI codes.
///
/// # Alternatives
///
/// If you'd like to see live `stdout` output while running the application but can't/don't want to show the text on the 3DS itself,
/// you can try using [`Soc::redirect_to_3dslink`](crate::services::soc::Soc::redirect_to_3dslink) while activating the `--server` flag for `3dslink` (also supported by `cargo-3ds`).
/// More info in the `cargo-3ds` docs.
#[doc(alias = "PrintConsole")] #[doc(alias = "PrintConsole")]
pub struct Console<'screen> { pub struct Console<'screen> {
context: Box<PrintConsole>, context: Box<PrintConsole>,

4
ctru-rs/src/prelude.rs

@ -1,3 +1,7 @@
//! `use ctru::prelude::*;` to import common services, members and functions.
//!
//! Particularly useful when writing very small applications.
pub use crate::console::Console; pub use crate::console::Console;
pub use crate::services::{ pub use crate::services::{
apt::Apt, apt::Apt,

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

@ -209,7 +209,9 @@ pub enum Side {
/// ///
/// The service exits when this struct is dropped. /// The service exits when this struct is dropped.
pub struct Gfx { pub struct Gfx {
/// Top screen representation.
pub top_screen: RefCell<TopScreen>, pub top_screen: RefCell<TopScreen>,
/// Bottom screen representation.
pub bottom_screen: RefCell<BottomScreen>, pub bottom_screen: RefCell<BottomScreen>,
_service_handler: ServiceReference, _service_handler: ServiceReference,
} }

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

@ -75,6 +75,7 @@ bitflags::bitflags! {
/// This service requires no special permissions to use. /// This service requires no special permissions to use.
pub struct Hid(()); pub struct Hid(());
impl Hid {
/// Initializes the HID service. /// Initializes the HID service.
/// ///
/// # Errors /// # Errors
@ -82,7 +83,6 @@ pub struct Hid(());
/// This function will return an error if the service was unable to be initialized. /// This function will return an error if the service was unable to be initialized.
/// Since this service requires no special or elevated permissions, errors are /// Since this service requires no special or elevated permissions, errors are
/// rare in practice. /// rare in practice.
impl Hid {
#[doc(alias = "hidInit")] #[doc(alias = "hidInit")]
pub fn new() -> crate::Result<Hid> { pub fn new() -> crate::Result<Hid> {
unsafe { unsafe {

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

@ -1,4 +1,4 @@
//! NDSP (Audio) service //! NDSP (Audio) service.
pub mod wave; pub mod wave;
use wave::{Wave, WaveStatus}; use wave::{Wave, WaveStatus};
@ -73,6 +73,19 @@ pub enum NdspError {
SampleCountOutOfBounds(usize, usize), SampleCountOutOfBounds(usize, usize),
} }
/// NDSP Channel representation.
///
/// There are 24 individual channels in total and each can play a different audio [`Wave`] simultaneuosly.
///
/// # Default
///
/// NDSP initialises all channels with default values on creation, but the developer is supposed to change these values to correctly work with the service.
///
/// In particular:
/// - Default audio format is set to [`AudioFormat::PCM16Mono`].
/// - Default sample rate is set to 1 Hz.
/// - Default interpolation type is set to [`InterpolationType::Polyphase`].
/// - Default mix is set to [`AudioMix::default()`]
pub struct Channel<'ndsp> { pub struct Channel<'ndsp> {
id: u8, id: u8,
_rf: RefMut<'ndsp, ()>, // we don't need to hold any data _rf: RefMut<'ndsp, ()>, // we don't need to hold any data
@ -169,7 +182,7 @@ impl Channel<'_> {
unsafe { ctru_sys::ndspChnIsPaused(self.id.into()) } unsafe { ctru_sys::ndspChnIsPaused(self.id.into()) }
} }
// Returns the channel's id /// Returns the channel's index.
pub fn id(&self) -> u8 { pub fn id(&self) -> u8 {
self.id self.id
} }
@ -458,8 +471,8 @@ impl AudioMix {
} }
} }
/// Returns an [`AudioMix`] object with "front left" and "front right" volumes set to 100%, and all other volumes set to 0%.
impl Default for AudioMix { impl Default for AudioMix {
/// Returns an [`AudioMix`] object with "front left" and "front right" volumes set to 100%, and all other volumes set to 0%.
fn default() -> Self { fn default() -> Self {
let mut mix = AudioMix::zeroed(); let mut mix = AudioMix::zeroed();
mix.set_front(1.0, 1.0); mix.set_front(1.0, 1.0);

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

@ -1,3 +1,5 @@
//! Audio wave representation.
use super::{AudioFormat, NdspError}; use super::{AudioFormat, NdspError};
use crate::linear::LinearAllocator; use crate::linear::LinearAllocator;

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

@ -52,9 +52,11 @@ pub enum AESKeyType {
KeyslotInvalid = ctru_sys::PS_KEYSLOT_INVALID, KeyslotInvalid = ctru_sys::PS_KEYSLOT_INVALID,
} }
/// Handle to the PS service.
pub struct Ps(()); pub struct Ps(());
impl Ps { impl Ps {
/// Initialize a new service handle.
#[doc(alias = "psInit")] #[doc(alias = "psInit")]
pub fn new() -> Result<Self> { pub fn new() -> Result<Self> {
unsafe { unsafe {
@ -63,6 +65,7 @@ impl Ps {
} }
} }
/// Returns the console's local friend code seed.
#[doc(alias = "PS_GetLocalFriendCodeSeed")] #[doc(alias = "PS_GetLocalFriendCodeSeed")]
pub fn local_friend_code_seed(&self) -> crate::Result<u64> { pub fn local_friend_code_seed(&self) -> crate::Result<u64> {
let mut seed: u64 = 0; let mut seed: u64 = 0;
@ -71,6 +74,7 @@ impl Ps {
Ok(seed) Ok(seed)
} }
/// Returns the console's devide ID.
#[doc(alias = "PS_GetDeviceId")] #[doc(alias = "PS_GetDeviceId")]
pub fn device_id(&self) -> crate::Result<u32> { pub fn device_id(&self) -> crate::Result<u32> {
let mut id: u32 = 0; let mut id: u32 = 0;
@ -79,6 +83,7 @@ impl Ps {
Ok(id) Ok(id)
} }
/// Generates cryptografically secure random bytes and writes them into the `out` buffer.
#[doc(alias = "PS_GenerateRandomBytes")] #[doc(alias = "PS_GenerateRandomBytes")]
pub fn generate_random_bytes(&self, out: &mut [u8]) -> crate::Result<()> { pub fn generate_random_bytes(&self, out: &mut [u8]) -> crate::Result<()> {
ResultCode(unsafe { ResultCode(unsafe {

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

@ -18,6 +18,12 @@ use std::sync::Mutex;
use crate::services::ServiceReference; use crate::services::ServiceReference;
/// Handle to the RomFS service.
///
/// This service lets the application access a virtual mounted device created using a folder included within the application bundle.
/// `ctru` will include as RomFS the folder specified in the `Cargo.toml` manifest (or use `./romfs` by default). Look at the [`romfs`](self) module for more information.
///
/// After mounting the RomFS file system, the included files and folders will be accessible exactly like any other file, just by using the drive prefix `romfs:/`.
pub struct RomFS { pub struct RomFS {
_service_handler: ServiceReference, _service_handler: ServiceReference,
} }
@ -25,6 +31,7 @@ pub struct RomFS {
static ROMFS_ACTIVE: Mutex<usize> = Mutex::new(0); static ROMFS_ACTIVE: Mutex<usize> = Mutex::new(0);
impl RomFS { impl RomFS {
/// Mounts the specified RomFS folder as a virtual drive.
#[doc(alias = "romfsMountSelf")] #[doc(alias = "romfsMountSelf")]
pub fn new() -> crate::Result<Self> { pub fn new() -> crate::Result<Self> {
let _service_handler = ServiceReference::new( let _service_handler = ServiceReference::new(

Loading…
Cancel
Save