Skip to main content

Disk

Struct Disk 

Source
pub struct Disk { /* private fields */ }
Expand description

A disk device with a cursor.

Implementations§

Source§

impl Disk

Source

pub fn new(dev: AxBlockDevice) -> Self

Create a new disk.

Source

pub fn size(&self) -> u64

Get the size of the disk.

Source

pub fn position(&self) -> u64

Get the position of the cursor.

Source

pub fn set_position(&mut self, pos: u64)

Set the position of the cursor.

Source

pub fn read_one(&mut self, buf: &mut [u8]) -> DevResult<usize>

Read within one block, returns the number of bytes read.

Source

pub fn write_one(&mut self, buf: &[u8]) -> DevResult<usize>

Write within one block, returns the number of bytes written.

Trait Implementations§

Source§

impl BlockDevice for Disk

Source§

fn write( &mut self, buffer: &[u8], block_id: AbsoluteBN, count: u32, ) -> Ext4Result<()>

Writes count blocks from buffer starting at block_id.
Source§

fn read( &mut self, buffer: &mut [u8], block_id: AbsoluteBN, count: u32, ) -> Ext4Result<()>

Reads count blocks into buffer starting at block_id.
Source§

fn open(&mut self) -> Ext4Result<()>

Opens the underlying device.
Source§

fn close(&mut self) -> Ext4Result<()>

Closes the underlying device.
Source§

fn total_blocks(&self) -> u64

Returns the total number of device blocks.
Source§

fn current_time(&self) -> Ext4Result<Ext4Timestamp>

Returns the current timestamp used for inode metadata updates.
Source§

fn block_size(&self) -> u32

Returns the device block size in bytes.
Source§

fn flush(&mut self) -> Result<(), Ext4Error>

Flushes device state to stable storage.
Source§

fn is_open(&self) -> bool

Returns whether the device is currently open.
Source§

fn is_readonly(&self) -> bool

Returns whether the device is read-only.
Source§

impl Clone for Disk

Source§

fn clone(&self) -> Disk

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl IoBase for Disk

Source§

type Error = ()

Type of errors returned by input/output operations.
Source§

impl Read for Disk

Source§

fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>

Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more
Source§

fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Self::Error>

Read the exact number of bytes required to fill buf. Read more
Source§

impl Seek for Disk

Source§

fn seek(&mut self, pos: SeekFrom) -> Result<u64, Self::Error>

Seek to an offset, in bytes, in a stream. Read more
Source§

impl Write for Disk

Source§

fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error>

Write a buffer into this writer, returning how many bytes were written. Read more
Source§

fn flush(&mut self) -> Result<(), Self::Error>

Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
Source§

fn write_all(&mut self, buf: &[u8]) -> Result<(), Self::Error>

Attempts to write an entire buffer into this writer. Read more

Auto Trait Implementations§

§

impl Freeze for Disk

§

impl !RefUnwindSafe for Disk

§

impl Send for Disk

§

impl Sync for Disk

§

impl Unpin for Disk

§

impl UnsafeUnpin for Disk

§

impl !UnwindSafe for Disk

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoStorage<T> for T
where T: Read + Write + Seek,

Source§

fn into_storage(self) -> T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ReadSeek for T
where T: Read + Seek,

Source§

impl<T> ReadWriteSeek for T
where T: Read + Write + Seek,