Skip to main content

Geometry

Struct Geometry 

Source
pub struct Geometry {
Show 15 fields pub variant: FatVariant, pub bytes_per_sector: u32, pub sectors_per_cluster: u32, pub cluster_size: u32, pub reserved_sectors: u32, pub num_fats: u32, pub fat_size_sectors: u32, pub root_entry_count: u32, pub total_sectors: u64, pub root_cluster: u32, pub count_of_clusters: u32, pub fat_start: u64, pub root_dir_start: u64, pub root_dir_bytes: u32, pub data_start: u64,
}
Expand description

Resolved on-disk geometry of a FAT12/16/32 volume. All byte offsets are relative to the start of the volume (sector 0).

Fields§

§variant: FatVariant

Which FAT variant.

§bytes_per_sector: u32

Bytes per logical sector (power of two, 512–4096).

§sectors_per_cluster: u32

Sectors per cluster (power of two, 1–128).

§cluster_size: u32

Cluster size in bytes.

§reserved_sectors: u32

Count of reserved sectors preceding the first FAT.

§num_fats: u32

Number of FAT copies.

§fat_size_sectors: u32

Sectors occupied by one FAT.

§root_entry_count: u32

FAT12/16 fixed root directory entry count (0 on FAT32).

§total_sectors: u64

Total sectors in the volume.

§root_cluster: u32

FAT32/exFAT first cluster of the root directory (0 on FAT12/16).

§count_of_clusters: u32

Count of data clusters (drives the type decision).

§fat_start: u64

Byte offset of the first FAT.

§root_dir_start: u64

Byte offset of the FAT12/16 fixed root region (0 on FAT32).

§root_dir_bytes: u32

Byte size of the FAT12/16 fixed root region (0 on FAT32).

§data_start: u64

Byte offset of cluster 2 (start of the data region).

Implementations§

Source§

impl Geometry

Source

pub fn parse(boot: &[u8]) -> Result<Geometry>

Parse the BPB from the boot sector boot (at least 512 bytes).

Fails loud, naming the offending value, on any structurally invalid field — an invalid BPB is a bootstrap failure, never a silent default.

Source

pub fn cluster_offset(&self, cluster: u32) -> Option<u64>

Byte offset of the first sector of cluster (>= 2) in the data region.

Trait Implementations§

Source§

impl Clone for Geometry

Source§

fn clone(&self) -> Geometry

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 Debug for Geometry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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