use crate::lib_bitfield;
use super::{ExtCsd, ExtCsdIndex};
lib_bitfield! {
BackgroundOperationsSupport: u8,
mask: 0x1,
default: 1,
{
supported: 0;
}
}
impl ExtCsd {
pub const fn bkops_support(&self) -> BackgroundOperationsSupport {
BackgroundOperationsSupport::from_inner(self.0[ExtCsdIndex::BkopsSupport.into_inner()])
}
pub(crate) fn set_bkops_support(&mut self, val: BackgroundOperationsSupport) {
self.0[ExtCsdIndex::BkopsSupport.into_inner()] = val.into_inner();
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_bkops_support() {
let mut ext_csd = ExtCsd::new();
ext_csd.set_bkops_support(BackgroundOperationsSupport::new());
assert_eq!(ext_csd.bkops_support(), BackgroundOperationsSupport::new());
(0..=u8::MAX)
.map(BackgroundOperationsSupport::from_inner)
.for_each(|ops| {
ext_csd.set_bkops_support(ops);
assert_eq!(ext_csd.bkops_support(), ops);
});
}
}