roopes_core/aggregates/command_executable/
mod.rs1#![cfg_attr(feature = "doc-images",
3 cfg_attr(
4 all(),
5 doc = ::embed_doc_image::embed_image!(
6 "executable-command-diagram",
7 "src/aggregates/executable_command/executable_command.svg"
8)))]
9#![cfg_attr(
10 not(feature = "doc-images"),
11 doc = "**Doc images not enabled**. Compile with feature `doc-images` and \
12 Rust version >= 1.54 to enable."
13)]
14use crate::prelude::*;
19use delegate::delegate;
20
21pub mod prelude
24{
25 pub use super::CommandExecutable;
26}
27
28pub struct CommandExecutable<E>
31where
32 E: Executable,
33{
34 executable: E,
35}
36
37impl<E> CommandExecutable<E>
38where
39 E: Executable,
40{
41 pub fn new(executable: E) -> CommandExecutable<E>
44 {
45 CommandExecutable { executable }
46 }
47}
48
49#[allow(clippy::inline_always)]
50impl<E> Executable for CommandExecutable<E>
51where
52 E: Executable,
53{
54 delegate! {
55 to self.executable {
56 fn execute(&self);
57 }
58 }
59}
60
61#[allow(clippy::inline_always)]
62impl<E> Command for CommandExecutable<E>
63where
64 E: Executable,
65{
66 delegate! {
67 to self.executable {
68 fn execute(&self);
69 }
70 }
71}
72
73impl<E> From<E> for CommandExecutable<E>
74where
75 E: Executable,
76{
77 fn from(executable: E) -> Self
78 {
79 CommandExecutable::new(executable)
80 }
81}