diff --git a/core/io/generic.rs b/core/io/generic.rs index d67a93dd7..fd59ece88 100644 --- a/core/io/generic.rs +++ b/core/io/generic.rs @@ -1,18 +1,16 @@ +use super::MemoryIO; use crate::{Clock, Completion, File, Instant, LimboError, OpenFlags, Result, IO}; use std::cell::RefCell; use std::io::{Read, Seek, Write}; use std::sync::Arc; use tracing::{debug, trace}; -use super::MemoryIO; -pub struct GenericIO { -} +pub struct GenericIO {} impl GenericIO { pub fn new() -> Result { debug!("Using IO backend 'generic'"); - Ok(Self { - }) + Ok(Self {}) } } @@ -42,6 +40,10 @@ impl IO for GenericIO { getrandom::getrandom(&mut buf).unwrap(); i64::from_ne_bytes(buf) } + + fn get_memory_io(&self) -> Arc { + Arc::new(MemoryIO::new()) + } } impl Clock for GenericIO { @@ -52,10 +54,6 @@ impl Clock for GenericIO { micros: now.timestamp_subsec_micros(), } } - - fn get_memory_io(&self) -> Arc { - Arc::new(MemoryIO::new()) - } } pub struct GenericFile { diff --git a/core/io/io_uring.rs b/core/io/io_uring.rs index 6e2fc1e7e..b4b21aca8 100644 --- a/core/io/io_uring.rs +++ b/core/io/io_uring.rs @@ -1,4 +1,5 @@ use super::{common, Completion, File, OpenFlags, WriteCompletion, IO}; +use crate::io::clock::{Clock, Instant}; use crate::{LimboError, MemoryIO, Result}; use rustix::fs::{self, FlockOperation, OFlags}; use rustix::io_uring::iovec; @@ -11,7 +12,6 @@ use std::rc::Rc; use std::sync::Arc; use thiserror::Error; use tracing::{debug, trace}; -use crate::io::clock::{Clock, Instant}; const MAX_IOVECS: u32 = 128; const SQPOLL_IDLE: u32 = 1000; @@ -197,6 +197,10 @@ impl IO for UringIO { getrandom::getrandom(&mut buf).unwrap(); i64::from_ne_bytes(buf) } + + fn get_memory_io(&self) -> Arc { + Arc::new(MemoryIO::new()) + } } impl Clock for UringIO { @@ -207,10 +211,6 @@ impl Clock for UringIO { micros: now.timestamp_subsec_micros(), } } - - fn get_memory_io(&self) -> Arc { - Arc::new(MemoryIO::new()) - } } pub struct UringFile { diff --git a/core/io/vfs.rs b/core/io/vfs.rs index 6af47b176..95b4055d0 100644 --- a/core/io/vfs.rs +++ b/core/io/vfs.rs @@ -51,8 +51,8 @@ impl IO for VfsMod { unsafe { (vfs.gen_random_number)() } } - fn get_memory_io(&self) -> Option> { - Some(Arc::new(MemoryIO::new())) + fn get_memory_io(&self) -> Arc { + Arc::new(MemoryIO::new()) } } @@ -69,10 +69,6 @@ impl VfsMod { cstr.to_string_lossy().into_owned() } } - - fn get_memory_io(&self) -> Arc { - Arc::new(MemoryIO::new()) - } } impl File for VfsFileImpl { diff --git a/core/io/windows.rs b/core/io/windows.rs index f970ef02d..6c46d1973 100644 --- a/core/io/windows.rs +++ b/core/io/windows.rs @@ -1,17 +1,15 @@ +use super::MemoryIO; use crate::{Clock, Completion, File, Instant, LimboError, OpenFlags, Result, IO}; use std::cell::RefCell; use std::io::{Read, Seek, Write}; use std::sync::Arc; use tracing::{debug, trace}; -use super::MemoryIO; -pub struct WindowsIO { -} +pub struct WindowsIO {} impl WindowsIO { pub fn new() -> Result { debug!("Using IO backend 'syscall'"); - Ok(Self { - }) + Ok(Self {}) } } @@ -40,6 +38,10 @@ impl IO for WindowsIO { getrandom::getrandom(&mut buf).unwrap(); i64::from_ne_bytes(buf) } + + fn get_memory_io(&self) -> Arc { + Arc::new(MemoryIO::new()) + } } impl Clock for WindowsIO { @@ -50,10 +52,6 @@ impl Clock for WindowsIO { micros: now.timestamp_subsec_micros(), } } - - fn get_memory_io(&self) -> Arc { - Arc::new(MemoryIO::new()) - } } pub struct WindowsFile {