v2/item: Implement `TryFrom<[usize; 2]>` for `Header`
use crate::Error;
-use core::convert::TryFrom;
+use core::convert::{TryFrom, TryInto};
use libc::EINVAL;
#[derive(Clone, Copy, Debug, PartialEq)]
@@ -33,6 +33,17 @@ pub struct Header {
pub kind: Kind,
}
+impl TryFrom<[usize; 2]> for Header {
+ type Error = Error;
+
+ #[inline]
+ fn try_from(header: [usize; 2]) -> Result<Self, Self::Error> {
+ let [size, kind] = header;
+ let kind = kind.try_into()?;
+ Ok(Self { size, kind })
+ }
+}
+
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(C, align(8))]
pub struct Syscall {
