Struct gpt::partition::Partition

source ·
pub struct Partition {
    pub part_type_guid: Type,
    pub part_guid: Uuid,
    pub first_lba: u64,
    pub last_lba: u64,
    pub flags: u64,
    pub name: String,
}
Expand description

A partition entry in a GPT partition table.

Fields§

§part_type_guid: Type

GUID of the partition type.

§part_guid: Uuid

UUID of the partition.

§first_lba: u64

First LBA of the partition.

§last_lba: u64

Last LBA of the partition.

§flags: u64

Partition flags.

§name: String

Partition name.

Implementations§

source§

impl Partition

source

pub fn zero() -> Self

Create a partition entry of type “unused”, whose bytes are all 0s.

source

pub fn write( &self, p: &Path, partition_index: u64, start_lba: u64, lb_size: LogicalBlockSize ) -> Result<()>

Write the partition entry to the partitions area in the given file. NOTE: does not update partitions array crc32 in the headers!

source

pub fn write_to_device<D: DiskDevice>( &self, device: &mut D, partition_index: u64, start_lba: u64, lb_size: LogicalBlockSize, bytes_per_partition: u32 ) -> Result<()>

Write the partition entry to the partitions area in the given device. NOTE: does not update partitions array crc32 in the headers!

source

pub fn write_zero_entries_to_device<D: DiskDevice>( device: &mut D, starting_partition_index: u64, number_entries: u64, start_lba: u64, lb_size: LogicalBlockSize, bytes_per_partition: u32 ) -> Result<()>

Write empty partition entries starting at the given index in the partition array for the given number of entries…

source

pub fn bytes_len(&self, lb_size: LogicalBlockSize) -> Result<u64>

Return the length (in bytes) of this partition. Partition size is calculated as (last_lba + 1 - first_lba) * block_size Bounds are inclusive, meaning we add one to account for the full last logical block

source

pub fn bytes_start(&self, lb_size: LogicalBlockSize) -> Result<u64>

Return the starting offset (in bytes) of this partition.

source

pub fn is_used(&self) -> bool

Check whether this partition is in use.

source

pub fn size(&self) -> Result<u64>

Return the number of sectors in the partition.

Trait Implementations§

source§

impl Clone for Partition

source§

fn clone(&self) -> Partition

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

source§

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

Formats the value using the given formatter. Read more
source§

impl Display for Partition

source§

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

Formats the value using the given formatter. Read more
source§

impl PartialEq for Partition

source§

fn eq(&self, other: &Partition) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for Partition

source§

impl StructuralPartialEq for Partition

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> ToOwned for T
where T: Clone,

§

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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

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

§

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.