From 1e4002604f37fb850cccb68b3dc3e20cea75585c Mon Sep 17 00:00:00 2001 From: Andrea Ciliberti Date: Wed, 5 Apr 2023 20:58:23 +0200 Subject: [PATCH] Fixed mutability for all modules --- ctru-rs/src/services/apt.rs | 2 +- ctru-rs/src/services/cam.rs | 2 +- ctru-rs/src/services/fs.rs | 20 ++++++++++---------- ctru-rs/src/services/gfx.rs | 6 +++--- ctru-rs/src/services/hid.rs | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/ctru-rs/src/services/apt.rs b/ctru-rs/src/services/apt.rs index 2096a70..aa1dd28 100644 --- a/ctru-rs/src/services/apt.rs +++ b/ctru-rs/src/services/apt.rs @@ -14,7 +14,7 @@ impl Apt { unsafe { ctru_sys::aptMainLoop() } } - pub fn set_app_cpu_time_limit(&self, percent: u32) -> crate::Result<()> { + pub fn set_app_cpu_time_limit(&mut self, percent: u32) -> crate::Result<()> { unsafe { ResultCode(ctru_sys::APT_SetAppCpuTimeLimit(percent))?; Ok(()) diff --git a/ctru-rs/src/services/cam.rs b/ctru-rs/src/services/cam.rs index 520e3e2..52ce926 100644 --- a/ctru-rs/src/services/cam.rs +++ b/ctru-rs/src/services/cam.rs @@ -354,7 +354,7 @@ pub trait Camera { /// The new width will be `trim_width / 2` to the left and right of the center. /// The new height will be `trim_height / 2` above and below the center. fn set_trimming_params_center( - &self, + &mut self, trim_width: i16, trim_height: i16, cam_width: i16, diff --git a/ctru-rs/src/services/fs.rs b/ctru-rs/src/services/fs.rs index 45f9efb..9364bb6 100644 --- a/ctru-rs/src/services/fs.rs +++ b/ctru-rs/src/services/fs.rs @@ -310,7 +310,7 @@ impl Fs { } /// Returns a handle to the SDMC (memory card) Archive. - pub fn sdmc(&self) -> crate::Result { + pub fn sdmc(&mut self) -> crate::Result { unsafe { let mut handle = 0; let id = ArchiveID::Sdmc; @@ -384,7 +384,7 @@ impl File { /// let sdmc_archive = fs.sdmc().unwrap(); /// let mut f = File::create(&sdmc_archive, "/foo.txt").unwrap(); /// ``` - pub fn create>(arch: &Archive, path: P) -> IoResult { + pub fn create>(arch: &mut Archive, path: P) -> IoResult { OpenOptions::new() .write(true) .create(true) @@ -588,11 +588,11 @@ impl OpenOptions { /// * Invalid combinations of open options. /// /// [`Archive`]: struct.Archive.html - pub fn open>(&self, path: P) -> IoResult { + pub fn open>(&mut self, path: P) -> IoResult { self._open(path.as_ref(), self.open_flags()) } - fn _open(&self, path: &Path, flags: FsOpen) -> IoResult { + fn _open(&mut self, path: &Path, flags: FsOpen) -> IoResult { unsafe { let mut file_handle = 0; let path = to_utf16(path); @@ -706,7 +706,7 @@ impl<'a> DirEntry<'a> { /// but is not limited to just these cases: /// /// * User lacks permissions to create directory at `path` -pub fn create_dir>(arch: &Archive, path: P) -> IoResult<()> { +pub fn create_dir>(arch: &mut Archive, path: P) -> IoResult<()> { unsafe { let path = to_utf16(path.as_ref()); let fs_path = ctru_sys::fsMakePath(PathType::UTF16.into(), path.as_ptr() as _); @@ -732,7 +732,7 @@ pub fn create_dir>(arch: &Archive, path: P) -> IoResult<()> { /// /// * If any directory in the path specified by `path` does not already exist /// and it could not be created otherwise. -pub fn create_dir_all>(arch: &Archive, path: P) -> IoResult<()> { +pub fn create_dir_all>(arch: &mut Archive, path: P) -> IoResult<()> { let path = path.as_ref(); let mut dir = PathBuf::new(); let mut result = Ok(()); @@ -768,7 +768,7 @@ pub fn metadata>(arch: &Archive, path: P) -> IoResult { /// /// * The user lacks permissions to remove the directory at the provided path. /// * The directory isn't empty. -pub fn remove_dir>(arch: &Archive, path: P) -> IoResult<()> { +pub fn remove_dir>(arch: &mut Archive, path: P) -> IoResult<()> { unsafe { let path = to_utf16(path.as_ref()); let fs_path = ctru_sys::fsMakePath(PathType::UTF16.into(), path.as_ptr() as _); @@ -786,7 +786,7 @@ pub fn remove_dir>(arch: &Archive, path: P) -> IoResult<()> { /// # Errors /// /// see `file::remove_file` and `fs::remove_dir` -pub fn remove_dir_all>(arch: &Archive, path: P) -> IoResult<()> { +pub fn remove_dir_all>(arch: &mut Archive, path: P) -> IoResult<()> { unsafe { let path = to_utf16(path.as_ref()); let fs_path = ctru_sys::fsMakePath(PathType::UTF16.into(), path.as_ptr() as _); @@ -838,7 +838,7 @@ pub fn read_dir>(arch: &Archive, path: P) -> IoResult { /// /// * path points to a directory. /// * The user lacks permissions to remove the file. -pub fn remove_file>(arch: &Archive, path: P) -> IoResult<()> { +pub fn remove_file>(arch: &mut Archive, path: P) -> IoResult<()> { unsafe { let path = to_utf16(path.as_ref()); let fs_path = ctru_sys::fsMakePath(PathType::UTF16.into(), path.as_ptr() as _); @@ -861,7 +861,7 @@ pub fn remove_file>(arch: &Archive, path: P) -> IoResult<()> { /// /// * from does not exist. /// * The user lacks permissions to view contents. -pub fn rename(arch: &Archive, from: P, to: Q) -> IoResult<()> +pub fn rename(arch: &mut Archive, from: P, to: Q) -> IoResult<()> where P: AsRef, Q: AsRef, diff --git a/ctru-rs/src/services/gfx.rs b/ctru-rs/src/services/gfx.rs index 40d4740..5b71978 100644 --- a/ctru-rs/src/services/gfx.rs +++ b/ctru-rs/src/services/gfx.rs @@ -163,21 +163,21 @@ impl Gfx { } /// Flushes the current framebuffers - pub fn flush_buffers(&self) { + pub fn flush_buffers(&mut self) { unsafe { ctru_sys::gfxFlushBuffers() }; } /// Swaps the framebuffers and sets the gsp state /// /// Use this function when working with software rendering - pub fn swap_buffers(&self) { + pub fn swap_buffers(&mut self) { unsafe { ctru_sys::gfxSwapBuffers() }; } /// Swaps the framebuffers without manipulating the gsp state /// /// Use this function when working with GPU rendering - pub fn swap_buffers_gpu(&self) { + pub fn swap_buffers_gpu(&mut self) { unsafe { ctru_sys::gfxSwapBuffersGpu() }; } diff --git a/ctru-rs/src/services/hid.rs b/ctru-rs/src/services/hid.rs index 26b034f..31dd4d9 100644 --- a/ctru-rs/src/services/hid.rs +++ b/ctru-rs/src/services/hid.rs @@ -71,7 +71,7 @@ impl Hid { /// Scans the HID service for all user input occurring on the current /// frame. This function should be called on every frame when polling /// for user input. - pub fn scan_input(&self) { + pub fn scan_input(&mut self) { unsafe { ctru_sys::hidScanInput() }; }