qemu_command_builder/
mon.rs1use crate::common::OnOff;
2use crate::to_command::{ToArg, ToCommand};
3use bon::Builder;
4
5pub enum ReadlineControl {
6 Readline,
7 Control,
8}
9
10impl ToArg for ReadlineControl {
11 fn to_arg(&self) -> &str {
12 match self {
13 ReadlineControl::Readline => "readline",
14 ReadlineControl::Control => "control",
15 }
16 }
17}
18#[derive(Builder)]
19pub struct Mon {
20 chardev: String,
21 mode: Option<ReadlineControl>,
22 pretty: Option<OnOff>,
23}
24
25impl ToCommand for Mon {
26 fn to_command(&self) -> Vec<String> {
27 let mut cmd = vec!["-mon".to_string()];
28
29 let mut args = vec![];
30 args.push(format!("chardev={}", self.chardev));
31 if let Some(mode) = &self.mode {
32 args.push(format!("mode={}", mode.to_arg()));
33 }
34 if let Some(pretty) = &self.pretty {
35 args.push(format!("pretty={}", pretty.to_arg()));
36 }
37
38 cmd.push(args.join(","));
39 cmd
40 }
41}