Impl StoreIdAccessor::access() for Aspect
This commit is contained in:
parent
2c544382a1
commit
2022f4e4bb
1 changed files with 13 additions and 1 deletions
|
@ -3,6 +3,7 @@ use storeid::StoreId;
|
|||
use hook::Hook;
|
||||
use hook::result::HookResult;
|
||||
use hook::accessor::{StoreIdAccessor, MutableHookDataAccessor, NonMutableHookDataAccessor};
|
||||
use hook::accessor::HookDataAccessor as HDA;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Aspect {
|
||||
|
@ -31,8 +32,19 @@ impl Aspect {
|
|||
|
||||
impl StoreIdAccessor for Aspect {
|
||||
fn access(&self, id: &StoreId) -> HookResult<()> {
|
||||
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(())
|
||||
}
|
||||
}
|
||||
|
||||
impl MutableHookDataAccessor for Aspect {
|
||||
|
|
Loading…
Reference in a new issue