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:
6
src/env/tock/mod.rs
vendored
6
src/env/tock/mod.rs
vendored
@@ -1,4 +1,5 @@
|
||||
pub use self::storage::{TockStorage, TockUpgradeStorage};
|
||||
use crate::api::customization::{CustomizationImpl, DEFAULT_CUSTOMIZATION};
|
||||
use crate::api::firmware_protection::FirmwareProtection;
|
||||
use crate::ctap::hid::{CtapHid, CtapHidCommand, KeepaliveStatus, ProcessedPacket};
|
||||
use crate::ctap::status_code::Ctap2StatusCode;
|
||||
@@ -80,6 +81,7 @@ impl Env for TockEnv {
|
||||
type UpgradeStorage = TockUpgradeStorage;
|
||||
type FirmwareProtection = Self;
|
||||
type Write = Console;
|
||||
type Customization = CustomizationImpl;
|
||||
|
||||
fn rng(&mut self) -> &mut Self::Rng {
|
||||
&mut self.rng
|
||||
@@ -104,6 +106,10 @@ impl Env for TockEnv {
|
||||
fn write(&mut self) -> Self::Write {
|
||||
Console::new()
|
||||
}
|
||||
|
||||
fn customization(&self) -> &Self::Customization {
|
||||
&DEFAULT_CUSTOMIZATION
|
||||
}
|
||||
}
|
||||
|
||||
// Returns whether the keepalive was sent, or false if cancelled.
|
||||
|
||||
Reference in New Issue
Block a user