I'm working on my first Rust project, which will include a library.
In this library, I'm currently defining traits (eg AsfaloadSecretKey), and the goal is to have multiple structs (eg MinisignSecretKey) implement these traits (eg impl AsfaloadSecretKey for MinisignSecretKey).
I'm wondering if I should replace
struct MinisignSecretKey {
key: minisign::SecretKey,
}
by
// Define generic struct at same level as trait
struct AsfaloadSecretKey<K> {
key: K,
}
// Implement the trait for the specialised struct
impl AsfaloadSecretKey for AsfaloadSecretKey<minisign::SecretKey> {
//...
}
What are the up/downsides of my each approach? Does my current approach have limitations?
Could anyone share their experience?
Thanks in advance!