nouvelle version du driver et du disk

This commit is contained in:
amaury
2023-03-16 15:59:58 +01:00
parent 66eaa8a64f
commit 4c81f0591a
5 changed files with 100 additions and 14 deletions

View File

@ -0,0 +1,42 @@
use crate::Disk;
/// driver disk
pub struct DrvDisk {
disk: Disk
}
impl DrvDisk {
///initialize the disk ok the current driver
pub fn init_drv_disk(disk: Disk) -> DrvDisk {
DrvDisk { disk: disk }
}
///read inside the disk
///
/// ### Parameters
///
/// - **self** driver disk
/// - **sector_number** sector where to read the data
/// - **data** where the readed data will be stored
pub fn read_sector(&mut self, sector_number : i32, data : &mut Vec<u8>) {
match Disk::read_request(&mut self.disk,sector_number, data) {
Err(e) => println!("{:?}", e),
_ => ()
}
}
///write inside the disk
///
/// ### Parameters
///
/// - **self** driver disk
/// - **sector_number** sector where to write the data
/// - **data** where the data to write is stored
pub fn write_sector(&mut self, sector_number : i32, data : &mut Vec<u8>) {
match Disk::write_request(&mut self.disk, sector_number, data) {
Err(e) => println!("{:?}", e),
_ => ()
}
}
}