use heterob::{endianness::Le, Seq};
use super::ExtendedCapabilityDataError;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct RootComplexEventCollectorEndpointAssociation {
pub association_bitmap_for_rcieps: u32,
}
impl RootComplexEventCollectorEndpointAssociation {
pub const SIZE: usize = 4;
}
impl From<[u8; Self::SIZE]> for RootComplexEventCollectorEndpointAssociation {
fn from(bytes: [u8; Self::SIZE]) -> Self {
let Le(association_bitmap_for_rcieps) = bytes.into();
Self {
association_bitmap_for_rcieps,
}
}
}
impl TryFrom<&[u8]> for RootComplexEventCollectorEndpointAssociation {
type Error = ExtendedCapabilityDataError;
fn try_from(slice: &[u8]) -> Result<Self, Self::Error> {
let Seq { head, .. } = slice.try_into().map_err(|_| ExtendedCapabilityDataError {
name: "Root Complex Event Collector Endpoint Association",
size: Self::SIZE,
})?;
Ok(From::<[u8; Self::SIZE]>::from(head))
}
}