diff --git a/library/std/src/os/mikros/mod.rs b/library/std/src/os/mikros/mod.rs index 90e733c0c62..8f90111ac2a 100644 --- a/library/std/src/os/mikros/mod.rs +++ b/library/std/src/os/mikros/mod.rs @@ -11,11 +11,10 @@ mod errno; -use serde::{Serialize, Serializer, ser::{SerializeTupleVariant, SerializeStruct}}; - #[stable(feature = "mikros", since = "1.80.0")] pub use errno::Errno; - +use serde::ser::{SerializeStruct, SerializeTupleVariant}; +use serde::{Serialize, Serializer}; #[stable(feature = "mikros", since = "1.80.0")] #[derive(Copy, Clone, Debug, PartialEq, Eq)] @@ -60,7 +59,9 @@ pub fn writable(self) -> bool { #[stable(feature = "mikros", since = "1.80.0")] pub fn get_writing_details(self) -> Option<(FileWriteMode, FileCreationMode)> { match self { - Self::Write(wr_mode, cr_mode) | Self::ReadWrite(wr_mode, cr_mode) => Some((wr_mode, cr_mode)), + Self::Write(wr_mode, cr_mode) | Self::ReadWrite(wr_mode, cr_mode) => { + Some((wr_mode, cr_mode)) + } Self::Read => None, } } @@ -86,7 +87,9 @@ fn serialize(&self, serializer: S) -> Result match self { Self::NoCreate => serializer.serialize_unit_variant("FileCreationMode", 0, "NoCreate"), Self::Create => serializer.serialize_unit_variant("FileCreationMode", 1, "Create"), - Self::ForceCreate => serializer.serialize_unit_variant("FileCreationMode", 2, "ForceCreate"), + Self::ForceCreate => { + serializer.serialize_unit_variant("FileCreationMode", 2, "ForceCreate") + } } } } @@ -119,14 +122,14 @@ fn serialize(&self, serializer: S) -> Result tv.serialize_field(wr_mode)?; tv.serialize_field(cr_mode)?; tv.end() - }, + } Self::ReadWrite(ref wr_mode, ref cr_mode) => { - let mut tv = serializer.serialize_tuple_variant("FileOpenMode", 2, "ReadWrite", 2)?; + let mut tv = + serializer.serialize_tuple_variant("FileOpenMode", 2, "ReadWrite", 2)?; tv.serialize_field(wr_mode)?; tv.serialize_field(cr_mode)?; tv.end() - }, - + } } } } diff --git a/library/std/src/sys/pal/mikros/fs.rs b/library/std/src/sys/pal/mikros/fs.rs index f05d1e19244..1a83bc0575c 100644 --- a/library/std/src/sys/pal/mikros/fs.rs +++ b/library/std/src/sys/pal/mikros/fs.rs @@ -6,7 +6,7 @@ use crate::hash::{Hash, Hasher}; use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut, SeekFrom}; use crate::os::mikros::ipc::rpc; -use crate::os::mikros::{Errno, syscalls, FileOpenMode, FileCreationMode, FileWriteMode}; +use crate::os::mikros::{Errno, FileCreationMode, FileOpenMode, FileWriteMode, syscalls}; use crate::path::{Component, Path, PathBuf}; use crate::sys::time::SystemTime; use crate::sys::unsupported; @@ -320,7 +320,6 @@ pub fn file_type(&self) -> io::Result { } } - impl OpenOptions { pub fn new() -> OpenOptions { OpenOptions { @@ -374,10 +373,7 @@ fn get_open_mode(&self) -> io::Result { (true, false) => FileCreationMode::Create, (_, true) => FileCreationMode::ForceCreate, }; - let wr_mode = FileWriteMode { - truncate: self.truncate, - append: self.append, - }; + let wr_mode = FileWriteMode { truncate: self.truncate, append: self.append }; match self.read { false => Ok(FileOpenMode::Write(wr_mode, cr_mode)), true => Ok(FileOpenMode::ReadWrite(wr_mode, cr_mode)), @@ -385,7 +381,6 @@ fn get_open_mode(&self) -> io::Result { } } - impl File { pub fn open(path: &Path, opts: &OpenOptions) -> io::Result { let open_mode = opts.get_open_mode()?; @@ -396,7 +391,8 @@ pub fn open(path: &Path, opts: &OpenOptions) -> io::Result { } }; let open_res: Result<(u64, u64), Errno> = postcard::from_bytes( - &rpc::send_call(vfs_pid, 2, 2, &postcard::to_allocvec(&(path, open_mode)).unwrap()).get_return(), + &rpc::send_call(vfs_pid, 2, 2, &postcard::to_allocvec(&(path, open_mode)).unwrap()) + .get_return(), ) .unwrap(); let (fs_pid, fd) = open_res?;