qemu_command_builder/
compact.rs1use crate::to_command::ToArg;
2use crate::to_command::ToCommand;
3use bon::Builder;
4
5#[derive(Debug, Clone, Hash, Ord, PartialOrd, Eq, PartialEq)]
6pub enum AcceptRejectCrash {
7 Accept,
8 Reject,
9 Crash,
10}
11
12impl ToArg for AcceptRejectCrash {
13 fn to_arg(&self) -> &str {
14 match self {
15 AcceptRejectCrash::Accept => "accept",
16 AcceptRejectCrash::Reject => "reject",
17 AcceptRejectCrash::Crash => "crash",
18 }
19 }
20}
21
22#[derive(Debug, Clone, Hash, Ord, PartialOrd, Eq, PartialEq)]
23pub enum AcceptHide {
24 Accept,
25 Hide,
26}
27impl ToArg for AcceptHide {
28 fn to_arg(&self) -> &str {
29 match self {
30 AcceptHide::Accept => "accept",
31 AcceptHide::Hide => "hide",
32 }
33 }
34}
35#[derive(Debug, Clone, Hash, Ord, PartialOrd, Eq, PartialEq, Builder)]
36pub struct DeprecatedInput {
37 deprecated_input: AcceptRejectCrash,
38 deprecated_output: AcceptHide,
39}
40
41#[derive(Debug, Clone, Hash, Ord, PartialOrd, Eq, PartialEq, Builder)]
42pub struct UnstableInput {
43 unstable_input: AcceptRejectCrash,
44 unstable_output: AcceptHide,
45}
46
47#[derive(Debug, Clone, Hash, Ord, PartialOrd, Eq, PartialEq)]
48pub enum Compact {
49 DeprecatedInput(DeprecatedInput),
50 UnstableInput(UnstableInput),
51}
52
53impl ToCommand for Compact {
54 fn to_command(&self) -> Vec<String> {
55 let mut cmd = vec![];
56
57 cmd.push("-compact".to_string());
58
59 match self {
60 Compact::DeprecatedInput(deprecated_input) => {
61 let mut args = vec![];
62 args.push(format!(
63 "deprecated-input={}",
64 deprecated_input.deprecated_input.to_arg()
65 ));
66 args.push(format!(
67 "deprecated-output={}",
68 deprecated_input.deprecated_output.to_arg()
69 ));
70 cmd.push(args.join(","));
71 }
72 Compact::UnstableInput(unstable_input) => {
73 let mut args = vec![];
74 args.push(format!(
75 "unstable-input={}",
76 unstable_input.unstable_input.to_arg()
77 ));
78 args.push(format!(
79 "unstable-output={}",
80 unstable_input.unstable_output.to_arg()
81 ));
82 cmd.push(args.join(","));
83 }
84 }
85 cmd
86 }
87}