pub struct Device { /* private fields */ }
Expand description
A MBR FAT-16 compatible device emulator.
Implementations§
Source§impl Device
impl Device
Sourcepub const MAX_SIZE: usize = 2_147_483_648usize
pub const MAX_SIZE: usize = 2_147_483_648usize
The maximum size in bytes supported by the FAT-16.
Sourcepub fn new(size: usize) -> Result<Self>
pub fn new(size: usize) -> Result<Self>
Attempts to create a new device with the provided amount of bytes.
Sourcepub fn try_to_raw_bytes(&self) -> Result<Vec<u8>>
pub fn try_to_raw_bytes(&self) -> Result<Vec<u8>>
Attempts to serialize the structure into raw device (MBR+part0) bytes.
The only failure is if the device is borrowed mutably elsewhere.
Sourcepub fn from_raw_bytes_unchecked(bytes: Vec<u8>) -> Self
pub fn from_raw_bytes_unchecked(bytes: Vec<u8>) -> Self
Attempts to deserialize the structure from raw device (MBR+FAT16).
This device can be mounted using any fstools such as fdisk and mkfs.fat.
Sourcepub fn try_to_bytes(&self) -> Result<Vec<u8>>
pub fn try_to_bytes(&self) -> Result<Vec<u8>>
Serializes the structure into bytes.
Sourcepub fn try_from_bytes(buffer: &[u8]) -> Result<Self>
pub fn try_from_bytes(buffer: &[u8]) -> Result<Self>
Deserializes the structure into bytes.
Sourcepub fn with_min_len(self, min_len: usize) -> Self
pub fn with_min_len(self, min_len: usize) -> Self
Creates a device with the provided minimum length of the buffer.
Sourcepub fn with_max_len(self, max_len: usize) -> Self
pub fn with_max_len(self, max_len: usize) -> Self
Creates a device with the provided maximum length of the buffer.
Sourcepub fn with_resize_chunk(self, resize_chunk: usize) -> Self
pub fn with_resize_chunk(self, resize_chunk: usize) -> Self
Creates a device with the provided minimum chunk length increase.
Sourcepub fn open(self) -> VolumeManager<Self, Clock>
pub fn open(self) -> VolumeManager<Self, Clock>
Opens the device into a MBR volumes manager.
Trait Implementations§
Source§impl BlockDevice for Device
impl BlockDevice for Device
Source§fn read(
&self,
blocks: &mut [Block],
start_block_idx: BlockIdx,
reason: &str,
) -> Result<()>
fn read( &self, blocks: &mut [Block], start_block_idx: BlockIdx, reason: &str, ) -> Result<()>
Read one or more blocks, starting at the given block index.
Source§fn write(&self, blocks: &[Block], start_block_idx: BlockIdx) -> Result<()>
fn write(&self, blocks: &[Block], start_block_idx: BlockIdx) -> Result<()>
Write one or more blocks, starting at the given block index.
Source§fn num_blocks(&self) -> Result<BlockCount>
fn num_blocks(&self) -> Result<BlockCount>
Determine how many blocks this device can hold.
Auto Trait Implementations§
impl Freeze for Device
impl !RefUnwindSafe for Device
impl !Send for Device
impl !Sync for Device
impl Unpin for Device
impl !UnwindSafe for Device
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more