#[repr(C, packed(1))]pub struct MasterBootRecord {
pub bootstrap: [u8; 446],
pub partition_table: MbrPartitionTable,
pub signature: [u8; 2],
}Expand description
The complete Master Boot Record structure (512 bytes).
@hadris-spec MBR:layout @hadris-compliance unknown @hadris-tests roundtrip::mbr_write_read_roundtrip
Fields§
§bootstrap: [u8; 446]Bootstrap code area (446 bytes).
partition_table: MbrPartitionTablePartition table (64 bytes - 4 entries of 16 bytes each).
signature: [u8; 2]Boot signature (must be 0x55, 0xAA).
Implementations§
Source§impl MasterBootRecord
impl MasterBootRecord
Sourcepub const fn new(partition_table: MbrPartitionTable) -> Self
pub const fn new(partition_table: MbrPartitionTable) -> Self
Creates a new MBR with the given partition table.
Sourcepub const fn protective(disk_sectors: u64) -> Self
pub const fn protective(disk_sectors: u64) -> Self
Creates a protective MBR for GPT disks.
Sourcepub const fn has_valid_signature(&self) -> bool
pub const fn has_valid_signature(&self) -> bool
Returns whether this MBR has a valid boot signature.
Sourcepub fn get_partition_table(&self) -> MbrPartitionTable
pub fn get_partition_table(&self) -> MbrPartitionTable
Returns a copy of the partition table.
This method exists because the struct is packed and direct field access would create a misaligned reference.
Sourcepub fn set_partition_table(&mut self, table: MbrPartitionTable)
pub fn set_partition_table(&mut self, table: MbrPartitionTable)
Sets the partition table.
This method exists because the struct is packed and direct field access would create a misaligned reference.
Sourcepub fn with_partition_table<F>(&mut self, f: F)where
F: FnOnce(&mut MbrPartitionTable),
pub fn with_partition_table<F>(&mut self, f: F)where
F: FnOnce(&mut MbrPartitionTable),
Modifies the partition table using a closure.
This is a convenience method that gets the partition table, allows modification via a closure, and sets it back.
Trait Implementations§
Source§impl Clone for MasterBootRecord
impl Clone for MasterBootRecord
Source§fn clone(&self) -> MasterBootRecord
fn clone(&self) -> MasterBootRecord
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for MasterBootRecord
Source§impl Debug for MasterBootRecord
impl Debug for MasterBootRecord
Source§impl Default for MasterBootRecord
impl Default for MasterBootRecord
Source§impl MasterBootRecordReadExt for MasterBootRecord
Available on crate features read and sync only.
impl MasterBootRecordReadExt for MasterBootRecord
read and sync only.Source§impl MasterBootRecordReadExt for MasterBootRecord
Available on crate features async and read only.
impl MasterBootRecordReadExt for MasterBootRecord
async and read only.Source§impl MasterBootRecordWriteExt for MasterBootRecord
Available on crate features sync and write only.
impl MasterBootRecordWriteExt for MasterBootRecord
sync and write only.Source§impl MasterBootRecordWriteExt for MasterBootRecord
Available on crate features async and write only.
impl MasterBootRecordWriteExt for MasterBootRecord
async and write only.impl Pod for MasterBootRecord
Auto Trait Implementations§
impl Freeze for MasterBootRecord
impl RefUnwindSafe for MasterBootRecord
impl Send for MasterBootRecord
impl Sync for MasterBootRecord
impl Unpin for MasterBootRecord
impl UnsafeUnpin for MasterBootRecord
impl UnwindSafe for MasterBootRecord
Blanket Implementations§
impl<T> AnyBitPattern for Twhere
T: Pod,
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
Source§impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
Source§type Bits = T
type Bits = T
Self must have the same layout as the specified Bits except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern.Source§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
bits
as &Self.