#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[derive(Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub enum LinkWidth
{
x1,
x2,
x4,
x8,
x16,
x32,
}
impl FromBytes for LinkWidth
{
type Error = ParseLinkWidthError;
#[inline(always)]
fn from_bytes(bytes: &[u8]) -> Result<Self, Self::Error>
{
use self::LinkWidth::*;
match bytes
{
b"1" => Ok(x1),
b"2" => Ok(x2),
b"4" => Ok(x4),
b"8" => Ok(x8),
b"16" => Ok(x16),
b"32" => Ok(x32),
_ => Err(ParseLinkWidthError::Unrecognised(bytes.to_vec()))
}
}
}