qemu_command_builder/args/
set.rs1use crate::parsers::ARG_SET;
2use crate::to_command::ToCommand;
3use bon::Builder;
4use proptest_derive::Arbitrary;
5use std::str::FromStr;
6
7#[derive(Debug, Clone, Hash, Ord, PartialOrd, Eq, PartialEq, Default, Builder, Arbitrary)]
9pub struct Set {
10 group: String,
12 value: String,
14}
15
16impl ToCommand for Set {
17 fn command(&self) -> String {
18 ARG_SET.to_string()
19 }
20 fn to_args(&self) -> Vec<String> {
21 vec![format!("{}={}", self.group, self.value)]
22 }
23}
24
25impl FromStr for Set {
26 type Err = String;
27
28 fn from_str(s: &str) -> Result<Self, Self::Err> {
29 let (group, value) = s.split_once('=').ok_or_else(|| format!("invalid -set argument: {s}"))?;
30 Ok(Self {
31 group: group.to_string(),
32 value: value.to_string(),
33 })
34 }
35}