Open Ichmed opened 1 year ago
Right now each pilot runs by reading a config file, creating an environment and then executing that environment.
This is basically already a constructor and method call approach just abstracted away needlessly. By creating a struct
struct PodmanPilot<'a> { config: Config<'a>, program_name: String, ... } impl<'a> Pilot for PodmanPilot<'a> { ... }
And implementing the current create and start functions on that struct we gain the following benefits:
self
config()
Pilot
The following things would be possible even though i don't see any need for them:
Vec<dyn Pilot>
The new main method would look something like this:
... let config = config_for_name(&program_name); PodmanPilot::from_config(config)?.create()?.run() }
By implementing Drop on the Pilot struct, cleanup code can also be made easier.
Drop
Right now each pilot runs by reading a config file, creating an environment and then executing that environment.
This is basically already a constructor and method call approach just abstracted away needlessly. By creating a struct
And implementing the current create and start functions on that struct we gain the following benefits:
self
instead ofconfig()
is more readablePilot
structPilot
trait as orientation.The following things would be possible even though i don't see any need for them:
Pilot
traitVec<dyn Pilot>
or similar structs that can even handle pilots of different typesThe new main method would look something like this:
By implementing
Drop
on thePilot
struct, cleanup code can also be made easier.