Change block device trait

This commit is contained in:
Yuke Peng
2023-11-22 22:05:08 +08:00
committed by Tate, Hongliang Tian
parent 5b274d6cbe
commit 1616f2d32c
8 changed files with 249 additions and 48 deletions

View File

@ -530,6 +530,11 @@ impl<'a> VmReader<'a> {
unsafe { self.end.sub_ptr(self.cursor) }
}
/// Returns the cursor pointer, which refers to the address of the next byte to read.
pub const fn cursor(&self) -> *const u8 {
self.cursor
}
/// Returns if it has remaining data to read.
pub const fn has_remain(&self) -> bool {
self.remain() > 0
@ -635,6 +640,11 @@ impl<'a> VmWriter<'a> {
unsafe { self.end.sub_ptr(self.cursor) }
}
/// Returns the cursor pointer, which refers to the address of the next byte to write.
pub const fn cursor(&self) -> *mut u8 {
self.cursor
}
/// Returns if it has avaliable space to write.
pub const fn has_avail(&self) -> bool {
self.avail() > 0