Add TryFrom trait for u32 -> PixelFormat
This commit is contained in:
parent
1b5583b00f
commit
fb07217701
14
src/lib.rs
14
src/lib.rs
@ -1,5 +1,7 @@
|
|||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
|
use core::convert::TryFrom;
|
||||||
|
|
||||||
const CMDLINE_SIZE: usize = 256;
|
const CMDLINE_SIZE: usize = 256;
|
||||||
|
|
||||||
pub trait LoadProtocol: Sized {
|
pub trait LoadProtocol: Sized {
|
||||||
@ -73,3 +75,15 @@ pub struct ProtoV1 {
|
|||||||
|
|
||||||
pub cmdline: [u8; CMDLINE_SIZE]
|
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(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user