Browse Source

Fixed mutability for all modules

pull/115/head
Andrea Ciliberti 2 years ago
parent
commit
1e4002604f
  1. 2
      ctru-rs/src/services/apt.rs
  2. 2
      ctru-rs/src/services/cam.rs
  3. 20
      ctru-rs/src/services/fs.rs
  4. 6
      ctru-rs/src/services/gfx.rs
  5. 2
      ctru-rs/src/services/hid.rs

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

@ -14,7 +14,7 @@ impl Apt {
unsafe { ctru_sys::aptMainLoop() } 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 { unsafe {
ResultCode(ctru_sys::APT_SetAppCpuTimeLimit(percent))?; ResultCode(ctru_sys::APT_SetAppCpuTimeLimit(percent))?;
Ok(()) Ok(())

2
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 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. /// The new height will be `trim_height / 2` above and below the center.
fn set_trimming_params_center( fn set_trimming_params_center(
&self, &mut self,
trim_width: i16, trim_width: i16,
trim_height: i16, trim_height: i16,
cam_width: i16, cam_width: i16,

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

@ -310,7 +310,7 @@ impl Fs {
} }
/// Returns a handle to the SDMC (memory card) Archive. /// Returns a handle to the SDMC (memory card) Archive.
pub fn sdmc(&self) -> crate::Result<Archive> { pub fn sdmc(&mut self) -> crate::Result<Archive> {
unsafe { unsafe {
let mut handle = 0; let mut handle = 0;
let id = ArchiveID::Sdmc; let id = ArchiveID::Sdmc;
@ -384,7 +384,7 @@ impl File {
/// 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: &mut Archive, path: P) -> IoResult<File> {
OpenOptions::new() OpenOptions::new()
.write(true) .write(true)
.create(true) .create(true)
@ -588,11 +588,11 @@ impl OpenOptions {
/// * Invalid combinations of open options. /// * Invalid combinations of open options.
/// ///
/// [`Archive`]: struct.Archive.html /// [`Archive`]: struct.Archive.html
pub fn open<P: AsRef<Path>>(&self, path: P) -> IoResult<File> { pub fn open<P: AsRef<Path>>(&mut self, path: P) -> IoResult<File> {
self._open(path.as_ref(), self.open_flags()) self._open(path.as_ref(), self.open_flags())
} }
fn _open(&self, path: &Path, flags: FsOpen) -> IoResult<File> { fn _open(&mut self, path: &Path, flags: FsOpen) -> IoResult<File> {
unsafe { unsafe {
let mut file_handle = 0; let mut file_handle = 0;
let path = to_utf16(path); let path = to_utf16(path);
@ -706,7 +706,7 @@ impl<'a> DirEntry<'a> {
/// but is not limited to just these cases: /// but is not limited to just these cases:
/// ///
/// * User lacks permissions to create directory at `path` /// * User lacks permissions to create directory at `path`
pub fn create_dir<P: AsRef<Path>>(arch: &Archive, path: P) -> IoResult<()> { pub fn create_dir<P: AsRef<Path>>(arch: &mut Archive, path: P) -> IoResult<()> {
unsafe { unsafe {
let path = to_utf16(path.as_ref()); let path = to_utf16(path.as_ref());
let fs_path = ctru_sys::fsMakePath(PathType::UTF16.into(), path.as_ptr() as _); let fs_path = ctru_sys::fsMakePath(PathType::UTF16.into(), path.as_ptr() as _);
@ -732,7 +732,7 @@ pub fn create_dir<P: AsRef<Path>>(arch: &Archive, path: P) -> IoResult<()> {
/// ///
/// * If any directory in the path specified by `path` does not already exist /// * If any directory in the path specified by `path` does not already exist
/// and it could not be created otherwise. /// and it could not be created otherwise.
pub fn create_dir_all<P: AsRef<Path>>(arch: &Archive, path: P) -> IoResult<()> { pub fn create_dir_all<P: AsRef<Path>>(arch: &mut Archive, path: P) -> IoResult<()> {
let path = path.as_ref(); let path = path.as_ref();
let mut dir = PathBuf::new(); let mut dir = PathBuf::new();
let mut result = Ok(()); let mut result = Ok(());
@ -768,7 +768,7 @@ pub fn metadata<P: AsRef<Path>>(arch: &Archive, path: P) -> IoResult<Metadata> {
/// ///
/// * The user lacks permissions to remove the directory at the provided path. /// * The user lacks permissions to remove the directory at the provided path.
/// * The directory isn't empty. /// * The directory isn't empty.
pub fn remove_dir<P: AsRef<Path>>(arch: &Archive, path: P) -> IoResult<()> { pub fn remove_dir<P: AsRef<Path>>(arch: &mut Archive, path: P) -> IoResult<()> {
unsafe { unsafe {
let path = to_utf16(path.as_ref()); let path = to_utf16(path.as_ref());
let fs_path = ctru_sys::fsMakePath(PathType::UTF16.into(), path.as_ptr() as _); let fs_path = ctru_sys::fsMakePath(PathType::UTF16.into(), path.as_ptr() as _);
@ -786,7 +786,7 @@ pub fn remove_dir<P: AsRef<Path>>(arch: &Archive, path: P) -> IoResult<()> {
/// # Errors /// # Errors
/// ///
/// see `file::remove_file` and `fs::remove_dir` /// see `file::remove_file` and `fs::remove_dir`
pub fn remove_dir_all<P: AsRef<Path>>(arch: &Archive, path: P) -> IoResult<()> { pub fn remove_dir_all<P: AsRef<Path>>(arch: &mut Archive, path: P) -> IoResult<()> {
unsafe { unsafe {
let path = to_utf16(path.as_ref()); let path = to_utf16(path.as_ref());
let fs_path = ctru_sys::fsMakePath(PathType::UTF16.into(), path.as_ptr() as _); let fs_path = ctru_sys::fsMakePath(PathType::UTF16.into(), path.as_ptr() as _);
@ -838,7 +838,7 @@ pub fn read_dir<P: AsRef<Path>>(arch: &Archive, path: P) -> IoResult<ReadDir> {
/// ///
/// * path points to a directory. /// * path points to a directory.
/// * The user lacks permissions to remove the file. /// * The user lacks permissions to remove the file.
pub fn remove_file<P: AsRef<Path>>(arch: &Archive, path: P) -> IoResult<()> { pub fn remove_file<P: AsRef<Path>>(arch: &mut Archive, path: P) -> IoResult<()> {
unsafe { unsafe {
let path = to_utf16(path.as_ref()); let path = to_utf16(path.as_ref());
let fs_path = ctru_sys::fsMakePath(PathType::UTF16.into(), path.as_ptr() as _); let fs_path = ctru_sys::fsMakePath(PathType::UTF16.into(), path.as_ptr() as _);
@ -861,7 +861,7 @@ pub fn remove_file<P: AsRef<Path>>(arch: &Archive, path: P) -> IoResult<()> {
/// ///
/// * from does not exist. /// * from does not exist.
/// * The user lacks permissions to view contents. /// * The user lacks permissions to view contents.
pub fn rename<P, Q>(arch: &Archive, from: P, to: Q) -> IoResult<()> pub fn rename<P, Q>(arch: &mut Archive, from: P, to: Q) -> IoResult<()>
where where
P: AsRef<Path>, P: AsRef<Path>,
Q: AsRef<Path>, Q: AsRef<Path>,

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

@ -163,21 +163,21 @@ impl Gfx {
} }
/// Flushes the current framebuffers /// Flushes the current framebuffers
pub fn flush_buffers(&self) { pub fn flush_buffers(&mut self) {
unsafe { ctru_sys::gfxFlushBuffers() }; unsafe { ctru_sys::gfxFlushBuffers() };
} }
/// Swaps the framebuffers and sets the gsp state /// Swaps the framebuffers and sets the gsp state
/// ///
/// Use this function when working with software rendering /// Use this function when working with software rendering
pub fn swap_buffers(&self) { pub fn swap_buffers(&mut self) {
unsafe { ctru_sys::gfxSwapBuffers() }; unsafe { ctru_sys::gfxSwapBuffers() };
} }
/// Swaps the framebuffers without manipulating the gsp state /// Swaps the framebuffers without manipulating the gsp state
/// ///
/// Use this function when working with GPU rendering /// 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() }; unsafe { ctru_sys::gfxSwapBuffersGpu() };
} }

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

@ -71,7 +71,7 @@ impl Hid {
/// Scans the HID service for all user input occurring on the current /// Scans the HID service for all user input occurring on the current
/// frame. This function should be called on every frame when polling /// frame. This function should be called on every frame when polling
/// for user input. /// for user input.
pub fn scan_input(&self) { pub fn scan_input(&mut self) {
unsafe { ctru_sys::hidScanInput() }; unsafe { ctru_sys::hidScanInput() };
} }

Loading…
Cancel
Save