Introduce Customization struct (#458)
* Introduce Customization trait * Introduce Customization trait including the customization accessors that control various behaviors. * Expose Customization through a getter API in Env, and make the code that directly access the constants currently switch to accessing the customizations via Env. * TockEnv's customization getter implementation directly returns the reference of the global DEFAULT_CUSTOMIZATION constant, so the constant values are still inlined and dead code won't be compiled. * We'll add the customizations from global constants to the struct one-by-one, only MAX_MSG_SIZE in this commit. * Small fixes * Fix deploy script * put is_valid under std gate
This commit is contained in:
13
src/env/test/mod.rs
vendored
13
src/env/test/mod.rs
vendored
@@ -1,4 +1,5 @@
|
||||
use self::upgrade_storage::BufferUpgradeStorage;
|
||||
use crate::api::customization::{CustomizationImpl, DEFAULT_CUSTOMIZATION};
|
||||
use crate::api::firmware_protection::FirmwareProtection;
|
||||
use crate::ctap::status_code::Ctap2StatusCode;
|
||||
use crate::ctap::Channel;
|
||||
@@ -13,6 +14,7 @@ pub struct TestEnv {
|
||||
user_presence: TestUserPresence,
|
||||
store: Store<BufferStorage>,
|
||||
upgrade_storage: Option<BufferUpgradeStorage>,
|
||||
customization: CustomizationImpl,
|
||||
}
|
||||
|
||||
pub struct TestUserPresence {
|
||||
@@ -51,17 +53,23 @@ impl TestEnv {
|
||||
let storage = new_storage();
|
||||
let store = Store::new(storage).ok().unwrap();
|
||||
let upgrade_storage = Some(BufferUpgradeStorage::new().unwrap());
|
||||
let customization = DEFAULT_CUSTOMIZATION.clone();
|
||||
TestEnv {
|
||||
rng,
|
||||
user_presence,
|
||||
store,
|
||||
upgrade_storage,
|
||||
customization,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn disable_upgrade_storage(&mut self) {
|
||||
self.upgrade_storage = None;
|
||||
}
|
||||
|
||||
pub fn customization_mut(&mut self) -> &mut CustomizationImpl {
|
||||
&mut self.customization
|
||||
}
|
||||
}
|
||||
|
||||
impl TestUserPresence {
|
||||
@@ -89,6 +97,7 @@ impl Env for TestEnv {
|
||||
type UpgradeStorage = BufferUpgradeStorage;
|
||||
type FirmwareProtection = Self;
|
||||
type Write = TestWrite;
|
||||
type Customization = CustomizationImpl;
|
||||
|
||||
fn rng(&mut self) -> &mut Self::Rng {
|
||||
&mut self.rng
|
||||
@@ -113,4 +122,8 @@ impl Env for TestEnv {
|
||||
fn write(&mut self) -> Self::Write {
|
||||
TestWrite
|
||||
}
|
||||
|
||||
fn customization(&self) -> &Self::Customization {
|
||||
&self.customization
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user