use crate::memory_management::{HardwareProperties, MemoryDeviceProperties};
use alloc::collections::BTreeSet;
#[derive(Debug)]
pub struct DeviceProperties<Feature: Ord + Copy> {
set: alloc::collections::BTreeSet<Feature>,
memory: MemoryDeviceProperties,
hardware: HardwareProperties,
}
impl<Feature: Ord + Copy> DeviceProperties<Feature> {
pub fn new(
features: &[Feature],
memory_props: MemoryDeviceProperties,
hardware: HardwareProperties,
) -> Self {
let mut set = BTreeSet::new();
for feature in features {
set.insert(*feature);
}
DeviceProperties {
set,
memory: memory_props,
hardware,
}
}
pub fn feature_enabled(&self, feature: Feature) -> bool {
self.set.contains(&feature)
}
pub fn register_feature(&mut self, feature: Feature) -> bool {
self.set.insert(feature)
}
pub fn memory_properties(&self) -> &MemoryDeviceProperties {
&self.memory
}
pub fn hardware_properties(&self) -> &HardwareProperties {
&self.hardware
}
}