#[cfg(any(feature = "bitflags"))]
use crate::GPTError;
#[cfg(any(feature = "bitflags"))]
bitflags::bitflags! {
#[repr(transparent)]
pub struct Attributes: u64 {
const REQUIRED = 0b1;
const NO_BLOCK_IO = 0b10;
const LEGACY_BIOS_BOOTABLE = 0b100;
}
}
#[cfg(not(feature = "bitflags"))]
#[derive(Debug)]
#[repr(transparent)]
pub struct Attributes(pub u64);
#[cfg(not(feature = "bitflags"))]
impl Attributes {
fn bits(&self) -> u64 {
self.0
}
}
#[cfg(feature = "bitflags")]
impl TryFrom<u64> for Attributes {
type Error = GPTError;
fn try_from(value: u64) -> Result<Self, Self::Error> {
Attributes::from_bits(value).ok_or(GPTError::InvalidData)
}
}
#[cfg(not(feature = "bitflags"))]
impl From<u64> for Attributes {
fn from(value: u64) -> Self {
Attributes(value)
}
}
impl From<Attributes> for u64 {
fn from(attr: Attributes) -> u64 {
attr.bits()
}
}