clientapi_pve/models/pve_audio_config.rs
1/*
2 * Proxmox Virtual Environment API
3 *
4 * Generated from apidoc.js. NOT an official Proxmox specification. See https://pve.proxmox.com/pve-docs/api-viewer/ for the upstream documentation.
5 *
6 * The version of the OpenAPI document: 9.x
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
15pub struct PveAudioConfig {
16
17 /// Configure an audio device.
18 #[serde(rename = "device")]
19 pub device: models::PveQemuDeviceEnum,
20
21 /// Driver backend for the audio device.
22 #[serde(rename = "driver", skip_serializing_if = "Option::is_none")]
23 pub driver: Option<models::PveDriverEnum>,
24
25
26}
27
28impl PveAudioConfig {
29 pub fn new(device: models::PveQemuDeviceEnum) -> PveAudioConfig {
30 PveAudioConfig {
31
32 device,
33
34 driver: None,
35
36 }
37 }
38}
39
40
41impl PveAudioConfig {
42 /// Serialise this PveAudioConfig into Proxmox's CLI-style shorthand
43 /// string (`key=value,…`). The property marked `x-pve-default-key`
44 /// is emitted positionally without a `key=` prefix; aliases collapse
45 /// multiple property names to the same wire key.
46 ///
47 /// Example: `PveAudioConfig `
48 /// → `"virtio,bridge=vmbr0"`
49 pub fn to_shorthand(&self) -> String {
50 let mut parts: Vec<String> = Vec::new();
51
52
53
54 parts.push(format!("device={}", self.device));
55
56
57
58 if let Some(ref v) = self.driver {
59 parts.push(format!("driver={}", v));
60 }
61
62 parts.join(",")
63 }
64}
65