qemu_command_builder/
addfs.rs

1use bon::Builder;
2
3use crate::to_command::ToCommand;
4
5/// Add a file descriptor to an fd set.
6#[derive(Default, Builder)]
7pub struct AddFd {
8    /// This option defines the file descriptor of which a duplicate is
9    /// added to fd set. The file descriptor cannot be stdin, stdout, or
10    /// stderr.
11    fd: usize,
12    /// This option defines the ID of the fd set to add the file
13    /// descriptor to.
14    set: usize,
15    /// This option defines a free-form string that can be used to
16    /// describe fd.
17    opaque: Option<String>,
18}
19
20impl ToCommand for AddFd {
21    fn to_command(&self) -> Vec<String> {
22        let mut cmd = vec!["-add-fd".to_string()];
23
24        let mut arg = vec![self.fd.to_string()];
25        arg.push(format!(",set={}", self.set));
26        if let Some(opaque) = &self.opaque {
27            arg.push(format!(",opaque={}", opaque));
28        }
29        cmd.push(arg.join(","));
30        cmd
31    }
32}