I need some guidance on a trait design pattern—basic setup is as follows:
/// driver performs operations on a Target
trait Driver {
type Manager: DriverManager; // used to associate a driver manager
type DriverError: Error;
fn driver_op_1(&self, ...);
fn driver_op_2(&self. ...);
}
/// initializes a Targets based on TargetTraits
trait DriverManager {
type Object;
type ManagerError: Error;
fn manage_op_1(&self, ...); //
}
trait TargetTraits {
fn target_op_1(&self,...);
}
struct DriverA {}
impl Driver for DriverA { ... }
impl DriverManager for DriverA { ... }
I would like to erase DriverManager from DriverA so I can Vec<Box<dyn Driver>> I feel that my setup is an anti-pattern, but I am not sure how to pattern it correctly. I do have complete control over this so I can change my approach, so any feedback is very much appreciated.