qemu_command_builder/
mon.rs

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