BitSound@lemmy.worldtoTechnology@lemmy.world•New Leica camera stops deepfakes at the shutterEnglish
1·
1 year agoThis is tilting at windmills. If someone has physical possession of a piece of hardware, you should assume that it’s been compromised down to the silicon, no matter what clever tricks they’ve tried to stymie hackers with. Also, the analog hole will always exist. Just generate a deepfake and then take a picture of it.
For a direct replacement, you might want to consider enums, for something like
enum Strategy { Foo, Bar, }
That’s going to be a lot more ergonomic than shuffling trait objects around, you can do stuff like:
fn execute(strategy: Strategy) { match strategy { Strategy::Foo => { ... } Strategy::Bar => { ... } }
If you have known set of strategy that isn’t extensible, enums are good. If you want the ability for third party code to add new strategies, the boxed trait object approach works. Consider also the simplest approach of just having functions like this:
fn execute_foo() { ... } fn execute_bar() { ... }
Sometimes, Rust encourages not trying to be too clever, like having
get
vsget_mut
and not trying to abstract over the mutability.