#![no_std]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![deny(
clippy::all,
clippy::missing_const_for_fn,
clippy::must_use_candidate,
clippy::ptr_as_ptr,
clippy::use_self,
missing_debug_implementations,
unused
)]
mod enums;
pub mod capsule;
pub mod firmware_storage;
pub mod protocol;
pub mod table;
pub mod time;
mod net;
mod status;
pub use net::*;
pub use status::Status;
pub use uguid::{Guid, guid};
use core::ffi::c_void;
pub type Event = *mut c_void;
pub type Handle = *mut c_void;
pub type Char8 = u8;
pub type Char16 = u16;
pub type PhysicalAddress = u64;
pub type VirtualAddress = u64;
#[derive(Copy, Clone, Debug, Default, PartialEq, Ord, PartialOrd, Eq, Hash)]
#[repr(transparent)]
pub struct Boolean(pub u8);
impl Boolean {
pub const TRUE: Self = Self(1);
pub const FALSE: Self = Self(0);
}
impl From<bool> for Boolean {
fn from(value: bool) -> Self {
match value {
true => Self(1),
false => Self(0),
}
}
}
impl From<Boolean> for bool {
#[allow(clippy::match_like_matches_macro)]
fn from(value: Boolean) -> Self {
match value.0 {
0 => false,
_ => true,
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_boolean_abi() {
assert_eq!(size_of::<Boolean>(), 1);
assert_eq!(Boolean::from(true).0, 1);
assert_eq!(Boolean::from(false).0, 0);
assert_eq!(Boolean::TRUE.0, 1);
assert_eq!(Boolean::FALSE.0, 0);
assert!(!bool::from(Boolean(0b0)));
assert!(bool::from(Boolean(0b1)));
assert!(bool::from(Boolean(0b11111110)));
assert!(bool::from(Boolean(0b11111111)));
}
}