Add write to the environment

This commit is contained in:
Julien Cretin
2022-03-04 15:09:44 +01:00
parent dcc053c6cb
commit f09e5a77e8
6 changed files with 152 additions and 88 deletions

11
src/env/mod.rs vendored
View File

@@ -13,7 +13,7 @@ pub trait UserPresence {
/// Blocks for user presence.
///
/// Returns an error in case of timeout or keepalive error.
fn check(&self, cid: ChannelID) -> Result<(), Ctap2StatusCode>;
fn check(&mut self, cid: ChannelID) -> Result<(), Ctap2StatusCode>;
}
/// Describes what CTAP needs to function.
@@ -23,6 +23,7 @@ pub trait Env {
type Storage: Storage;
type UpgradeStorage: UpgradeStorage;
type FirmwareProtection: FirmwareProtection;
type Write: core::fmt::Write;
fn rng(&mut self) -> &mut Self::Rng;
fn user_presence(&mut self) -> &mut Self::UserPresence;
@@ -38,4 +39,12 @@ pub trait Env {
fn upgrade_storage(&mut self) -> StorageResult<Self::UpgradeStorage>;
fn firmware_protection(&mut self) -> &mut Self::FirmwareProtection;
/// Creates a write instance for debugging.
///
/// This API doesn't return a reference such that drop may flush. This matches the Tock
/// environment. Non-Tock embedded environments should use the defmt feature (to be implemented
/// using the defmt crate) and ignore this API. Non-embedded environments may either use this
/// API or use the log feature (to be implemented using the log crate).
fn write(&mut self) -> Self::Write;
}