embedded_shadow/
policy.rs1pub trait AccessPolicy {
3 fn can_read(&self, addr: u16, len: usize) -> bool;
5 fn can_write(&self, addr: u16, len: usize) -> bool;
7}
8
9#[derive(Default)]
11pub struct AllowAllPolicy {}
12
13impl AccessPolicy for AllowAllPolicy {
14 fn can_read(&self, _addr: u16, _len: usize) -> bool {
15 true
16 }
17
18 fn can_write(&self, _addr: u16, _len: usize) -> bool {
19 true
20 }
21}
22
23pub trait PersistPolicy<PK> {
25 fn push_persist_keys_for_range<F>(&self, addr: u16, len: usize, push_key: F) -> bool
27 where
28 F: FnMut(PK);
29}
30
31#[derive(Default)]
33pub struct NoPersistPolicy {}
34
35impl PersistPolicy<()> for NoPersistPolicy {
36 fn push_persist_keys_for_range<F>(&self, _addr: u16, _len: usize, _push_key: F) -> bool {
37 false
38 }
39}