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
#[macro_use]
pub(crate) mod crate_macros {
macro_rules! read_exact_buff {
($bufid:ident, $rdr:expr, $buflen:expr) => {
{
let mut $bufid = [0u8; $buflen];
let _ = $rdr.read_exact(&mut $bufid)?;
$bufid
}
}
}
macro_rules! partition_types {
(
$(
$(#[$docs:meta])*
($upcase:ident, $guid:expr, $os:expr)$(,)*
)+
) => {
$(
$(#[$docs])*
pub const $upcase: Type = Type {
guid: $guid,
os: $os,
};
)+
impl FromStr for Type {
type Err = String;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
$(
$guid => Ok($upcase),
)+
_ => Err("Invalid or unknown Partition Type GUID.".to_string()),
}
}
}
}
}
}