Impl StoreIdAccessor::access() for Aspect

This commit is contained in:
Matthias Beyer 2016-03-04 21:18:18 +01:00
parent 2c544382a1
commit 2022f4e4bb

View file

@ -3,6 +3,7 @@ use storeid::StoreId;
use hook::Hook; use hook::Hook;
use hook::result::HookResult; use hook::result::HookResult;
use hook::accessor::{StoreIdAccessor, MutableHookDataAccessor, NonMutableHookDataAccessor}; use hook::accessor::{StoreIdAccessor, MutableHookDataAccessor, NonMutableHookDataAccessor};
use hook::accessor::HookDataAccessor as HDA;
#[derive(Debug)] #[derive(Debug)]
pub struct Aspect { pub struct Aspect {
@ -31,7 +32,18 @@ impl Aspect {
impl StoreIdAccessor for Aspect { impl StoreIdAccessor for Aspect {
fn access(&self, id: &StoreId) -> HookResult<()> { fn access(&self, id: &StoreId) -> HookResult<()> {
unimplemented!() let accessors : Vec<HDA> = self.hooks.iter().map(|h| h.accessor()).collect();
if !accessors.iter().all(|a| match a { &HDA::StoreIdAccess(_) => true, _ => false }) {
unimplemented!()
}
for accessor in accessors {
match accessor {
HDA::StoreIdAccess(accessor) => try!(accessor.access(id)),
_ => unreachable!(),
}
}
Ok(())
} }
} }