MasterBootRecord

Struct MasterBootRecord 

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

A struct representing an MBR partition table.

Implementations§

Source§

impl MasterBootRecord

Source

pub fn from_bytes<T: AsRef<[u8]>>( bytes: &T, ) -> Result<MasterBootRecord, MbrError>

Parses the MBR table from a raw byte buffer.

Throws an error in the following cases:

  • BufferWrongSizeError if bytes.len() is less than 512
  • InvalidMBRSuffix if the final 2 bytes in bytes are not [0x55, 0xaa]
  • UnsupportedPartitionError if the MBR contains a tag that the crate does not recognize
Source

pub fn serialize<T: AsMut<[u8]>>( &self, buffer: &mut T, ) -> Result<usize, MbrError>

Serializes this MBR partition table to a raw byte buffer. Throws an error in the following cases:

  • BufferWrongSizeError if buffer.len() is less than 512

Note that it only affects the partition table itself, which only appears starting from byte 446 of the MBR; no bytes before this are affected, even though it is still necessary to pass a full 512 byte buffer.

Trait Implementations§

Source§

impl PartitionTable for MasterBootRecord

Source§

fn size(&self) -> usize

The size of the partition table itself, in bytes.
Source§

fn partition_table_entries(&self) -> &[PartitionTableEntry]

The entries in this table.

Auto Trait Implementations§

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