#[cfg(not(any(target_os = "linux", target_os = "android", target_os = "windows")))]
std::compile_error!(
"Your operating system is not supported, yet. \
Please open an issue on GitHub: \
https://github.com/mbuesch/disktest/issues"
);
use anyhow as ah;
use std::path::Path;
#[cfg(any(target_os = "linux", target_os = "android"))]
mod linux;
#[cfg(target_os = "windows")]
mod windows;
pub const DEFAULT_SECTOR_SIZE: u32 = 512;
pub trait RawIoOsIntf: Sized {
fn new(path: &Path, create: bool, read: bool, write: bool) -> ah::Result<Self>;
fn get_sector_size(&self) -> Option<u32>;
fn drop_file_caches(&mut self, offset: u64, size: u64) -> ah::Result<()>;
fn close(&mut self) -> ah::Result<()>;
fn sync(&mut self) -> ah::Result<()>;
fn set_len(&mut self, size: u64) -> ah::Result<()>;
fn seek(&mut self, offset: u64) -> ah::Result<u64>;
fn read(&mut self, buffer: &mut [u8]) -> ah::Result<RawIoResult>;
fn write(&mut self, buffer: &[u8]) -> ah::Result<RawIoResult>;
}
pub enum RawIoResult {
Ok(usize),
Enospc,
}
#[cfg(any(target_os = "linux", target_os = "android"))]
pub use crate::linux::RawIoLinux as RawIo;
#[cfg(target_os = "windows")]
pub use crate::windows::RawIoWindows as RawIo;