trussed
trussed copied to clipboard
Unify mechanism traits
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.