trussed icon indicating copy to clipboard operation
trussed copied to clipboard

Unify mechanism traits

Open robin-nitrokey opened this issue 10 months ago • 1 comments

This patch combines the operation traits that were previously used to call mechanism implementations into a single MechanismImpl trait. This has several advantages:

  • We can use a macro to implement the dispatch from the Mechanism enum, removing boilerplate code from the reply_to implementation.
  • To implement an operation for a mechanism, it is now sufficient to override the respective trait method. It is no longer necessary to also update reply_to.
  • The need to annotate all mechanism methods with #[inline(never)] to avoid producing a huge reply_to function (see the comment in mechanisms.rs) is reduced as we can just mark the methods generated by the macro as #[inline(never)].
  • This reduces the binary size required in the stable nitrokey-3-firmware by some kB.

robin-nitrokey avatar Apr 10 '24 16:04 robin-nitrokey