ModuleSetup returns a concrete type via a generic type parameter
This commit is contained in:
parent
863f48604c
commit
7019a0a071
4 changed files with 12 additions and 12 deletions
|
|
@ -69,12 +69,12 @@ impl PlaybookRun {
|
|||
println!("{}", serde_json::to_string_pretty(&self).unwrap());
|
||||
}
|
||||
|
||||
pub fn run<MS: ModuleSetup<A, S, E>, A: Serialize, S: Serialize, E: Serialize>(&mut self, cmd: MS) -> Result<S, E> {
|
||||
pub fn run<T: Module<A, S, E>, MS: ModuleSetup<T, A, S, E>, A: Serialize, S: Serialize, E: Serialize>(&mut self, cmd: MS) -> Result<S, E> {
|
||||
let module = cmd.with_facts(&self.facts);
|
||||
self.run_inner(module)
|
||||
}
|
||||
|
||||
pub fn run_inner<A: Serialize, S: Serialize, E: Serialize>(&mut self, cmd: Box<dyn Module<A, S, E>>) -> Result<S, E> {
|
||||
pub fn run_inner<T: Module<A, S, E>, A: Serialize, S: Serialize, E: Serialize>(&mut self, cmd: T) -> Result<S, E> {
|
||||
// TODO: Check conditions for skip
|
||||
|
||||
let module_name = cmd.module_name().to_string();
|
||||
|
|
@ -108,10 +108,10 @@ impl PlaybookRun {
|
|||
// }
|
||||
|
||||
/// A trait for modules to be run in the context of a playbook, by gathering facts
|
||||
pub trait ModuleSetup<A, S, E> {
|
||||
pub trait ModuleSetup<T: Module<A, S, E>, A: Serialize, S: Serialize, E: Serialize> {
|
||||
// type module: Module<A, S, E>;
|
||||
|
||||
fn with_facts(self, facts: &Facts) -> Box<dyn Module<A, S, E>>;
|
||||
fn with_facts(self, facts: &Facts) -> T;
|
||||
}
|
||||
|
||||
/// A Module takes some arguments which can be serialized back to the playbook run, and can be run to produce
|
||||
|
|
|
|||
Loading…
Reference in a new issue