1
0
forked from Rativel/BurritOS
Files
BurritOS/src/drivers/drv_disk.rs
2023-03-16 15:59:58 +01:00

42 lines
1.1 KiB
Rust

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),
_ => ()
}
}
}