Add TryFrom trait for u32 -> PixelFormat

This commit is contained in:
Mark 2020-09-20 18:23:53 +03:00
parent 1b5583b00f
commit fb07217701

View File

@ -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<u32> for PixelFormat {
type Error = ();
fn try_from(f: u32) -> Result<Self, Self::Error> {
match f {
0 => Ok(PixelFormat::LfbRgb32),
1 => Ok(PixelFormat::LfbBgr32),
_ => Err(())
}
}
}