settings_media_buttons/
lib.rs1use fidl_fuchsia_ui_input::MediaButtonsEvent;
6
7#[derive(PartialEq, Eq, Copy, Clone, Debug)]
10pub struct MediaButtons {
11 pub mic_mute: Option<bool>,
12 pub camera_disable: Option<bool>,
13}
14
15impl MediaButtons {
16 fn new() -> Self {
17 Self { mic_mute: None, camera_disable: None }
18 }
19
20 pub fn set_mic_mute(&mut self, mic_mute: Option<bool>) {
21 self.mic_mute = mic_mute;
22 }
23
24 pub fn set_camera_disable(&mut self, camera_disable: Option<bool>) {
25 self.camera_disable = camera_disable;
26 }
27}
28
29impl From<MediaButtonsEvent> for MediaButtons {
30 fn from(event: MediaButtonsEvent) -> Self {
31 let mut buttons = MediaButtons::new();
32
33 if let Some(mic_mute) = event.mic_mute {
34 buttons.set_mic_mute(Some(mic_mute));
35 }
36 if let Some(camera_disable) = event.camera_disable {
37 buttons.set_camera_disable(Some(camera_disable));
38 }
39
40 buttons
41 }
42}
43
44#[derive(PartialEq, Clone, Debug)]
45pub enum Event {
46 OnButton(MediaButtons),
47}
48
49impl From<MediaButtons> for Event {
50 fn from(button_types: MediaButtons) -> Self {
51 Self::OnButton(button_types)
52 }
53}
54
55pub struct MediaButtonsEventBuilder {
62 mic_mute: bool,
63 camera_disable: bool,
64}
65
66impl MediaButtonsEventBuilder {
67 #[allow(clippy::new_without_default)]
68 pub fn new() -> Self {
69 Self { mic_mute: false, camera_disable: false }
71 }
72
73 pub fn build(self) -> MediaButtonsEvent {
74 MediaButtonsEvent {
75 mic_mute: Some(self.mic_mute),
76 pause: Some(false),
77 camera_disable: Some(self.camera_disable),
78 ..Default::default()
79 }
80 }
81
82 pub fn set_mic_mute(mut self, mic_mute: bool) -> Self {
83 self.mic_mute = mic_mute;
84 self
85 }
86
87 pub fn set_camera_disable(mut self, camera_disable: bool) -> Self {
88 self.camera_disable = camera_disable;
89 self
90 }
91}