Minor fixes to attr writes

This commit is contained in:
Luke D. Jones
2022-10-01 14:57:25 +13:00
parent 600d0ae3d9
commit e938f1f9ec
6 changed files with 19 additions and 28 deletions

View File

@@ -85,6 +85,7 @@ macro_rules! get_attr_u8 {
};
}
/// Most attributes expect `u8` as a char, so `1` should be written as `b'1'`.
#[macro_export]
macro_rules! set_attr_u8 {
($(#[$doc_comment:meta])? $attr_name:literal $item:ident) => {

View File

@@ -76,25 +76,26 @@ pub enum GpuMode {
}
impl GpuMode {
pub fn to_mux(&self) -> u8 {
/// For writing to `gpu_mux_mode` attribute
pub fn to_mux_attr(&self) -> u8 {
if *self == Self::Discrete {
return 0;
return b'0';
}
1
b'1'
}
pub fn to_dgpu(&self) -> u8 {
pub fn to_dgpu_attr(&self) -> u8 {
if *self == Self::Integrated {
return 1;
return b'1';
}
0
b'0'
}
pub fn to_egpu(&self) -> u8 {
pub fn to_egpu_attr(&self) -> u8 {
if *self == Self::Egpu {
return 1;
return b'1';
}
0
b'0'
}
pub fn from_mux(num: u8) -> Self {