Struct Device

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

A MBR FAT-16 compatible device emulator.

Implementations§

Source§

impl Device

Source

pub const MIN_SIZE: usize = 2_141_184usize

The minimum size in bytes supported by the FAT-16.

Source

pub const MAX_SIZE: usize = 2_147_483_648usize

The maximum size in bytes supported by the FAT-16.

Source

pub fn new(size: usize) -> Result<Self>

Attempts to create a new device with the provided amount of bytes.

Source

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.

Source

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.

Source

pub fn try_to_bytes(&self) -> Result<Vec<u8>>

Serializes the structure into bytes.

Source

pub fn try_from_bytes(buffer: &[u8]) -> Result<Self>

Deserializes the structure into bytes.

Source

pub fn with_min_len(self, min_len: usize) -> Self

Creates a device with the provided minimum length of the buffer.

Source

pub fn with_max_len(self, max_len: usize) -> Self

Creates a device with the provided maximum length of the buffer.

Source

pub fn with_resize_chunk(self, resize_chunk: usize) -> Self

Creates a device with the provided minimum chunk length increase.

Source

pub fn open(self) -> VolumeManager<Self, Clock>

Opens the device into a MBR volumes manager.

Trait Implementations§

Source§

impl BlockDevice for Device

Source§

type Error = Error

The errors that the BlockDevice can return. Must be debug formattable.
Source§

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<()>

Write one or more blocks, starting at the given block index.
Source§

fn num_blocks(&self) -> Result<BlockCount>

Determine how many blocks this device can hold.
Source§

impl Clone for Device

Source§

fn clone(&self) -> Device

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Default for Device

Source§

fn default() -> Device

Returns the “default value” for a type. Read more
Source§

impl From<Device> for FileSystem

Source§

fn from(dev: Device) -> Self

Converts to this type from the input type.

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> 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> 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.