1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
//! Library of GPT disk data types.
//!
//! # GPT disk components
//!
//! ```text
//! ┌───┬───────┬─────────────────┬─────────┬───────────────────┬─────────┐
//! │MBR│Primary│Primary partition│Partition│Secondary partition│Secondary│
//! │ │header │entry array │data │entry array │header │
//! └───┴───────┴─────────────────┴─────────┴───────────────────┴─────────┘
//! ```
//!
//! 1. The first block of the disk contains a protective MBR. See
//! [`MasterBootRecord::protective_mbr`].
//! 2. The second block of the disk contains the primary GPT header. See
//! [`GptHeader`].
//! 3. Additional blocks after the header contain the partition entry
//! array. See [`GptPartitionEntry`] and [`GptPartitionEntryArray`].
//! 4. At the end of the disk is a secondary GPT header and partition
//! entry array.
//!
//! # Endianness
//!
//! The UEFI Specification specifies that data structures are little
//! endian (section 1.8.1 "Data Structure Descriptions"). Unless
//! otherwise noted, all fields in this library are little endian. This
//! is true even when running the code on a big-endian architecture; the
//! [`U16Le`], [`U32Le`], [`U64Le`], and [`LbaLe`] types help enforce
//! this. The little-endian convention is also used for [`Display`]
//! implementations. This means bytes within each field will appear
//! reversed when compared with a flat hex dump of GPT data.
//!
//! [`Display`]: core::fmt::Display
//!
//! # Features
//!
//! * `bytemuck`: Implements bytemuck's `Pod` and `Zeroable` traits for
//! many of the types in this crate. Also enables some methods that
//! rely on byte access.
//! * `std`: Provides `std::error::Error` implementations for all of the
//! error types. Off by default.
//!
//! # Examples
//!
//! Construct a GPT header:
//!
//! ```
//! use gpt_disk_types::{guid, Crc32, GptHeader, LbaLe, U32Le};
//!
//! let header = GptHeader {
//! header_crc32: Crc32(U32Le::from_u32(0xa4877843)),
//! my_lba: LbaLe::from_u64(1),
//! alternate_lba: LbaLe::from_u64(8191),
//! first_usable_lba: LbaLe::from_u64(34),
//! last_usable_lba: LbaLe::from_u64(8158),
//! disk_guid: guid!("57a7feb6-8cd5-4922-b7bd-c78b0914e870"),
//! partition_entry_lba: LbaLe::from_u64(2),
//! number_of_partition_entries: U32Le::from_u32(128),
//! partition_entry_array_crc32: Crc32(U32Le::from_u32(0x9206adff)),
//! ..Default::default()
//! };
//! ```
//!
//! Construct a GPT partition entry:
//!
//! ```
//! use gpt_disk_types::{guid, GptPartitionEntry, GptPartitionType, LbaLe};
//!
//! let entry = GptPartitionEntry {
//! partition_type_guid: GptPartitionType(guid!(
//! "ccf0994f-f7e0-4e26-a011-843e38aa2eac"
//! )),
//! unique_partition_guid: guid!("37c75ffd-8932-467a-9c56-8cf1f0456b12"),
//! starting_lba: LbaLe::from_u64(2048),
//! ending_lba: LbaLe::from_u64(4096),
//! attributes: Default::default(),
//! name: "hello world!".parse().unwrap(),
//! };
//! ```
// Re-export dependencies.
pub use crc;
pub use ucs2;
pub use ;
pub use ;
pub use Crc32;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;