[−][src]Struct gptman::GPTPartitionEntry
A GPT partition's entry in the partition array.
Examples
Basic usage:
let ss = 512; let data = vec![0; 100 * ss as usize]; let mut cur = std::io::Cursor::new(data); let mut gpt = gptman::GPT::new_from(&mut cur, ss as u64, [0xff; 16]) .expect("could not create partition table"); // NOTE: partition entries starts at 1 gpt[1] = gptman::GPTPartitionEntry { partition_type_guid: [0xff; 16], unique_partition_guid: [0xff; 16], starting_lba: gpt.header.first_usable_lba, ending_lba: gpt.header.last_usable_lba, attribute_bits: 0, partition_name: "A Robot Named Fight!".into(), }; assert_eq!(gpt[1].partition_name.as_str(), "A Robot Named Fight!");
Fields
partition_type_guid: [u8; 16]
16 bytes representing the UUID of the partition's type.
unique_partition_guid: [u8; 16]
16 bytes representing the UUID of the partition.
starting_lba: u64
The position (in sectors) of the first sector (used) of the partition.
ending_lba: u64
The position (in sectors) of the last sector (used) of the partition.
attribute_bits: u64
The attribute bits.
See Wikipedia's page for more information.
partition_name: PartitionName
The partition name.
Examples
Basic usage:
let name: gptman::PartitionName = "A Robot Named Fight!".into(); assert_eq!(name.as_str(), "A Robot Named Fight!");
Implementations
impl GPTPartitionEntry
[src]
pub fn empty() -> GPTPartitionEntry
[src]
Creates an empty partition entry
Examples
Basic usage:
let ss = 512; let data = vec![0; 100 * ss as usize]; let mut cur = std::io::Cursor::new(data); let mut gpt = gptman::GPT::new_from(&mut cur, ss as u64, [0xff; 16]) .expect("could not create partition table"); gpt[1] = gptman::GPTPartitionEntry::empty(); // NOTE: an empty partition entry is considered as not allocated assert!(gpt[1].is_unused());
pub fn read_from<R: ?Sized>(reader: &mut R) -> Result<GPTPartitionEntry> where
R: Read,
[src]
R: Read,
Read a partition entry from the reader at the current position.
pub fn is_unused(&self) -> bool
[src]
Returns true
if the partition entry is not used (type GUID == [0; 16]
)
pub fn is_used(&self) -> bool
[src]
Returns true
if the partition entry is used (type GUID != [0; 16]
)
pub fn size(&self) -> Result<u64>
[src]
Returns the number of sectors in the partition. A partition entry must always be 1 sector long at minimum.
Errors
This function will return an error if the ending_lba
is lesser than the starting_lba
.
Examples
Basic usage:
let ss = 512; let data = vec![0; 100 * ss as usize]; let mut cur = std::io::Cursor::new(data); let mut gpt = gptman::GPT::new_from(&mut cur, ss as u64, [0xff; 16]) .expect("could not create partition table"); gpt[1] = gptman::GPTPartitionEntry { partition_type_guid: [0xff; 16], unique_partition_guid: [0xff; 16], starting_lba: gpt.header.first_usable_lba, ending_lba: gpt.header.last_usable_lba, attribute_bits: 0, partition_name: "A Robot Named Fight!".into(), }; assert_eq!( gpt[1].size().ok(), Some(gpt.header.last_usable_lba + 1 - gpt.header.first_usable_lba) );
Trait Implementations
impl Clone for GPTPartitionEntry
[src]
pub fn clone(&self) -> GPTPartitionEntry
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for GPTPartitionEntry
[src]
impl<'de> Deserialize<'de> for GPTPartitionEntry
[src]
pub fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl Eq for GPTPartitionEntry
[src]
impl PartialEq<GPTPartitionEntry> for GPTPartitionEntry
[src]
pub fn eq(&self, other: &GPTPartitionEntry) -> bool
[src]
pub fn ne(&self, other: &GPTPartitionEntry) -> bool
[src]
impl Serialize for GPTPartitionEntry
[src]
pub fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl StructuralEq for GPTPartitionEntry
[src]
impl StructuralPartialEq for GPTPartitionEntry
[src]
Auto Trait Implementations
impl RefUnwindSafe for GPTPartitionEntry
[src]
impl Send for GPTPartitionEntry
[src]
impl Sync for GPTPartitionEntry
[src]
impl Unpin for GPTPartitionEntry
[src]
impl UnwindSafe for GPTPartitionEntry
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,