diff --git a/src/lib.rs b/src/lib.rs index 21e3433..fbab0a9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,7 @@ #![no_std] +use core::convert::TryFrom; + const CMDLINE_SIZE: usize = 256; pub trait LoadProtocol: Sized { @@ -73,3 +75,15 @@ pub struct ProtoV1 { pub cmdline: [u8; CMDLINE_SIZE] } + +impl TryFrom for PixelFormat { + type Error = (); + + fn try_from(f: u32) -> Result { + match f { + 0 => Ok(PixelFormat::LfbRgb32), + 1 => Ok(PixelFormat::LfbBgr32), + _ => Err(()) + } + } +}