Browse Source

Fix issues with ``Fs`` docs

pull/64/head
TechiePi 2 years ago
parent
commit
1e8c6ccacb
  1. 23
      ctru-rs/src/services/fs.rs

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

@ -91,7 +91,7 @@ pub struct Fs(());
/// # Examples /// # Examples
/// ///
/// ```no_run /// ```no_run
/// use ctru::services::fs::Fs /// use ctru::services::fs::Fs;
/// ///
/// let fs = Fs::init().unwrap(); /// let fs = Fs::init().unwrap();
/// let sdmc_archive = fs.sdmc().unwrap(); /// let sdmc_archive = fs.sdmc().unwrap();
@ -116,14 +116,11 @@ pub struct Archive {
/// use std::io::prelude::*; /// use std::io::prelude::*;
/// use ctru::services::fs::{Fs, File}; /// use ctru::services::fs::{Fs, File};
/// ///
/// # fn foo() -> std::io::Result<()> {
/// let fs = Fs::init()?; /// let fs = Fs::init()?;
/// let sdmc = fs.sdmc()?; /// let sdmc = fs.sdmc()?;
/// ///
/// let mut file = File::create(&sdmc, "/foo.txt")?; /// let mut file = File::create(&sdmc, "/foo.txt")?;
/// file.write_all(b"Hello, world!")?; /// file.write_all(b"Hello, world!")?;
/// # Ok(())
/// #}
/// ``` /// ```
/// ///
/// Read the contents of a file into a `String`:: /// Read the contents of a file into a `String`::
@ -132,7 +129,6 @@ pub struct Archive {
/// use std::io::prelude::*; /// use std::io::prelude::*;
/// use ctru::services::fs::{Fs, File}; /// use ctru::services::fs::{Fs, File};
/// ///
/// # fn foo() -> std::io::Result<()> {
/// let fs = Fs::init()?; /// let fs = Fs::init()?;
/// let sdmc = fs.sdmc()?; /// let sdmc = fs.sdmc()?;
/// ///
@ -140,8 +136,6 @@ pub struct Archive {
/// let mut contents = String::new(); /// let mut contents = String::new();
/// file.read_to_string(&mut contents)?; /// file.read_to_string(&mut contents)?;
/// assert_eq!(contents, "Hello, world!"); /// assert_eq!(contents, "Hello, world!");
/// # Ok(())
/// #}
/// ``` /// ```
/// ///
/// It can be more efficient to read the contents of a file with a buffered /// It can be more efficient to read the contents of a file with a buffered
@ -152,7 +146,6 @@ pub struct Archive {
/// use std::io::prelude::*; /// use std::io::prelude::*;
/// use ctru::services::fs::{Fs, File}; /// use ctru::services::fs::{Fs, File};
/// ///
/// # fn foo() -> std::io::Result<()> {
/// let fs = Fs::init()?; /// let fs = Fs::init()?;
/// let sdmc = fs.sdmc()?; /// let sdmc = fs.sdmc()?;
/// ///
@ -161,8 +154,6 @@ pub struct Archive {
/// let mut contents = String::new(); /// let mut contents = String::new();
/// buf_reader.read_to_string(&mut contents)?; /// buf_reader.read_to_string(&mut contents)?;
/// assert_eq!(contents, "Hello, world!"); /// assert_eq!(contents, "Hello, world!");
/// # Ok(())
/// # }
/// ``` /// ```
pub struct File { pub struct File {
handle: u32, handle: u32,
@ -206,7 +197,7 @@ pub struct Metadata {
/// Opening a file to read: /// Opening a file to read:
/// ///
/// ```no_run /// ```no_run
/// use ctru::services::fs::OpenOptions; /// use ctru::services::fs::{Fs, OpenOptions};
/// ///
/// let fs = Fs::init().unwrap(); /// let fs = Fs::init().unwrap();
/// let sdmc_archive = fs.sdmc().unwrap(); /// let sdmc_archive = fs.sdmc().unwrap();
@ -221,7 +212,7 @@ pub struct Metadata {
/// doesn't exist: /// doesn't exist:
/// ///
/// ```no_run /// ```no_run
/// use ctru::services::fs::OpenOptions; /// use ctru::services::fs::{Fs, OpenOptions};
/// ///
/// let fs = Fs::init().unwrap(); /// let fs = Fs::init().unwrap();
/// let sdmc_archive = fs.sdmc().unwrap(); /// let sdmc_archive = fs.sdmc().unwrap();
@ -350,8 +341,8 @@ impl File {
/// ```no_run /// ```no_run
/// use ctru::services::fs::{Fs, File}; /// use ctru::services::fs::{Fs, File};
/// ///
/// let fs = Fs::init().unwrap() /// let fs = Fs::init().unwrap();
/// let sdmc_archive = fs.sdmc().unwrap() /// let sdmc_archive = fs.sdmc().unwrap();
/// let mut f = File::open(&sdmc_archive, "/foo.txt").unwrap(); /// let mut f = File::open(&sdmc_archive, "/foo.txt").unwrap();
/// ``` /// ```
pub fn open<P: AsRef<Path>>(arch: &Archive, path: P) -> IoResult<File> { pub fn open<P: AsRef<Path>>(arch: &Archive, path: P) -> IoResult<File> {
@ -379,8 +370,8 @@ impl File {
/// ```no_run /// ```no_run
/// use ctru::services::fs::{Fs, File}; /// use ctru::services::fs::{Fs, File};
/// ///
/// let fs = Fs::init().unwrap() /// let fs = Fs::init().unwrap();
/// let sdmc_archive = fs.sdmc().unwrap() /// let sdmc_archive = fs.sdmc().unwrap();
/// let mut f = File::create(&sdmc_archive, "/foo.txt").unwrap(); /// let mut f = File::create(&sdmc_archive, "/foo.txt").unwrap();
/// ``` /// ```
pub fn create<P: AsRef<Path>>(arch: &Archive, path: P) -> IoResult<File> { pub fn create<P: AsRef<Path>>(arch: &Archive, path: P) -> IoResult<File> {

Loading…
Cancel
Save