google_cloud_devicestreaming_v1/
model.rs

1// Copyright 2025 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Code generated by sidekick. DO NOT EDIT.
16
17#![allow(rustdoc::redundant_explicit_links)]
18#![allow(rustdoc::broken_intra_doc_links)]
19#![no_implicit_prelude]
20extern crate async_trait;
21extern crate bytes;
22extern crate gax;
23extern crate gaxi;
24extern crate lazy_static;
25extern crate reqwest;
26extern crate serde;
27extern crate serde_json;
28extern crate serde_with;
29extern crate std;
30extern crate tracing;
31extern crate wkt;
32
33/// A message returned from a device.
34#[derive(Clone, Default, PartialEq)]
35#[non_exhaustive]
36pub struct DeviceMessage {
37    pub contents: std::option::Option<crate::model::device_message::Contents>,
38
39    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
40}
41
42impl DeviceMessage {
43    pub fn new() -> Self {
44        std::default::Default::default()
45    }
46
47    /// Sets the value of [contents][crate::model::DeviceMessage::contents].
48    ///
49    /// Note that all the setters affecting `contents` are mutually
50    /// exclusive.
51    pub fn set_contents<
52        T: std::convert::Into<std::option::Option<crate::model::device_message::Contents>>,
53    >(
54        mut self,
55        v: T,
56    ) -> Self {
57        self.contents = v.into();
58        self
59    }
60
61    /// The value of [contents][crate::model::DeviceMessage::contents]
62    /// if it holds a `StatusUpdate`, `None` if the field is not set or
63    /// holds a different branch.
64    pub fn status_update(
65        &self,
66    ) -> std::option::Option<&std::boxed::Box<crate::model::StatusUpdate>> {
67        #[allow(unreachable_patterns)]
68        self.contents.as_ref().and_then(|v| match v {
69            crate::model::device_message::Contents::StatusUpdate(v) => std::option::Option::Some(v),
70            _ => std::option::Option::None,
71        })
72    }
73
74    /// Sets the value of [contents][crate::model::DeviceMessage::contents]
75    /// to hold a `StatusUpdate`.
76    ///
77    /// Note that all the setters affecting `contents` are
78    /// mutually exclusive.
79    pub fn set_status_update<T: std::convert::Into<std::boxed::Box<crate::model::StatusUpdate>>>(
80        mut self,
81        v: T,
82    ) -> Self {
83        self.contents = std::option::Option::Some(
84            crate::model::device_message::Contents::StatusUpdate(v.into()),
85        );
86        self
87    }
88
89    /// The value of [contents][crate::model::DeviceMessage::contents]
90    /// if it holds a `StreamStatus`, `None` if the field is not set or
91    /// holds a different branch.
92    pub fn stream_status(
93        &self,
94    ) -> std::option::Option<&std::boxed::Box<crate::model::StreamStatus>> {
95        #[allow(unreachable_patterns)]
96        self.contents.as_ref().and_then(|v| match v {
97            crate::model::device_message::Contents::StreamStatus(v) => std::option::Option::Some(v),
98            _ => std::option::Option::None,
99        })
100    }
101
102    /// Sets the value of [contents][crate::model::DeviceMessage::contents]
103    /// to hold a `StreamStatus`.
104    ///
105    /// Note that all the setters affecting `contents` are
106    /// mutually exclusive.
107    pub fn set_stream_status<T: std::convert::Into<std::boxed::Box<crate::model::StreamStatus>>>(
108        mut self,
109        v: T,
110    ) -> Self {
111        self.contents = std::option::Option::Some(
112            crate::model::device_message::Contents::StreamStatus(v.into()),
113        );
114        self
115    }
116
117    /// The value of [contents][crate::model::DeviceMessage::contents]
118    /// if it holds a `StreamData`, `None` if the field is not set or
119    /// holds a different branch.
120    pub fn stream_data(&self) -> std::option::Option<&std::boxed::Box<crate::model::StreamData>> {
121        #[allow(unreachable_patterns)]
122        self.contents.as_ref().and_then(|v| match v {
123            crate::model::device_message::Contents::StreamData(v) => std::option::Option::Some(v),
124            _ => std::option::Option::None,
125        })
126    }
127
128    /// Sets the value of [contents][crate::model::DeviceMessage::contents]
129    /// to hold a `StreamData`.
130    ///
131    /// Note that all the setters affecting `contents` are
132    /// mutually exclusive.
133    pub fn set_stream_data<T: std::convert::Into<std::boxed::Box<crate::model::StreamData>>>(
134        mut self,
135        v: T,
136    ) -> Self {
137        self.contents =
138            std::option::Option::Some(crate::model::device_message::Contents::StreamData(v.into()));
139        self
140    }
141}
142
143impl wkt::message::Message for DeviceMessage {
144    fn typename() -> &'static str {
145        "type.googleapis.com/google.cloud.devicestreaming.v1.DeviceMessage"
146    }
147}
148
149#[doc(hidden)]
150impl<'de> serde::de::Deserialize<'de> for DeviceMessage {
151    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
152    where
153        D: serde::Deserializer<'de>,
154    {
155        #[allow(non_camel_case_types)]
156        #[doc(hidden)]
157        #[derive(PartialEq, Eq, Hash)]
158        enum __FieldTag {
159            __status_update,
160            __stream_status,
161            __stream_data,
162            Unknown(std::string::String),
163        }
164        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
165            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
166            where
167                D: serde::Deserializer<'de>,
168            {
169                struct Visitor;
170                impl<'de> serde::de::Visitor<'de> for Visitor {
171                    type Value = __FieldTag;
172                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
173                        formatter.write_str("a field name for DeviceMessage")
174                    }
175                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
176                    where
177                        E: serde::de::Error,
178                    {
179                        use std::result::Result::Ok;
180                        use std::string::ToString;
181                        match value {
182                            "statusUpdate" => Ok(__FieldTag::__status_update),
183                            "status_update" => Ok(__FieldTag::__status_update),
184                            "streamStatus" => Ok(__FieldTag::__stream_status),
185                            "stream_status" => Ok(__FieldTag::__stream_status),
186                            "streamData" => Ok(__FieldTag::__stream_data),
187                            "stream_data" => Ok(__FieldTag::__stream_data),
188                            _ => Ok(__FieldTag::Unknown(value.to_string())),
189                        }
190                    }
191                }
192                deserializer.deserialize_identifier(Visitor)
193            }
194        }
195        struct Visitor;
196        impl<'de> serde::de::Visitor<'de> for Visitor {
197            type Value = DeviceMessage;
198            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
199                formatter.write_str("struct DeviceMessage")
200            }
201            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
202            where
203                A: serde::de::MapAccess<'de>,
204            {
205                #[allow(unused_imports)]
206                use serde::de::Error;
207                use std::option::Option::Some;
208                let mut fields = std::collections::HashSet::new();
209                let mut result = Self::Value::new();
210                while let Some(tag) = map.next_key::<__FieldTag>()? {
211                    #[allow(clippy::match_single_binding)]
212                    match tag {
213                        __FieldTag::__status_update => {
214                            if !fields.insert(__FieldTag::__status_update) {
215                                return std::result::Result::Err(A::Error::duplicate_field(
216                                    "multiple values for status_update",
217                                ));
218                            }
219                            if result.contents.is_some() {
220                                return std::result::Result::Err(A::Error::duplicate_field(
221                                    "multiple values for `contents`, a oneof with full ID .google.cloud.devicestreaming.v1.DeviceMessage.status_update, latest field was statusUpdate",
222                                ));
223                            }
224                            result.contents = std::option::Option::Some(
225                                crate::model::device_message::Contents::StatusUpdate(
226                                    map.next_value::<std::option::Option<
227                                        std::boxed::Box<crate::model::StatusUpdate>,
228                                    >>()?
229                                    .unwrap_or_default(),
230                                ),
231                            );
232                        }
233                        __FieldTag::__stream_status => {
234                            if !fields.insert(__FieldTag::__stream_status) {
235                                return std::result::Result::Err(A::Error::duplicate_field(
236                                    "multiple values for stream_status",
237                                ));
238                            }
239                            if result.contents.is_some() {
240                                return std::result::Result::Err(A::Error::duplicate_field(
241                                    "multiple values for `contents`, a oneof with full ID .google.cloud.devicestreaming.v1.DeviceMessage.stream_status, latest field was streamStatus",
242                                ));
243                            }
244                            result.contents = std::option::Option::Some(
245                                crate::model::device_message::Contents::StreamStatus(
246                                    map.next_value::<std::option::Option<
247                                        std::boxed::Box<crate::model::StreamStatus>,
248                                    >>()?
249                                    .unwrap_or_default(),
250                                ),
251                            );
252                        }
253                        __FieldTag::__stream_data => {
254                            if !fields.insert(__FieldTag::__stream_data) {
255                                return std::result::Result::Err(A::Error::duplicate_field(
256                                    "multiple values for stream_data",
257                                ));
258                            }
259                            if result.contents.is_some() {
260                                return std::result::Result::Err(A::Error::duplicate_field(
261                                    "multiple values for `contents`, a oneof with full ID .google.cloud.devicestreaming.v1.DeviceMessage.stream_data, latest field was streamData",
262                                ));
263                            }
264                            result.contents = std::option::Option::Some(
265                                crate::model::device_message::Contents::StreamData(
266                                    map.next_value::<std::option::Option<
267                                        std::boxed::Box<crate::model::StreamData>,
268                                    >>()?
269                                    .unwrap_or_default(),
270                                ),
271                            );
272                        }
273                        __FieldTag::Unknown(key) => {
274                            let value = map.next_value::<serde_json::Value>()?;
275                            result._unknown_fields.insert(key, value);
276                        }
277                    }
278                }
279                std::result::Result::Ok(result)
280            }
281        }
282        deserializer.deserialize_any(Visitor)
283    }
284}
285
286#[doc(hidden)]
287impl serde::ser::Serialize for DeviceMessage {
288    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
289    where
290        S: serde::ser::Serializer,
291    {
292        use serde::ser::SerializeMap;
293        #[allow(unused_imports)]
294        use std::option::Option::Some;
295        let mut state = serializer.serialize_map(std::option::Option::None)?;
296        if let Some(value) = self.status_update() {
297            state.serialize_entry("statusUpdate", value)?;
298        }
299        if let Some(value) = self.stream_status() {
300            state.serialize_entry("streamStatus", value)?;
301        }
302        if let Some(value) = self.stream_data() {
303            state.serialize_entry("streamData", value)?;
304        }
305        if !self._unknown_fields.is_empty() {
306            for (key, value) in self._unknown_fields.iter() {
307                state.serialize_entry(key, &value)?;
308            }
309        }
310        state.end()
311    }
312}
313
314impl std::fmt::Debug for DeviceMessage {
315    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
316        let mut debug_struct = f.debug_struct("DeviceMessage");
317        debug_struct.field("contents", &self.contents);
318        if !self._unknown_fields.is_empty() {
319            debug_struct.field("_unknown_fields", &self._unknown_fields);
320        }
321        debug_struct.finish()
322    }
323}
324
325/// Defines additional types related to [DeviceMessage].
326pub mod device_message {
327    #[allow(unused_imports)]
328    use super::*;
329
330    #[derive(Clone, Debug, PartialEq)]
331    #[non_exhaustive]
332    pub enum Contents {
333        /// Information about the device's state.
334        StatusUpdate(std::boxed::Box<crate::model::StatusUpdate>),
335        /// The result of a device stream from ADB.
336        StreamStatus(std::boxed::Box<crate::model::StreamStatus>),
337        /// Data from an open stream.
338        StreamData(std::boxed::Box<crate::model::StreamData>),
339    }
340}
341
342/// A message to an ADB server.
343#[derive(Clone, Default, PartialEq)]
344#[non_exhaustive]
345pub struct AdbMessage {
346    pub contents: std::option::Option<crate::model::adb_message::Contents>,
347
348    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
349}
350
351impl AdbMessage {
352    pub fn new() -> Self {
353        std::default::Default::default()
354    }
355
356    /// Sets the value of [contents][crate::model::AdbMessage::contents].
357    ///
358    /// Note that all the setters affecting `contents` are mutually
359    /// exclusive.
360    pub fn set_contents<
361        T: std::convert::Into<std::option::Option<crate::model::adb_message::Contents>>,
362    >(
363        mut self,
364        v: T,
365    ) -> Self {
366        self.contents = v.into();
367        self
368    }
369
370    /// The value of [contents][crate::model::AdbMessage::contents]
371    /// if it holds a `Open`, `None` if the field is not set or
372    /// holds a different branch.
373    pub fn open(&self) -> std::option::Option<&std::boxed::Box<crate::model::Open>> {
374        #[allow(unreachable_patterns)]
375        self.contents.as_ref().and_then(|v| match v {
376            crate::model::adb_message::Contents::Open(v) => std::option::Option::Some(v),
377            _ => std::option::Option::None,
378        })
379    }
380
381    /// Sets the value of [contents][crate::model::AdbMessage::contents]
382    /// to hold a `Open`.
383    ///
384    /// Note that all the setters affecting `contents` are
385    /// mutually exclusive.
386    pub fn set_open<T: std::convert::Into<std::boxed::Box<crate::model::Open>>>(
387        mut self,
388        v: T,
389    ) -> Self {
390        self.contents =
391            std::option::Option::Some(crate::model::adb_message::Contents::Open(v.into()));
392        self
393    }
394
395    /// The value of [contents][crate::model::AdbMessage::contents]
396    /// if it holds a `StreamData`, `None` if the field is not set or
397    /// holds a different branch.
398    pub fn stream_data(&self) -> std::option::Option<&std::boxed::Box<crate::model::StreamData>> {
399        #[allow(unreachable_patterns)]
400        self.contents.as_ref().and_then(|v| match v {
401            crate::model::adb_message::Contents::StreamData(v) => std::option::Option::Some(v),
402            _ => std::option::Option::None,
403        })
404    }
405
406    /// Sets the value of [contents][crate::model::AdbMessage::contents]
407    /// to hold a `StreamData`.
408    ///
409    /// Note that all the setters affecting `contents` are
410    /// mutually exclusive.
411    pub fn set_stream_data<T: std::convert::Into<std::boxed::Box<crate::model::StreamData>>>(
412        mut self,
413        v: T,
414    ) -> Self {
415        self.contents =
416            std::option::Option::Some(crate::model::adb_message::Contents::StreamData(v.into()));
417        self
418    }
419}
420
421impl wkt::message::Message for AdbMessage {
422    fn typename() -> &'static str {
423        "type.googleapis.com/google.cloud.devicestreaming.v1.AdbMessage"
424    }
425}
426
427#[doc(hidden)]
428impl<'de> serde::de::Deserialize<'de> for AdbMessage {
429    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
430    where
431        D: serde::Deserializer<'de>,
432    {
433        #[allow(non_camel_case_types)]
434        #[doc(hidden)]
435        #[derive(PartialEq, Eq, Hash)]
436        enum __FieldTag {
437            __open,
438            __stream_data,
439            Unknown(std::string::String),
440        }
441        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
442            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
443            where
444                D: serde::Deserializer<'de>,
445            {
446                struct Visitor;
447                impl<'de> serde::de::Visitor<'de> for Visitor {
448                    type Value = __FieldTag;
449                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
450                        formatter.write_str("a field name for AdbMessage")
451                    }
452                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
453                    where
454                        E: serde::de::Error,
455                    {
456                        use std::result::Result::Ok;
457                        use std::string::ToString;
458                        match value {
459                            "open" => Ok(__FieldTag::__open),
460                            "streamData" => Ok(__FieldTag::__stream_data),
461                            "stream_data" => Ok(__FieldTag::__stream_data),
462                            _ => Ok(__FieldTag::Unknown(value.to_string())),
463                        }
464                    }
465                }
466                deserializer.deserialize_identifier(Visitor)
467            }
468        }
469        struct Visitor;
470        impl<'de> serde::de::Visitor<'de> for Visitor {
471            type Value = AdbMessage;
472            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
473                formatter.write_str("struct AdbMessage")
474            }
475            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
476            where
477                A: serde::de::MapAccess<'de>,
478            {
479                #[allow(unused_imports)]
480                use serde::de::Error;
481                use std::option::Option::Some;
482                let mut fields = std::collections::HashSet::new();
483                let mut result = Self::Value::new();
484                while let Some(tag) = map.next_key::<__FieldTag>()? {
485                    #[allow(clippy::match_single_binding)]
486                    match tag {
487                        __FieldTag::__open => {
488                            if !fields.insert(__FieldTag::__open) {
489                                return std::result::Result::Err(A::Error::duplicate_field(
490                                    "multiple values for open",
491                                ));
492                            }
493                            if result.contents.is_some() {
494                                return std::result::Result::Err(A::Error::duplicate_field(
495                                    "multiple values for `contents`, a oneof with full ID .google.cloud.devicestreaming.v1.AdbMessage.open, latest field was open",
496                                ));
497                            }
498                            result.contents =
499                                std::option::Option::Some(
500                                    crate::model::adb_message::Contents::Open(
501                                        map.next_value::<std::option::Option<
502                                            std::boxed::Box<crate::model::Open>,
503                                        >>()?
504                                        .unwrap_or_default(),
505                                    ),
506                                );
507                        }
508                        __FieldTag::__stream_data => {
509                            if !fields.insert(__FieldTag::__stream_data) {
510                                return std::result::Result::Err(A::Error::duplicate_field(
511                                    "multiple values for stream_data",
512                                ));
513                            }
514                            if result.contents.is_some() {
515                                return std::result::Result::Err(A::Error::duplicate_field(
516                                    "multiple values for `contents`, a oneof with full ID .google.cloud.devicestreaming.v1.AdbMessage.stream_data, latest field was streamData",
517                                ));
518                            }
519                            result.contents = std::option::Option::Some(
520                                crate::model::adb_message::Contents::StreamData(
521                                    map.next_value::<std::option::Option<
522                                        std::boxed::Box<crate::model::StreamData>,
523                                    >>()?
524                                    .unwrap_or_default(),
525                                ),
526                            );
527                        }
528                        __FieldTag::Unknown(key) => {
529                            let value = map.next_value::<serde_json::Value>()?;
530                            result._unknown_fields.insert(key, value);
531                        }
532                    }
533                }
534                std::result::Result::Ok(result)
535            }
536        }
537        deserializer.deserialize_any(Visitor)
538    }
539}
540
541#[doc(hidden)]
542impl serde::ser::Serialize for AdbMessage {
543    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
544    where
545        S: serde::ser::Serializer,
546    {
547        use serde::ser::SerializeMap;
548        #[allow(unused_imports)]
549        use std::option::Option::Some;
550        let mut state = serializer.serialize_map(std::option::Option::None)?;
551        if let Some(value) = self.open() {
552            state.serialize_entry("open", value)?;
553        }
554        if let Some(value) = self.stream_data() {
555            state.serialize_entry("streamData", value)?;
556        }
557        if !self._unknown_fields.is_empty() {
558            for (key, value) in self._unknown_fields.iter() {
559                state.serialize_entry(key, &value)?;
560            }
561        }
562        state.end()
563    }
564}
565
566impl std::fmt::Debug for AdbMessage {
567    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
568        let mut debug_struct = f.debug_struct("AdbMessage");
569        debug_struct.field("contents", &self.contents);
570        if !self._unknown_fields.is_empty() {
571            debug_struct.field("_unknown_fields", &self._unknown_fields);
572        }
573        debug_struct.finish()
574    }
575}
576
577/// Defines additional types related to [AdbMessage].
578pub mod adb_message {
579    #[allow(unused_imports)]
580    use super::*;
581
582    #[derive(Clone, Debug, PartialEq)]
583    #[non_exhaustive]
584    pub enum Contents {
585        /// Open a new stream.
586        Open(std::boxed::Box<crate::model::Open>),
587        /// Send data to a stream.
588        StreamData(std::boxed::Box<crate::model::StreamData>),
589    }
590}
591
592/// A StatusUpdate message given over the ADB protocol for the device state.
593#[derive(Clone, Default, PartialEq)]
594#[non_exhaustive]
595pub struct StatusUpdate {
596    /// The device's state
597    pub state: crate::model::status_update::DeviceState,
598
599    /// A map of properties with information about this device.
600    pub properties: std::collections::HashMap<std::string::String, std::string::String>,
601
602    /// A comma-separated list of "features" that this device supports.
603    pub features: std::string::String,
604
605    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
606}
607
608impl StatusUpdate {
609    pub fn new() -> Self {
610        std::default::Default::default()
611    }
612
613    /// Sets the value of [state][crate::model::StatusUpdate::state].
614    pub fn set_state<T: std::convert::Into<crate::model::status_update::DeviceState>>(
615        mut self,
616        v: T,
617    ) -> Self {
618        self.state = v.into();
619        self
620    }
621
622    /// Sets the value of [properties][crate::model::StatusUpdate::properties].
623    pub fn set_properties<T, K, V>(mut self, v: T) -> Self
624    where
625        T: std::iter::IntoIterator<Item = (K, V)>,
626        K: std::convert::Into<std::string::String>,
627        V: std::convert::Into<std::string::String>,
628    {
629        use std::iter::Iterator;
630        self.properties = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
631        self
632    }
633
634    /// Sets the value of [features][crate::model::StatusUpdate::features].
635    pub fn set_features<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
636        self.features = v.into();
637        self
638    }
639}
640
641impl wkt::message::Message for StatusUpdate {
642    fn typename() -> &'static str {
643        "type.googleapis.com/google.cloud.devicestreaming.v1.StatusUpdate"
644    }
645}
646
647#[doc(hidden)]
648impl<'de> serde::de::Deserialize<'de> for StatusUpdate {
649    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
650    where
651        D: serde::Deserializer<'de>,
652    {
653        #[allow(non_camel_case_types)]
654        #[doc(hidden)]
655        #[derive(PartialEq, Eq, Hash)]
656        enum __FieldTag {
657            __state,
658            __properties,
659            __features,
660            Unknown(std::string::String),
661        }
662        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
663            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
664            where
665                D: serde::Deserializer<'de>,
666            {
667                struct Visitor;
668                impl<'de> serde::de::Visitor<'de> for Visitor {
669                    type Value = __FieldTag;
670                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
671                        formatter.write_str("a field name for StatusUpdate")
672                    }
673                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
674                    where
675                        E: serde::de::Error,
676                    {
677                        use std::result::Result::Ok;
678                        use std::string::ToString;
679                        match value {
680                            "state" => Ok(__FieldTag::__state),
681                            "properties" => Ok(__FieldTag::__properties),
682                            "features" => Ok(__FieldTag::__features),
683                            _ => Ok(__FieldTag::Unknown(value.to_string())),
684                        }
685                    }
686                }
687                deserializer.deserialize_identifier(Visitor)
688            }
689        }
690        struct Visitor;
691        impl<'de> serde::de::Visitor<'de> for Visitor {
692            type Value = StatusUpdate;
693            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
694                formatter.write_str("struct StatusUpdate")
695            }
696            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
697            where
698                A: serde::de::MapAccess<'de>,
699            {
700                #[allow(unused_imports)]
701                use serde::de::Error;
702                use std::option::Option::Some;
703                let mut fields = std::collections::HashSet::new();
704                let mut result = Self::Value::new();
705                while let Some(tag) = map.next_key::<__FieldTag>()? {
706                    #[allow(clippy::match_single_binding)]
707                    match tag {
708                        __FieldTag::__state => {
709                            if !fields.insert(__FieldTag::__state) {
710                                return std::result::Result::Err(A::Error::duplicate_field(
711                                    "multiple values for state",
712                                ));
713                            }
714                            result.state = map.next_value::<std::option::Option<crate::model::status_update::DeviceState>>()?.unwrap_or_default();
715                        }
716                        __FieldTag::__properties => {
717                            if !fields.insert(__FieldTag::__properties) {
718                                return std::result::Result::Err(A::Error::duplicate_field(
719                                    "multiple values for properties",
720                                ));
721                            }
722                            result.properties = map
723                                .next_value::<std::option::Option<
724                                    std::collections::HashMap<
725                                        std::string::String,
726                                        std::string::String,
727                                    >,
728                                >>()?
729                                .unwrap_or_default();
730                        }
731                        __FieldTag::__features => {
732                            if !fields.insert(__FieldTag::__features) {
733                                return std::result::Result::Err(A::Error::duplicate_field(
734                                    "multiple values for features",
735                                ));
736                            }
737                            result.features = map
738                                .next_value::<std::option::Option<std::string::String>>()?
739                                .unwrap_or_default();
740                        }
741                        __FieldTag::Unknown(key) => {
742                            let value = map.next_value::<serde_json::Value>()?;
743                            result._unknown_fields.insert(key, value);
744                        }
745                    }
746                }
747                std::result::Result::Ok(result)
748            }
749        }
750        deserializer.deserialize_any(Visitor)
751    }
752}
753
754#[doc(hidden)]
755impl serde::ser::Serialize for StatusUpdate {
756    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
757    where
758        S: serde::ser::Serializer,
759    {
760        use serde::ser::SerializeMap;
761        #[allow(unused_imports)]
762        use std::option::Option::Some;
763        let mut state = serializer.serialize_map(std::option::Option::None)?;
764        if !wkt::internal::is_default(&self.state) {
765            state.serialize_entry("state", &self.state)?;
766        }
767        if !self.properties.is_empty() {
768            state.serialize_entry("properties", &self.properties)?;
769        }
770        if !self.features.is_empty() {
771            state.serialize_entry("features", &self.features)?;
772        }
773        if !self._unknown_fields.is_empty() {
774            for (key, value) in self._unknown_fields.iter() {
775                state.serialize_entry(key, &value)?;
776            }
777        }
778        state.end()
779    }
780}
781
782impl std::fmt::Debug for StatusUpdate {
783    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
784        let mut debug_struct = f.debug_struct("StatusUpdate");
785        debug_struct.field("state", &self.state);
786        debug_struct.field("properties", &self.properties);
787        debug_struct.field("features", &self.features);
788        if !self._unknown_fields.is_empty() {
789            debug_struct.field("_unknown_fields", &self._unknown_fields);
790        }
791        debug_struct.finish()
792    }
793}
794
795/// Defines additional types related to [StatusUpdate].
796pub mod status_update {
797    #[allow(unused_imports)]
798    use super::*;
799
800    /// The state displayed with the ADB Device when running "adb devices"
801    ///
802    /// # Working with unknown values
803    ///
804    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
805    /// additional enum variants at any time. Adding new variants is not considered
806    /// a breaking change. Applications should write their code in anticipation of:
807    ///
808    /// - New values appearing in future releases of the client library, **and**
809    /// - New values received dynamically, without application changes.
810    ///
811    /// Please consult the [Working with enums] section in the user guide for some
812    /// guidelines.
813    ///
814    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
815    #[derive(Clone, Debug, PartialEq)]
816    #[non_exhaustive]
817    pub enum DeviceState {
818        /// The device state is unknown.
819        Unspecified,
820        /// The ADB device is in the "device" status.
821        Device,
822        /// The ADB device is in the "recovery" status.
823        Recovery,
824        /// The ADB device is in the "rescue" status.
825        Rescue,
826        /// The ADB device is in the "sideload" status.
827        Sideload,
828        /// The ADB device is in the "missing" status.
829        Missing,
830        /// The ADB device is in the "offline" status.
831        Offline,
832        /// The ADB device is in the "unauthorized" status.
833        Unauthorized,
834        /// The ADB device is in the "authorizing" status.
835        Authorizing,
836        /// The ADB device is in the "connecting" status.
837        Connecting,
838        /// If set, the enum was initialized with an unknown value.
839        ///
840        /// Applications can examine the value using [DeviceState::value] or
841        /// [DeviceState::name].
842        UnknownValue(device_state::UnknownValue),
843    }
844
845    #[doc(hidden)]
846    pub mod device_state {
847        #[allow(unused_imports)]
848        use super::*;
849        #[derive(Clone, Debug, PartialEq)]
850        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
851    }
852
853    impl DeviceState {
854        /// Gets the enum value.
855        ///
856        /// Returns `None` if the enum contains an unknown value deserialized from
857        /// the string representation of enums.
858        pub fn value(&self) -> std::option::Option<i32> {
859            match self {
860                Self::Unspecified => std::option::Option::Some(0),
861                Self::Device => std::option::Option::Some(1),
862                Self::Recovery => std::option::Option::Some(2),
863                Self::Rescue => std::option::Option::Some(3),
864                Self::Sideload => std::option::Option::Some(4),
865                Self::Missing => std::option::Option::Some(10),
866                Self::Offline => std::option::Option::Some(11),
867                Self::Unauthorized => std::option::Option::Some(12),
868                Self::Authorizing => std::option::Option::Some(13),
869                Self::Connecting => std::option::Option::Some(14),
870                Self::UnknownValue(u) => u.0.value(),
871            }
872        }
873
874        /// Gets the enum value as a string.
875        ///
876        /// Returns `None` if the enum contains an unknown value deserialized from
877        /// the integer representation of enums.
878        pub fn name(&self) -> std::option::Option<&str> {
879            match self {
880                Self::Unspecified => std::option::Option::Some("DEVICE_STATE_UNSPECIFIED"),
881                Self::Device => std::option::Option::Some("DEVICE"),
882                Self::Recovery => std::option::Option::Some("RECOVERY"),
883                Self::Rescue => std::option::Option::Some("RESCUE"),
884                Self::Sideload => std::option::Option::Some("SIDELOAD"),
885                Self::Missing => std::option::Option::Some("MISSING"),
886                Self::Offline => std::option::Option::Some("OFFLINE"),
887                Self::Unauthorized => std::option::Option::Some("UNAUTHORIZED"),
888                Self::Authorizing => std::option::Option::Some("AUTHORIZING"),
889                Self::Connecting => std::option::Option::Some("CONNECTING"),
890                Self::UnknownValue(u) => u.0.name(),
891            }
892        }
893    }
894
895    impl std::default::Default for DeviceState {
896        fn default() -> Self {
897            use std::convert::From;
898            Self::from(0)
899        }
900    }
901
902    impl std::fmt::Display for DeviceState {
903        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
904            wkt::internal::display_enum(f, self.name(), self.value())
905        }
906    }
907
908    impl std::convert::From<i32> for DeviceState {
909        fn from(value: i32) -> Self {
910            match value {
911                0 => Self::Unspecified,
912                1 => Self::Device,
913                2 => Self::Recovery,
914                3 => Self::Rescue,
915                4 => Self::Sideload,
916                10 => Self::Missing,
917                11 => Self::Offline,
918                12 => Self::Unauthorized,
919                13 => Self::Authorizing,
920                14 => Self::Connecting,
921                _ => Self::UnknownValue(device_state::UnknownValue(
922                    wkt::internal::UnknownEnumValue::Integer(value),
923                )),
924            }
925        }
926    }
927
928    impl std::convert::From<&str> for DeviceState {
929        fn from(value: &str) -> Self {
930            use std::string::ToString;
931            match value {
932                "DEVICE_STATE_UNSPECIFIED" => Self::Unspecified,
933                "DEVICE" => Self::Device,
934                "RECOVERY" => Self::Recovery,
935                "RESCUE" => Self::Rescue,
936                "SIDELOAD" => Self::Sideload,
937                "MISSING" => Self::Missing,
938                "OFFLINE" => Self::Offline,
939                "UNAUTHORIZED" => Self::Unauthorized,
940                "AUTHORIZING" => Self::Authorizing,
941                "CONNECTING" => Self::Connecting,
942                _ => Self::UnknownValue(device_state::UnknownValue(
943                    wkt::internal::UnknownEnumValue::String(value.to_string()),
944                )),
945            }
946        }
947    }
948
949    impl serde::ser::Serialize for DeviceState {
950        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
951        where
952            S: serde::Serializer,
953        {
954            match self {
955                Self::Unspecified => serializer.serialize_i32(0),
956                Self::Device => serializer.serialize_i32(1),
957                Self::Recovery => serializer.serialize_i32(2),
958                Self::Rescue => serializer.serialize_i32(3),
959                Self::Sideload => serializer.serialize_i32(4),
960                Self::Missing => serializer.serialize_i32(10),
961                Self::Offline => serializer.serialize_i32(11),
962                Self::Unauthorized => serializer.serialize_i32(12),
963                Self::Authorizing => serializer.serialize_i32(13),
964                Self::Connecting => serializer.serialize_i32(14),
965                Self::UnknownValue(u) => u.0.serialize(serializer),
966            }
967        }
968    }
969
970    impl<'de> serde::de::Deserialize<'de> for DeviceState {
971        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
972        where
973            D: serde::Deserializer<'de>,
974        {
975            deserializer.deserialize_any(wkt::internal::EnumVisitor::<DeviceState>::new(
976                ".google.cloud.devicestreaming.v1.StatusUpdate.DeviceState",
977            ))
978        }
979    }
980}
981
982/// The result of a stream.
983#[derive(Clone, Default, PartialEq)]
984#[non_exhaustive]
985pub struct StreamStatus {
986    /// The unique ID of this stream, assigned by the client.
987    pub stream_id: i32,
988
989    /// The result of the stream. Either "Okay" for success or "Fail" for failure.
990    pub status: std::option::Option<crate::model::stream_status::Status>,
991
992    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
993}
994
995impl StreamStatus {
996    pub fn new() -> Self {
997        std::default::Default::default()
998    }
999
1000    /// Sets the value of [stream_id][crate::model::StreamStatus::stream_id].
1001    pub fn set_stream_id<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
1002        self.stream_id = v.into();
1003        self
1004    }
1005
1006    /// Sets the value of [status][crate::model::StreamStatus::status].
1007    ///
1008    /// Note that all the setters affecting `status` are mutually
1009    /// exclusive.
1010    pub fn set_status<
1011        T: std::convert::Into<std::option::Option<crate::model::stream_status::Status>>,
1012    >(
1013        mut self,
1014        v: T,
1015    ) -> Self {
1016        self.status = v.into();
1017        self
1018    }
1019
1020    /// The value of [status][crate::model::StreamStatus::status]
1021    /// if it holds a `Okay`, `None` if the field is not set or
1022    /// holds a different branch.
1023    pub fn okay(&self) -> std::option::Option<&std::boxed::Box<crate::model::Okay>> {
1024        #[allow(unreachable_patterns)]
1025        self.status.as_ref().and_then(|v| match v {
1026            crate::model::stream_status::Status::Okay(v) => std::option::Option::Some(v),
1027            _ => std::option::Option::None,
1028        })
1029    }
1030
1031    /// Sets the value of [status][crate::model::StreamStatus::status]
1032    /// to hold a `Okay`.
1033    ///
1034    /// Note that all the setters affecting `status` are
1035    /// mutually exclusive.
1036    pub fn set_okay<T: std::convert::Into<std::boxed::Box<crate::model::Okay>>>(
1037        mut self,
1038        v: T,
1039    ) -> Self {
1040        self.status =
1041            std::option::Option::Some(crate::model::stream_status::Status::Okay(v.into()));
1042        self
1043    }
1044
1045    /// The value of [status][crate::model::StreamStatus::status]
1046    /// if it holds a `Fail`, `None` if the field is not set or
1047    /// holds a different branch.
1048    pub fn fail(&self) -> std::option::Option<&std::boxed::Box<crate::model::Fail>> {
1049        #[allow(unreachable_patterns)]
1050        self.status.as_ref().and_then(|v| match v {
1051            crate::model::stream_status::Status::Fail(v) => std::option::Option::Some(v),
1052            _ => std::option::Option::None,
1053        })
1054    }
1055
1056    /// Sets the value of [status][crate::model::StreamStatus::status]
1057    /// to hold a `Fail`.
1058    ///
1059    /// Note that all the setters affecting `status` are
1060    /// mutually exclusive.
1061    pub fn set_fail<T: std::convert::Into<std::boxed::Box<crate::model::Fail>>>(
1062        mut self,
1063        v: T,
1064    ) -> Self {
1065        self.status =
1066            std::option::Option::Some(crate::model::stream_status::Status::Fail(v.into()));
1067        self
1068    }
1069}
1070
1071impl wkt::message::Message for StreamStatus {
1072    fn typename() -> &'static str {
1073        "type.googleapis.com/google.cloud.devicestreaming.v1.StreamStatus"
1074    }
1075}
1076
1077#[doc(hidden)]
1078impl<'de> serde::de::Deserialize<'de> for StreamStatus {
1079    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1080    where
1081        D: serde::Deserializer<'de>,
1082    {
1083        #[allow(non_camel_case_types)]
1084        #[doc(hidden)]
1085        #[derive(PartialEq, Eq, Hash)]
1086        enum __FieldTag {
1087            __stream_id,
1088            __okay,
1089            __fail,
1090            Unknown(std::string::String),
1091        }
1092        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
1093            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1094            where
1095                D: serde::Deserializer<'de>,
1096            {
1097                struct Visitor;
1098                impl<'de> serde::de::Visitor<'de> for Visitor {
1099                    type Value = __FieldTag;
1100                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1101                        formatter.write_str("a field name for StreamStatus")
1102                    }
1103                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
1104                    where
1105                        E: serde::de::Error,
1106                    {
1107                        use std::result::Result::Ok;
1108                        use std::string::ToString;
1109                        match value {
1110                            "streamId" => Ok(__FieldTag::__stream_id),
1111                            "stream_id" => Ok(__FieldTag::__stream_id),
1112                            "okay" => Ok(__FieldTag::__okay),
1113                            "fail" => Ok(__FieldTag::__fail),
1114                            _ => Ok(__FieldTag::Unknown(value.to_string())),
1115                        }
1116                    }
1117                }
1118                deserializer.deserialize_identifier(Visitor)
1119            }
1120        }
1121        struct Visitor;
1122        impl<'de> serde::de::Visitor<'de> for Visitor {
1123            type Value = StreamStatus;
1124            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1125                formatter.write_str("struct StreamStatus")
1126            }
1127            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
1128            where
1129                A: serde::de::MapAccess<'de>,
1130            {
1131                #[allow(unused_imports)]
1132                use serde::de::Error;
1133                use std::option::Option::Some;
1134                let mut fields = std::collections::HashSet::new();
1135                let mut result = Self::Value::new();
1136                while let Some(tag) = map.next_key::<__FieldTag>()? {
1137                    #[allow(clippy::match_single_binding)]
1138                    match tag {
1139                        __FieldTag::__stream_id => {
1140                            if !fields.insert(__FieldTag::__stream_id) {
1141                                return std::result::Result::Err(A::Error::duplicate_field(
1142                                    "multiple values for stream_id",
1143                                ));
1144                            }
1145                            struct __With(std::option::Option<i32>);
1146                            impl<'de> serde::de::Deserialize<'de> for __With {
1147                                fn deserialize<D>(
1148                                    deserializer: D,
1149                                ) -> std::result::Result<Self, D::Error>
1150                                where
1151                                    D: serde::de::Deserializer<'de>,
1152                                {
1153                                    serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
1154                                }
1155                            }
1156                            result.stream_id = map.next_value::<__With>()?.0.unwrap_or_default();
1157                        }
1158                        __FieldTag::__okay => {
1159                            if !fields.insert(__FieldTag::__okay) {
1160                                return std::result::Result::Err(A::Error::duplicate_field(
1161                                    "multiple values for okay",
1162                                ));
1163                            }
1164                            if result.status.is_some() {
1165                                return std::result::Result::Err(A::Error::duplicate_field(
1166                                    "multiple values for `status`, a oneof with full ID .google.cloud.devicestreaming.v1.StreamStatus.okay, latest field was okay",
1167                                ));
1168                            }
1169                            result.status =
1170                                std::option::Option::Some(
1171                                    crate::model::stream_status::Status::Okay(
1172                                        map.next_value::<std::option::Option<
1173                                            std::boxed::Box<crate::model::Okay>,
1174                                        >>()?
1175                                        .unwrap_or_default(),
1176                                    ),
1177                                );
1178                        }
1179                        __FieldTag::__fail => {
1180                            if !fields.insert(__FieldTag::__fail) {
1181                                return std::result::Result::Err(A::Error::duplicate_field(
1182                                    "multiple values for fail",
1183                                ));
1184                            }
1185                            if result.status.is_some() {
1186                                return std::result::Result::Err(A::Error::duplicate_field(
1187                                    "multiple values for `status`, a oneof with full ID .google.cloud.devicestreaming.v1.StreamStatus.fail, latest field was fail",
1188                                ));
1189                            }
1190                            result.status =
1191                                std::option::Option::Some(
1192                                    crate::model::stream_status::Status::Fail(
1193                                        map.next_value::<std::option::Option<
1194                                            std::boxed::Box<crate::model::Fail>,
1195                                        >>()?
1196                                        .unwrap_or_default(),
1197                                    ),
1198                                );
1199                        }
1200                        __FieldTag::Unknown(key) => {
1201                            let value = map.next_value::<serde_json::Value>()?;
1202                            result._unknown_fields.insert(key, value);
1203                        }
1204                    }
1205                }
1206                std::result::Result::Ok(result)
1207            }
1208        }
1209        deserializer.deserialize_any(Visitor)
1210    }
1211}
1212
1213#[doc(hidden)]
1214impl serde::ser::Serialize for StreamStatus {
1215    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1216    where
1217        S: serde::ser::Serializer,
1218    {
1219        use serde::ser::SerializeMap;
1220        #[allow(unused_imports)]
1221        use std::option::Option::Some;
1222        let mut state = serializer.serialize_map(std::option::Option::None)?;
1223        if !wkt::internal::is_default(&self.stream_id) {
1224            struct __With<'a>(&'a i32);
1225            impl<'a> serde::ser::Serialize for __With<'a> {
1226                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1227                where
1228                    S: serde::ser::Serializer,
1229                {
1230                    serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
1231                }
1232            }
1233            state.serialize_entry("streamId", &__With(&self.stream_id))?;
1234        }
1235        if let Some(value) = self.okay() {
1236            state.serialize_entry("okay", value)?;
1237        }
1238        if let Some(value) = self.fail() {
1239            state.serialize_entry("fail", value)?;
1240        }
1241        if !self._unknown_fields.is_empty() {
1242            for (key, value) in self._unknown_fields.iter() {
1243                state.serialize_entry(key, &value)?;
1244            }
1245        }
1246        state.end()
1247    }
1248}
1249
1250impl std::fmt::Debug for StreamStatus {
1251    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1252        let mut debug_struct = f.debug_struct("StreamStatus");
1253        debug_struct.field("stream_id", &self.stream_id);
1254        debug_struct.field("status", &self.status);
1255        if !self._unknown_fields.is_empty() {
1256            debug_struct.field("_unknown_fields", &self._unknown_fields);
1257        }
1258        debug_struct.finish()
1259    }
1260}
1261
1262/// Defines additional types related to [StreamStatus].
1263pub mod stream_status {
1264    #[allow(unused_imports)]
1265    use super::*;
1266
1267    /// The result of the stream. Either "Okay" for success or "Fail" for failure.
1268    #[derive(Clone, Debug, PartialEq)]
1269    #[non_exhaustive]
1270    pub enum Status {
1271        /// Okay for success.
1272        Okay(std::boxed::Box<crate::model::Okay>),
1273        /// Fail for failure.
1274        Fail(std::boxed::Box<crate::model::Fail>),
1275    }
1276}
1277
1278/// Message for opening a new stream.
1279#[derive(Clone, Default, PartialEq)]
1280#[non_exhaustive]
1281pub struct Open {
1282    /// Required. The unique ID that will be used to talk to this stream. This
1283    /// should probably just be a number that increments for each new Open request.
1284    pub stream_id: i32,
1285
1286    /// Optional. An ADB service to use in the new stream.
1287    pub service: std::string::String,
1288
1289    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1290}
1291
1292impl Open {
1293    pub fn new() -> Self {
1294        std::default::Default::default()
1295    }
1296
1297    /// Sets the value of [stream_id][crate::model::Open::stream_id].
1298    pub fn set_stream_id<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
1299        self.stream_id = v.into();
1300        self
1301    }
1302
1303    /// Sets the value of [service][crate::model::Open::service].
1304    pub fn set_service<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1305        self.service = v.into();
1306        self
1307    }
1308}
1309
1310impl wkt::message::Message for Open {
1311    fn typename() -> &'static str {
1312        "type.googleapis.com/google.cloud.devicestreaming.v1.Open"
1313    }
1314}
1315
1316#[doc(hidden)]
1317impl<'de> serde::de::Deserialize<'de> for Open {
1318    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1319    where
1320        D: serde::Deserializer<'de>,
1321    {
1322        #[allow(non_camel_case_types)]
1323        #[doc(hidden)]
1324        #[derive(PartialEq, Eq, Hash)]
1325        enum __FieldTag {
1326            __stream_id,
1327            __service,
1328            Unknown(std::string::String),
1329        }
1330        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
1331            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1332            where
1333                D: serde::Deserializer<'de>,
1334            {
1335                struct Visitor;
1336                impl<'de> serde::de::Visitor<'de> for Visitor {
1337                    type Value = __FieldTag;
1338                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1339                        formatter.write_str("a field name for Open")
1340                    }
1341                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
1342                    where
1343                        E: serde::de::Error,
1344                    {
1345                        use std::result::Result::Ok;
1346                        use std::string::ToString;
1347                        match value {
1348                            "streamId" => Ok(__FieldTag::__stream_id),
1349                            "stream_id" => Ok(__FieldTag::__stream_id),
1350                            "service" => Ok(__FieldTag::__service),
1351                            _ => Ok(__FieldTag::Unknown(value.to_string())),
1352                        }
1353                    }
1354                }
1355                deserializer.deserialize_identifier(Visitor)
1356            }
1357        }
1358        struct Visitor;
1359        impl<'de> serde::de::Visitor<'de> for Visitor {
1360            type Value = Open;
1361            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1362                formatter.write_str("struct Open")
1363            }
1364            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
1365            where
1366                A: serde::de::MapAccess<'de>,
1367            {
1368                #[allow(unused_imports)]
1369                use serde::de::Error;
1370                use std::option::Option::Some;
1371                let mut fields = std::collections::HashSet::new();
1372                let mut result = Self::Value::new();
1373                while let Some(tag) = map.next_key::<__FieldTag>()? {
1374                    #[allow(clippy::match_single_binding)]
1375                    match tag {
1376                        __FieldTag::__stream_id => {
1377                            if !fields.insert(__FieldTag::__stream_id) {
1378                                return std::result::Result::Err(A::Error::duplicate_field(
1379                                    "multiple values for stream_id",
1380                                ));
1381                            }
1382                            struct __With(std::option::Option<i32>);
1383                            impl<'de> serde::de::Deserialize<'de> for __With {
1384                                fn deserialize<D>(
1385                                    deserializer: D,
1386                                ) -> std::result::Result<Self, D::Error>
1387                                where
1388                                    D: serde::de::Deserializer<'de>,
1389                                {
1390                                    serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
1391                                }
1392                            }
1393                            result.stream_id = map.next_value::<__With>()?.0.unwrap_or_default();
1394                        }
1395                        __FieldTag::__service => {
1396                            if !fields.insert(__FieldTag::__service) {
1397                                return std::result::Result::Err(A::Error::duplicate_field(
1398                                    "multiple values for service",
1399                                ));
1400                            }
1401                            result.service = map
1402                                .next_value::<std::option::Option<std::string::String>>()?
1403                                .unwrap_or_default();
1404                        }
1405                        __FieldTag::Unknown(key) => {
1406                            let value = map.next_value::<serde_json::Value>()?;
1407                            result._unknown_fields.insert(key, value);
1408                        }
1409                    }
1410                }
1411                std::result::Result::Ok(result)
1412            }
1413        }
1414        deserializer.deserialize_any(Visitor)
1415    }
1416}
1417
1418#[doc(hidden)]
1419impl serde::ser::Serialize for Open {
1420    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1421    where
1422        S: serde::ser::Serializer,
1423    {
1424        use serde::ser::SerializeMap;
1425        #[allow(unused_imports)]
1426        use std::option::Option::Some;
1427        let mut state = serializer.serialize_map(std::option::Option::None)?;
1428        if !wkt::internal::is_default(&self.stream_id) {
1429            struct __With<'a>(&'a i32);
1430            impl<'a> serde::ser::Serialize for __With<'a> {
1431                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1432                where
1433                    S: serde::ser::Serializer,
1434                {
1435                    serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
1436                }
1437            }
1438            state.serialize_entry("streamId", &__With(&self.stream_id))?;
1439        }
1440        if !self.service.is_empty() {
1441            state.serialize_entry("service", &self.service)?;
1442        }
1443        if !self._unknown_fields.is_empty() {
1444            for (key, value) in self._unknown_fields.iter() {
1445                state.serialize_entry(key, &value)?;
1446            }
1447        }
1448        state.end()
1449    }
1450}
1451
1452impl std::fmt::Debug for Open {
1453    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1454        let mut debug_struct = f.debug_struct("Open");
1455        debug_struct.field("stream_id", &self.stream_id);
1456        debug_struct.field("service", &self.service);
1457        if !self._unknown_fields.is_empty() {
1458            debug_struct.field("_unknown_fields", &self._unknown_fields);
1459        }
1460        debug_struct.finish()
1461    }
1462}
1463
1464/// Data for a stream.
1465#[derive(Clone, Default, PartialEq)]
1466#[non_exhaustive]
1467pub struct StreamData {
1468    /// Required. The unique ID of this stream, assigned by the client.
1469    pub stream_id: i32,
1470
1471    /// The data of the stream, either bytes or "Close", indicating that the stream
1472    /// is done.
1473    pub contents: std::option::Option<crate::model::stream_data::Contents>,
1474
1475    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1476}
1477
1478impl StreamData {
1479    pub fn new() -> Self {
1480        std::default::Default::default()
1481    }
1482
1483    /// Sets the value of [stream_id][crate::model::StreamData::stream_id].
1484    pub fn set_stream_id<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
1485        self.stream_id = v.into();
1486        self
1487    }
1488
1489    /// Sets the value of [contents][crate::model::StreamData::contents].
1490    ///
1491    /// Note that all the setters affecting `contents` are mutually
1492    /// exclusive.
1493    pub fn set_contents<
1494        T: std::convert::Into<std::option::Option<crate::model::stream_data::Contents>>,
1495    >(
1496        mut self,
1497        v: T,
1498    ) -> Self {
1499        self.contents = v.into();
1500        self
1501    }
1502
1503    /// The value of [contents][crate::model::StreamData::contents]
1504    /// if it holds a `Data`, `None` if the field is not set or
1505    /// holds a different branch.
1506    pub fn data(&self) -> std::option::Option<&::bytes::Bytes> {
1507        #[allow(unreachable_patterns)]
1508        self.contents.as_ref().and_then(|v| match v {
1509            crate::model::stream_data::Contents::Data(v) => std::option::Option::Some(v),
1510            _ => std::option::Option::None,
1511        })
1512    }
1513
1514    /// Sets the value of [contents][crate::model::StreamData::contents]
1515    /// to hold a `Data`.
1516    ///
1517    /// Note that all the setters affecting `contents` are
1518    /// mutually exclusive.
1519    pub fn set_data<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
1520        self.contents =
1521            std::option::Option::Some(crate::model::stream_data::Contents::Data(v.into()));
1522        self
1523    }
1524
1525    /// The value of [contents][crate::model::StreamData::contents]
1526    /// if it holds a `Close`, `None` if the field is not set or
1527    /// holds a different branch.
1528    pub fn close(&self) -> std::option::Option<&std::boxed::Box<crate::model::Close>> {
1529        #[allow(unreachable_patterns)]
1530        self.contents.as_ref().and_then(|v| match v {
1531            crate::model::stream_data::Contents::Close(v) => std::option::Option::Some(v),
1532            _ => std::option::Option::None,
1533        })
1534    }
1535
1536    /// Sets the value of [contents][crate::model::StreamData::contents]
1537    /// to hold a `Close`.
1538    ///
1539    /// Note that all the setters affecting `contents` are
1540    /// mutually exclusive.
1541    pub fn set_close<T: std::convert::Into<std::boxed::Box<crate::model::Close>>>(
1542        mut self,
1543        v: T,
1544    ) -> Self {
1545        self.contents =
1546            std::option::Option::Some(crate::model::stream_data::Contents::Close(v.into()));
1547        self
1548    }
1549}
1550
1551impl wkt::message::Message for StreamData {
1552    fn typename() -> &'static str {
1553        "type.googleapis.com/google.cloud.devicestreaming.v1.StreamData"
1554    }
1555}
1556
1557#[doc(hidden)]
1558impl<'de> serde::de::Deserialize<'de> for StreamData {
1559    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1560    where
1561        D: serde::Deserializer<'de>,
1562    {
1563        #[allow(non_camel_case_types)]
1564        #[doc(hidden)]
1565        #[derive(PartialEq, Eq, Hash)]
1566        enum __FieldTag {
1567            __stream_id,
1568            __data,
1569            __close,
1570            Unknown(std::string::String),
1571        }
1572        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
1573            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1574            where
1575                D: serde::Deserializer<'de>,
1576            {
1577                struct Visitor;
1578                impl<'de> serde::de::Visitor<'de> for Visitor {
1579                    type Value = __FieldTag;
1580                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1581                        formatter.write_str("a field name for StreamData")
1582                    }
1583                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
1584                    where
1585                        E: serde::de::Error,
1586                    {
1587                        use std::result::Result::Ok;
1588                        use std::string::ToString;
1589                        match value {
1590                            "streamId" => Ok(__FieldTag::__stream_id),
1591                            "stream_id" => Ok(__FieldTag::__stream_id),
1592                            "data" => Ok(__FieldTag::__data),
1593                            "close" => Ok(__FieldTag::__close),
1594                            _ => Ok(__FieldTag::Unknown(value.to_string())),
1595                        }
1596                    }
1597                }
1598                deserializer.deserialize_identifier(Visitor)
1599            }
1600        }
1601        struct Visitor;
1602        impl<'de> serde::de::Visitor<'de> for Visitor {
1603            type Value = StreamData;
1604            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1605                formatter.write_str("struct StreamData")
1606            }
1607            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
1608            where
1609                A: serde::de::MapAccess<'de>,
1610            {
1611                #[allow(unused_imports)]
1612                use serde::de::Error;
1613                use std::option::Option::Some;
1614                let mut fields = std::collections::HashSet::new();
1615                let mut result = Self::Value::new();
1616                while let Some(tag) = map.next_key::<__FieldTag>()? {
1617                    #[allow(clippy::match_single_binding)]
1618                    match tag {
1619                        __FieldTag::__stream_id => {
1620                            if !fields.insert(__FieldTag::__stream_id) {
1621                                return std::result::Result::Err(A::Error::duplicate_field(
1622                                    "multiple values for stream_id",
1623                                ));
1624                            }
1625                            struct __With(std::option::Option<i32>);
1626                            impl<'de> serde::de::Deserialize<'de> for __With {
1627                                fn deserialize<D>(
1628                                    deserializer: D,
1629                                ) -> std::result::Result<Self, D::Error>
1630                                where
1631                                    D: serde::de::Deserializer<'de>,
1632                                {
1633                                    serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
1634                                }
1635                            }
1636                            result.stream_id = map.next_value::<__With>()?.0.unwrap_or_default();
1637                        }
1638                        __FieldTag::__data => {
1639                            if !fields.insert(__FieldTag::__data) {
1640                                return std::result::Result::Err(A::Error::duplicate_field(
1641                                    "multiple values for data",
1642                                ));
1643                            }
1644                            struct __With(std::option::Option<::bytes::Bytes>);
1645                            impl<'de> serde::de::Deserialize<'de> for __With {
1646                                fn deserialize<D>(
1647                                    deserializer: D,
1648                                ) -> std::result::Result<Self, D::Error>
1649                                where
1650                                    D: serde::de::Deserializer<'de>,
1651                                {
1652                                    serde_with::As::< std::option::Option<serde_with::base64::Base64> >::deserialize(deserializer).map(__With)
1653                                }
1654                            }
1655                            if result.contents.is_some() {
1656                                return std::result::Result::Err(A::Error::duplicate_field(
1657                                    "multiple values for `contents`, a oneof with full ID .google.cloud.devicestreaming.v1.StreamData.data, latest field was data",
1658                                ));
1659                            }
1660                            result.contents = std::option::Option::Some(
1661                                crate::model::stream_data::Contents::Data(
1662                                    map.next_value::<__With>()?.0.unwrap_or_default(),
1663                                ),
1664                            );
1665                        }
1666                        __FieldTag::__close => {
1667                            if !fields.insert(__FieldTag::__close) {
1668                                return std::result::Result::Err(A::Error::duplicate_field(
1669                                    "multiple values for close",
1670                                ));
1671                            }
1672                            if result.contents.is_some() {
1673                                return std::result::Result::Err(A::Error::duplicate_field(
1674                                    "multiple values for `contents`, a oneof with full ID .google.cloud.devicestreaming.v1.StreamData.close, latest field was close",
1675                                ));
1676                            }
1677                            result.contents =
1678                                std::option::Option::Some(
1679                                    crate::model::stream_data::Contents::Close(
1680                                        map.next_value::<std::option::Option<
1681                                            std::boxed::Box<crate::model::Close>,
1682                                        >>()?
1683                                        .unwrap_or_default(),
1684                                    ),
1685                                );
1686                        }
1687                        __FieldTag::Unknown(key) => {
1688                            let value = map.next_value::<serde_json::Value>()?;
1689                            result._unknown_fields.insert(key, value);
1690                        }
1691                    }
1692                }
1693                std::result::Result::Ok(result)
1694            }
1695        }
1696        deserializer.deserialize_any(Visitor)
1697    }
1698}
1699
1700#[doc(hidden)]
1701impl serde::ser::Serialize for StreamData {
1702    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1703    where
1704        S: serde::ser::Serializer,
1705    {
1706        use serde::ser::SerializeMap;
1707        #[allow(unused_imports)]
1708        use std::option::Option::Some;
1709        let mut state = serializer.serialize_map(std::option::Option::None)?;
1710        if !wkt::internal::is_default(&self.stream_id) {
1711            struct __With<'a>(&'a i32);
1712            impl<'a> serde::ser::Serialize for __With<'a> {
1713                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1714                where
1715                    S: serde::ser::Serializer,
1716                {
1717                    serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
1718                }
1719            }
1720            state.serialize_entry("streamId", &__With(&self.stream_id))?;
1721        }
1722        if let Some(value) = self.data() {
1723            struct __With<'a>(&'a ::bytes::Bytes);
1724            impl<'a> serde::ser::Serialize for __With<'a> {
1725                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1726                where
1727                    S: serde::ser::Serializer,
1728                {
1729                    serde_with::As::<serde_with::base64::Base64>::serialize(self.0, serializer)
1730                }
1731            }
1732            state.serialize_entry("data", &__With(value))?;
1733        }
1734        if let Some(value) = self.close() {
1735            state.serialize_entry("close", value)?;
1736        }
1737        if !self._unknown_fields.is_empty() {
1738            for (key, value) in self._unknown_fields.iter() {
1739                state.serialize_entry(key, &value)?;
1740            }
1741        }
1742        state.end()
1743    }
1744}
1745
1746impl std::fmt::Debug for StreamData {
1747    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1748        let mut debug_struct = f.debug_struct("StreamData");
1749        debug_struct.field("stream_id", &self.stream_id);
1750        debug_struct.field("contents", &self.contents);
1751        if !self._unknown_fields.is_empty() {
1752            debug_struct.field("_unknown_fields", &self._unknown_fields);
1753        }
1754        debug_struct.finish()
1755    }
1756}
1757
1758/// Defines additional types related to [StreamData].
1759pub mod stream_data {
1760    #[allow(unused_imports)]
1761    use super::*;
1762
1763    /// The data of the stream, either bytes or "Close", indicating that the stream
1764    /// is done.
1765    #[derive(Clone, Debug, PartialEq)]
1766    #[non_exhaustive]
1767    pub enum Contents {
1768        /// Data in the stream.
1769        Data(::bytes::Bytes),
1770        /// The stream is closing. EOF.
1771        Close(std::boxed::Box<crate::model::Close>),
1772    }
1773}
1774
1775/// Message signifying that the stream is open
1776#[derive(Clone, Default, PartialEq)]
1777#[non_exhaustive]
1778pub struct Okay {
1779    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1780}
1781
1782impl Okay {
1783    pub fn new() -> Self {
1784        std::default::Default::default()
1785    }
1786}
1787
1788impl wkt::message::Message for Okay {
1789    fn typename() -> &'static str {
1790        "type.googleapis.com/google.cloud.devicestreaming.v1.Okay"
1791    }
1792}
1793
1794#[doc(hidden)]
1795impl<'de> serde::de::Deserialize<'de> for Okay {
1796    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1797    where
1798        D: serde::Deserializer<'de>,
1799    {
1800        #[allow(non_camel_case_types)]
1801        #[doc(hidden)]
1802        #[derive(PartialEq, Eq, Hash)]
1803        enum __FieldTag {
1804            Unknown(std::string::String),
1805        }
1806        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
1807            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1808            where
1809                D: serde::Deserializer<'de>,
1810            {
1811                struct Visitor;
1812                impl<'de> serde::de::Visitor<'de> for Visitor {
1813                    type Value = __FieldTag;
1814                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1815                        formatter.write_str("a field name for Okay")
1816                    }
1817                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
1818                    where
1819                        E: serde::de::Error,
1820                    {
1821                        use std::result::Result::Ok;
1822                        use std::string::ToString;
1823                        Ok(__FieldTag::Unknown(value.to_string()))
1824                    }
1825                }
1826                deserializer.deserialize_identifier(Visitor)
1827            }
1828        }
1829        struct Visitor;
1830        impl<'de> serde::de::Visitor<'de> for Visitor {
1831            type Value = Okay;
1832            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1833                formatter.write_str("struct Okay")
1834            }
1835            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
1836            where
1837                A: serde::de::MapAccess<'de>,
1838            {
1839                #[allow(unused_imports)]
1840                use serde::de::Error;
1841                use std::option::Option::Some;
1842                let mut result = Self::Value::new();
1843                while let Some(tag) = map.next_key::<__FieldTag>()? {
1844                    #[allow(clippy::match_single_binding)]
1845                    match tag {
1846                        __FieldTag::Unknown(key) => {
1847                            let value = map.next_value::<serde_json::Value>()?;
1848                            result._unknown_fields.insert(key, value);
1849                        }
1850                    }
1851                }
1852                std::result::Result::Ok(result)
1853            }
1854        }
1855        deserializer.deserialize_any(Visitor)
1856    }
1857}
1858
1859#[doc(hidden)]
1860impl serde::ser::Serialize for Okay {
1861    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1862    where
1863        S: serde::ser::Serializer,
1864    {
1865        use serde::ser::SerializeMap;
1866        #[allow(unused_imports)]
1867        use std::option::Option::Some;
1868        let mut state = serializer.serialize_map(std::option::Option::None)?;
1869        if !self._unknown_fields.is_empty() {
1870            for (key, value) in self._unknown_fields.iter() {
1871                state.serialize_entry(key, &value)?;
1872            }
1873        }
1874        state.end()
1875    }
1876}
1877
1878impl std::fmt::Debug for Okay {
1879    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1880        let mut debug_struct = f.debug_struct("Okay");
1881        if !self._unknown_fields.is_empty() {
1882            debug_struct.field("_unknown_fields", &self._unknown_fields);
1883        }
1884        debug_struct.finish()
1885    }
1886}
1887
1888/// Message signifying that the stream failed to open
1889#[derive(Clone, Default, PartialEq)]
1890#[non_exhaustive]
1891pub struct Fail {
1892    /// A user-displayable failure reason.
1893    pub reason: std::string::String,
1894
1895    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1896}
1897
1898impl Fail {
1899    pub fn new() -> Self {
1900        std::default::Default::default()
1901    }
1902
1903    /// Sets the value of [reason][crate::model::Fail::reason].
1904    pub fn set_reason<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1905        self.reason = v.into();
1906        self
1907    }
1908}
1909
1910impl wkt::message::Message for Fail {
1911    fn typename() -> &'static str {
1912        "type.googleapis.com/google.cloud.devicestreaming.v1.Fail"
1913    }
1914}
1915
1916#[doc(hidden)]
1917impl<'de> serde::de::Deserialize<'de> for Fail {
1918    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1919    where
1920        D: serde::Deserializer<'de>,
1921    {
1922        #[allow(non_camel_case_types)]
1923        #[doc(hidden)]
1924        #[derive(PartialEq, Eq, Hash)]
1925        enum __FieldTag {
1926            __reason,
1927            Unknown(std::string::String),
1928        }
1929        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
1930            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1931            where
1932                D: serde::Deserializer<'de>,
1933            {
1934                struct Visitor;
1935                impl<'de> serde::de::Visitor<'de> for Visitor {
1936                    type Value = __FieldTag;
1937                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1938                        formatter.write_str("a field name for Fail")
1939                    }
1940                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
1941                    where
1942                        E: serde::de::Error,
1943                    {
1944                        use std::result::Result::Ok;
1945                        use std::string::ToString;
1946                        match value {
1947                            "reason" => Ok(__FieldTag::__reason),
1948                            _ => Ok(__FieldTag::Unknown(value.to_string())),
1949                        }
1950                    }
1951                }
1952                deserializer.deserialize_identifier(Visitor)
1953            }
1954        }
1955        struct Visitor;
1956        impl<'de> serde::de::Visitor<'de> for Visitor {
1957            type Value = Fail;
1958            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1959                formatter.write_str("struct Fail")
1960            }
1961            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
1962            where
1963                A: serde::de::MapAccess<'de>,
1964            {
1965                #[allow(unused_imports)]
1966                use serde::de::Error;
1967                use std::option::Option::Some;
1968                let mut fields = std::collections::HashSet::new();
1969                let mut result = Self::Value::new();
1970                while let Some(tag) = map.next_key::<__FieldTag>()? {
1971                    #[allow(clippy::match_single_binding)]
1972                    match tag {
1973                        __FieldTag::__reason => {
1974                            if !fields.insert(__FieldTag::__reason) {
1975                                return std::result::Result::Err(A::Error::duplicate_field(
1976                                    "multiple values for reason",
1977                                ));
1978                            }
1979                            result.reason = map
1980                                .next_value::<std::option::Option<std::string::String>>()?
1981                                .unwrap_or_default();
1982                        }
1983                        __FieldTag::Unknown(key) => {
1984                            let value = map.next_value::<serde_json::Value>()?;
1985                            result._unknown_fields.insert(key, value);
1986                        }
1987                    }
1988                }
1989                std::result::Result::Ok(result)
1990            }
1991        }
1992        deserializer.deserialize_any(Visitor)
1993    }
1994}
1995
1996#[doc(hidden)]
1997impl serde::ser::Serialize for Fail {
1998    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1999    where
2000        S: serde::ser::Serializer,
2001    {
2002        use serde::ser::SerializeMap;
2003        #[allow(unused_imports)]
2004        use std::option::Option::Some;
2005        let mut state = serializer.serialize_map(std::option::Option::None)?;
2006        if !self.reason.is_empty() {
2007            state.serialize_entry("reason", &self.reason)?;
2008        }
2009        if !self._unknown_fields.is_empty() {
2010            for (key, value) in self._unknown_fields.iter() {
2011                state.serialize_entry(key, &value)?;
2012            }
2013        }
2014        state.end()
2015    }
2016}
2017
2018impl std::fmt::Debug for Fail {
2019    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2020        let mut debug_struct = f.debug_struct("Fail");
2021        debug_struct.field("reason", &self.reason);
2022        if !self._unknown_fields.is_empty() {
2023            debug_struct.field("_unknown_fields", &self._unknown_fields);
2024        }
2025        debug_struct.finish()
2026    }
2027}
2028
2029/// Message signifying that the stream closed.
2030#[derive(Clone, Default, PartialEq)]
2031#[non_exhaustive]
2032pub struct Close {
2033    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2034}
2035
2036impl Close {
2037    pub fn new() -> Self {
2038        std::default::Default::default()
2039    }
2040}
2041
2042impl wkt::message::Message for Close {
2043    fn typename() -> &'static str {
2044        "type.googleapis.com/google.cloud.devicestreaming.v1.Close"
2045    }
2046}
2047
2048#[doc(hidden)]
2049impl<'de> serde::de::Deserialize<'de> for Close {
2050    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2051    where
2052        D: serde::Deserializer<'de>,
2053    {
2054        #[allow(non_camel_case_types)]
2055        #[doc(hidden)]
2056        #[derive(PartialEq, Eq, Hash)]
2057        enum __FieldTag {
2058            Unknown(std::string::String),
2059        }
2060        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
2061            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2062            where
2063                D: serde::Deserializer<'de>,
2064            {
2065                struct Visitor;
2066                impl<'de> serde::de::Visitor<'de> for Visitor {
2067                    type Value = __FieldTag;
2068                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2069                        formatter.write_str("a field name for Close")
2070                    }
2071                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
2072                    where
2073                        E: serde::de::Error,
2074                    {
2075                        use std::result::Result::Ok;
2076                        use std::string::ToString;
2077                        Ok(__FieldTag::Unknown(value.to_string()))
2078                    }
2079                }
2080                deserializer.deserialize_identifier(Visitor)
2081            }
2082        }
2083        struct Visitor;
2084        impl<'de> serde::de::Visitor<'de> for Visitor {
2085            type Value = Close;
2086            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2087                formatter.write_str("struct Close")
2088            }
2089            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
2090            where
2091                A: serde::de::MapAccess<'de>,
2092            {
2093                #[allow(unused_imports)]
2094                use serde::de::Error;
2095                use std::option::Option::Some;
2096                let mut result = Self::Value::new();
2097                while let Some(tag) = map.next_key::<__FieldTag>()? {
2098                    #[allow(clippy::match_single_binding)]
2099                    match tag {
2100                        __FieldTag::Unknown(key) => {
2101                            let value = map.next_value::<serde_json::Value>()?;
2102                            result._unknown_fields.insert(key, value);
2103                        }
2104                    }
2105                }
2106                std::result::Result::Ok(result)
2107            }
2108        }
2109        deserializer.deserialize_any(Visitor)
2110    }
2111}
2112
2113#[doc(hidden)]
2114impl serde::ser::Serialize for Close {
2115    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2116    where
2117        S: serde::ser::Serializer,
2118    {
2119        use serde::ser::SerializeMap;
2120        #[allow(unused_imports)]
2121        use std::option::Option::Some;
2122        let mut state = serializer.serialize_map(std::option::Option::None)?;
2123        if !self._unknown_fields.is_empty() {
2124            for (key, value) in self._unknown_fields.iter() {
2125                state.serialize_entry(key, &value)?;
2126            }
2127        }
2128        state.end()
2129    }
2130}
2131
2132impl std::fmt::Debug for Close {
2133    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2134        let mut debug_struct = f.debug_struct("Close");
2135        if !self._unknown_fields.is_empty() {
2136            debug_struct.field("_unknown_fields", &self._unknown_fields);
2137        }
2138        debug_struct.finish()
2139    }
2140}
2141
2142/// Request message for DirectAccessService.CreateDeviceSession.
2143#[derive(Clone, Default, PartialEq)]
2144#[non_exhaustive]
2145pub struct CreateDeviceSessionRequest {
2146    /// Required. The Compute Engine project under which this device will be
2147    /// allocated. "projects/{project_id}"
2148    pub parent: std::string::String,
2149
2150    /// Required. A DeviceSession to create.
2151    pub device_session: std::option::Option<crate::model::DeviceSession>,
2152
2153    /// Optional. The ID to use for the DeviceSession, which will become the final
2154    /// component of the DeviceSession's resource name.
2155    ///
2156    /// This value should be 4-63 characters, and valid characters
2157    /// are /[a-z][0-9]-/.
2158    pub device_session_id: std::string::String,
2159
2160    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2161}
2162
2163impl CreateDeviceSessionRequest {
2164    pub fn new() -> Self {
2165        std::default::Default::default()
2166    }
2167
2168    /// Sets the value of [parent][crate::model::CreateDeviceSessionRequest::parent].
2169    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2170        self.parent = v.into();
2171        self
2172    }
2173
2174    /// Sets the value of [device_session][crate::model::CreateDeviceSessionRequest::device_session].
2175    pub fn set_device_session<T>(mut self, v: T) -> Self
2176    where
2177        T: std::convert::Into<crate::model::DeviceSession>,
2178    {
2179        self.device_session = std::option::Option::Some(v.into());
2180        self
2181    }
2182
2183    /// Sets or clears the value of [device_session][crate::model::CreateDeviceSessionRequest::device_session].
2184    pub fn set_or_clear_device_session<T>(mut self, v: std::option::Option<T>) -> Self
2185    where
2186        T: std::convert::Into<crate::model::DeviceSession>,
2187    {
2188        self.device_session = v.map(|x| x.into());
2189        self
2190    }
2191
2192    /// Sets the value of [device_session_id][crate::model::CreateDeviceSessionRequest::device_session_id].
2193    pub fn set_device_session_id<T: std::convert::Into<std::string::String>>(
2194        mut self,
2195        v: T,
2196    ) -> Self {
2197        self.device_session_id = v.into();
2198        self
2199    }
2200}
2201
2202impl wkt::message::Message for CreateDeviceSessionRequest {
2203    fn typename() -> &'static str {
2204        "type.googleapis.com/google.cloud.devicestreaming.v1.CreateDeviceSessionRequest"
2205    }
2206}
2207
2208#[doc(hidden)]
2209impl<'de> serde::de::Deserialize<'de> for CreateDeviceSessionRequest {
2210    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2211    where
2212        D: serde::Deserializer<'de>,
2213    {
2214        #[allow(non_camel_case_types)]
2215        #[doc(hidden)]
2216        #[derive(PartialEq, Eq, Hash)]
2217        enum __FieldTag {
2218            __parent,
2219            __device_session,
2220            __device_session_id,
2221            Unknown(std::string::String),
2222        }
2223        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
2224            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2225            where
2226                D: serde::Deserializer<'de>,
2227            {
2228                struct Visitor;
2229                impl<'de> serde::de::Visitor<'de> for Visitor {
2230                    type Value = __FieldTag;
2231                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2232                        formatter.write_str("a field name for CreateDeviceSessionRequest")
2233                    }
2234                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
2235                    where
2236                        E: serde::de::Error,
2237                    {
2238                        use std::result::Result::Ok;
2239                        use std::string::ToString;
2240                        match value {
2241                            "parent" => Ok(__FieldTag::__parent),
2242                            "deviceSession" => Ok(__FieldTag::__device_session),
2243                            "device_session" => Ok(__FieldTag::__device_session),
2244                            "deviceSessionId" => Ok(__FieldTag::__device_session_id),
2245                            "device_session_id" => Ok(__FieldTag::__device_session_id),
2246                            _ => Ok(__FieldTag::Unknown(value.to_string())),
2247                        }
2248                    }
2249                }
2250                deserializer.deserialize_identifier(Visitor)
2251            }
2252        }
2253        struct Visitor;
2254        impl<'de> serde::de::Visitor<'de> for Visitor {
2255            type Value = CreateDeviceSessionRequest;
2256            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2257                formatter.write_str("struct CreateDeviceSessionRequest")
2258            }
2259            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
2260            where
2261                A: serde::de::MapAccess<'de>,
2262            {
2263                #[allow(unused_imports)]
2264                use serde::de::Error;
2265                use std::option::Option::Some;
2266                let mut fields = std::collections::HashSet::new();
2267                let mut result = Self::Value::new();
2268                while let Some(tag) = map.next_key::<__FieldTag>()? {
2269                    #[allow(clippy::match_single_binding)]
2270                    match tag {
2271                        __FieldTag::__parent => {
2272                            if !fields.insert(__FieldTag::__parent) {
2273                                return std::result::Result::Err(A::Error::duplicate_field(
2274                                    "multiple values for parent",
2275                                ));
2276                            }
2277                            result.parent = map
2278                                .next_value::<std::option::Option<std::string::String>>()?
2279                                .unwrap_or_default();
2280                        }
2281                        __FieldTag::__device_session => {
2282                            if !fields.insert(__FieldTag::__device_session) {
2283                                return std::result::Result::Err(A::Error::duplicate_field(
2284                                    "multiple values for device_session",
2285                                ));
2286                            }
2287                            result.device_session = map
2288                                .next_value::<std::option::Option<crate::model::DeviceSession>>()?;
2289                        }
2290                        __FieldTag::__device_session_id => {
2291                            if !fields.insert(__FieldTag::__device_session_id) {
2292                                return std::result::Result::Err(A::Error::duplicate_field(
2293                                    "multiple values for device_session_id",
2294                                ));
2295                            }
2296                            result.device_session_id = map
2297                                .next_value::<std::option::Option<std::string::String>>()?
2298                                .unwrap_or_default();
2299                        }
2300                        __FieldTag::Unknown(key) => {
2301                            let value = map.next_value::<serde_json::Value>()?;
2302                            result._unknown_fields.insert(key, value);
2303                        }
2304                    }
2305                }
2306                std::result::Result::Ok(result)
2307            }
2308        }
2309        deserializer.deserialize_any(Visitor)
2310    }
2311}
2312
2313#[doc(hidden)]
2314impl serde::ser::Serialize for CreateDeviceSessionRequest {
2315    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2316    where
2317        S: serde::ser::Serializer,
2318    {
2319        use serde::ser::SerializeMap;
2320        #[allow(unused_imports)]
2321        use std::option::Option::Some;
2322        let mut state = serializer.serialize_map(std::option::Option::None)?;
2323        if !self.parent.is_empty() {
2324            state.serialize_entry("parent", &self.parent)?;
2325        }
2326        if self.device_session.is_some() {
2327            state.serialize_entry("deviceSession", &self.device_session)?;
2328        }
2329        if !self.device_session_id.is_empty() {
2330            state.serialize_entry("deviceSessionId", &self.device_session_id)?;
2331        }
2332        if !self._unknown_fields.is_empty() {
2333            for (key, value) in self._unknown_fields.iter() {
2334                state.serialize_entry(key, &value)?;
2335            }
2336        }
2337        state.end()
2338    }
2339}
2340
2341impl std::fmt::Debug for CreateDeviceSessionRequest {
2342    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2343        let mut debug_struct = f.debug_struct("CreateDeviceSessionRequest");
2344        debug_struct.field("parent", &self.parent);
2345        debug_struct.field("device_session", &self.device_session);
2346        debug_struct.field("device_session_id", &self.device_session_id);
2347        if !self._unknown_fields.is_empty() {
2348            debug_struct.field("_unknown_fields", &self._unknown_fields);
2349        }
2350        debug_struct.finish()
2351    }
2352}
2353
2354/// Request message for DirectAccessService.ListDeviceSessions.
2355#[derive(Clone, Default, PartialEq)]
2356#[non_exhaustive]
2357pub struct ListDeviceSessionsRequest {
2358    /// Required. The name of the parent to request, e.g. "projects/{project_id}"
2359    pub parent: std::string::String,
2360
2361    /// Optional. The maximum number of DeviceSessions to return.
2362    pub page_size: i32,
2363
2364    /// Optional. A continuation token for paging.
2365    pub page_token: std::string::String,
2366
2367    /// Optional. If specified, responses will be filtered by the given filter.
2368    /// Allowed fields are: session_state.
2369    pub filter: std::string::String,
2370
2371    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2372}
2373
2374impl ListDeviceSessionsRequest {
2375    pub fn new() -> Self {
2376        std::default::Default::default()
2377    }
2378
2379    /// Sets the value of [parent][crate::model::ListDeviceSessionsRequest::parent].
2380    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2381        self.parent = v.into();
2382        self
2383    }
2384
2385    /// Sets the value of [page_size][crate::model::ListDeviceSessionsRequest::page_size].
2386    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
2387        self.page_size = v.into();
2388        self
2389    }
2390
2391    /// Sets the value of [page_token][crate::model::ListDeviceSessionsRequest::page_token].
2392    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2393        self.page_token = v.into();
2394        self
2395    }
2396
2397    /// Sets the value of [filter][crate::model::ListDeviceSessionsRequest::filter].
2398    pub fn set_filter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2399        self.filter = v.into();
2400        self
2401    }
2402}
2403
2404impl wkt::message::Message for ListDeviceSessionsRequest {
2405    fn typename() -> &'static str {
2406        "type.googleapis.com/google.cloud.devicestreaming.v1.ListDeviceSessionsRequest"
2407    }
2408}
2409
2410#[doc(hidden)]
2411impl<'de> serde::de::Deserialize<'de> for ListDeviceSessionsRequest {
2412    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2413    where
2414        D: serde::Deserializer<'de>,
2415    {
2416        #[allow(non_camel_case_types)]
2417        #[doc(hidden)]
2418        #[derive(PartialEq, Eq, Hash)]
2419        enum __FieldTag {
2420            __parent,
2421            __page_size,
2422            __page_token,
2423            __filter,
2424            Unknown(std::string::String),
2425        }
2426        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
2427            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2428            where
2429                D: serde::Deserializer<'de>,
2430            {
2431                struct Visitor;
2432                impl<'de> serde::de::Visitor<'de> for Visitor {
2433                    type Value = __FieldTag;
2434                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2435                        formatter.write_str("a field name for ListDeviceSessionsRequest")
2436                    }
2437                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
2438                    where
2439                        E: serde::de::Error,
2440                    {
2441                        use std::result::Result::Ok;
2442                        use std::string::ToString;
2443                        match value {
2444                            "parent" => Ok(__FieldTag::__parent),
2445                            "pageSize" => Ok(__FieldTag::__page_size),
2446                            "page_size" => Ok(__FieldTag::__page_size),
2447                            "pageToken" => Ok(__FieldTag::__page_token),
2448                            "page_token" => Ok(__FieldTag::__page_token),
2449                            "filter" => Ok(__FieldTag::__filter),
2450                            _ => Ok(__FieldTag::Unknown(value.to_string())),
2451                        }
2452                    }
2453                }
2454                deserializer.deserialize_identifier(Visitor)
2455            }
2456        }
2457        struct Visitor;
2458        impl<'de> serde::de::Visitor<'de> for Visitor {
2459            type Value = ListDeviceSessionsRequest;
2460            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2461                formatter.write_str("struct ListDeviceSessionsRequest")
2462            }
2463            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
2464            where
2465                A: serde::de::MapAccess<'de>,
2466            {
2467                #[allow(unused_imports)]
2468                use serde::de::Error;
2469                use std::option::Option::Some;
2470                let mut fields = std::collections::HashSet::new();
2471                let mut result = Self::Value::new();
2472                while let Some(tag) = map.next_key::<__FieldTag>()? {
2473                    #[allow(clippy::match_single_binding)]
2474                    match tag {
2475                        __FieldTag::__parent => {
2476                            if !fields.insert(__FieldTag::__parent) {
2477                                return std::result::Result::Err(A::Error::duplicate_field(
2478                                    "multiple values for parent",
2479                                ));
2480                            }
2481                            result.parent = map
2482                                .next_value::<std::option::Option<std::string::String>>()?
2483                                .unwrap_or_default();
2484                        }
2485                        __FieldTag::__page_size => {
2486                            if !fields.insert(__FieldTag::__page_size) {
2487                                return std::result::Result::Err(A::Error::duplicate_field(
2488                                    "multiple values for page_size",
2489                                ));
2490                            }
2491                            struct __With(std::option::Option<i32>);
2492                            impl<'de> serde::de::Deserialize<'de> for __With {
2493                                fn deserialize<D>(
2494                                    deserializer: D,
2495                                ) -> std::result::Result<Self, D::Error>
2496                                where
2497                                    D: serde::de::Deserializer<'de>,
2498                                {
2499                                    serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
2500                                }
2501                            }
2502                            result.page_size = map.next_value::<__With>()?.0.unwrap_or_default();
2503                        }
2504                        __FieldTag::__page_token => {
2505                            if !fields.insert(__FieldTag::__page_token) {
2506                                return std::result::Result::Err(A::Error::duplicate_field(
2507                                    "multiple values for page_token",
2508                                ));
2509                            }
2510                            result.page_token = map
2511                                .next_value::<std::option::Option<std::string::String>>()?
2512                                .unwrap_or_default();
2513                        }
2514                        __FieldTag::__filter => {
2515                            if !fields.insert(__FieldTag::__filter) {
2516                                return std::result::Result::Err(A::Error::duplicate_field(
2517                                    "multiple values for filter",
2518                                ));
2519                            }
2520                            result.filter = map
2521                                .next_value::<std::option::Option<std::string::String>>()?
2522                                .unwrap_or_default();
2523                        }
2524                        __FieldTag::Unknown(key) => {
2525                            let value = map.next_value::<serde_json::Value>()?;
2526                            result._unknown_fields.insert(key, value);
2527                        }
2528                    }
2529                }
2530                std::result::Result::Ok(result)
2531            }
2532        }
2533        deserializer.deserialize_any(Visitor)
2534    }
2535}
2536
2537#[doc(hidden)]
2538impl serde::ser::Serialize for ListDeviceSessionsRequest {
2539    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2540    where
2541        S: serde::ser::Serializer,
2542    {
2543        use serde::ser::SerializeMap;
2544        #[allow(unused_imports)]
2545        use std::option::Option::Some;
2546        let mut state = serializer.serialize_map(std::option::Option::None)?;
2547        if !self.parent.is_empty() {
2548            state.serialize_entry("parent", &self.parent)?;
2549        }
2550        if !wkt::internal::is_default(&self.page_size) {
2551            struct __With<'a>(&'a i32);
2552            impl<'a> serde::ser::Serialize for __With<'a> {
2553                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2554                where
2555                    S: serde::ser::Serializer,
2556                {
2557                    serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
2558                }
2559            }
2560            state.serialize_entry("pageSize", &__With(&self.page_size))?;
2561        }
2562        if !self.page_token.is_empty() {
2563            state.serialize_entry("pageToken", &self.page_token)?;
2564        }
2565        if !self.filter.is_empty() {
2566            state.serialize_entry("filter", &self.filter)?;
2567        }
2568        if !self._unknown_fields.is_empty() {
2569            for (key, value) in self._unknown_fields.iter() {
2570                state.serialize_entry(key, &value)?;
2571            }
2572        }
2573        state.end()
2574    }
2575}
2576
2577impl std::fmt::Debug for ListDeviceSessionsRequest {
2578    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2579        let mut debug_struct = f.debug_struct("ListDeviceSessionsRequest");
2580        debug_struct.field("parent", &self.parent);
2581        debug_struct.field("page_size", &self.page_size);
2582        debug_struct.field("page_token", &self.page_token);
2583        debug_struct.field("filter", &self.filter);
2584        if !self._unknown_fields.is_empty() {
2585            debug_struct.field("_unknown_fields", &self._unknown_fields);
2586        }
2587        debug_struct.finish()
2588    }
2589}
2590
2591/// Response message for DirectAccessService.ListDeviceSessions.
2592#[derive(Clone, Default, PartialEq)]
2593#[non_exhaustive]
2594pub struct ListDeviceSessionsResponse {
2595    /// The sessions matching the specified filter in the given cloud project.
2596    pub device_sessions: std::vec::Vec<crate::model::DeviceSession>,
2597
2598    /// A token, which can be sent as `page_token` to retrieve the next page.
2599    /// If this field is omitted, there are no subsequent pages.
2600    pub next_page_token: std::string::String,
2601
2602    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2603}
2604
2605impl ListDeviceSessionsResponse {
2606    pub fn new() -> Self {
2607        std::default::Default::default()
2608    }
2609
2610    /// Sets the value of [device_sessions][crate::model::ListDeviceSessionsResponse::device_sessions].
2611    pub fn set_device_sessions<T, V>(mut self, v: T) -> Self
2612    where
2613        T: std::iter::IntoIterator<Item = V>,
2614        V: std::convert::Into<crate::model::DeviceSession>,
2615    {
2616        use std::iter::Iterator;
2617        self.device_sessions = v.into_iter().map(|i| i.into()).collect();
2618        self
2619    }
2620
2621    /// Sets the value of [next_page_token][crate::model::ListDeviceSessionsResponse::next_page_token].
2622    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2623        self.next_page_token = v.into();
2624        self
2625    }
2626}
2627
2628impl wkt::message::Message for ListDeviceSessionsResponse {
2629    fn typename() -> &'static str {
2630        "type.googleapis.com/google.cloud.devicestreaming.v1.ListDeviceSessionsResponse"
2631    }
2632}
2633
2634#[doc(hidden)]
2635impl gax::paginator::internal::PageableResponse for ListDeviceSessionsResponse {
2636    type PageItem = crate::model::DeviceSession;
2637
2638    fn items(self) -> std::vec::Vec<Self::PageItem> {
2639        self.device_sessions
2640    }
2641
2642    fn next_page_token(&self) -> std::string::String {
2643        use std::clone::Clone;
2644        self.next_page_token.clone()
2645    }
2646}
2647
2648#[doc(hidden)]
2649impl<'de> serde::de::Deserialize<'de> for ListDeviceSessionsResponse {
2650    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2651    where
2652        D: serde::Deserializer<'de>,
2653    {
2654        #[allow(non_camel_case_types)]
2655        #[doc(hidden)]
2656        #[derive(PartialEq, Eq, Hash)]
2657        enum __FieldTag {
2658            __device_sessions,
2659            __next_page_token,
2660            Unknown(std::string::String),
2661        }
2662        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
2663            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2664            where
2665                D: serde::Deserializer<'de>,
2666            {
2667                struct Visitor;
2668                impl<'de> serde::de::Visitor<'de> for Visitor {
2669                    type Value = __FieldTag;
2670                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2671                        formatter.write_str("a field name for ListDeviceSessionsResponse")
2672                    }
2673                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
2674                    where
2675                        E: serde::de::Error,
2676                    {
2677                        use std::result::Result::Ok;
2678                        use std::string::ToString;
2679                        match value {
2680                            "deviceSessions" => Ok(__FieldTag::__device_sessions),
2681                            "device_sessions" => Ok(__FieldTag::__device_sessions),
2682                            "nextPageToken" => Ok(__FieldTag::__next_page_token),
2683                            "next_page_token" => Ok(__FieldTag::__next_page_token),
2684                            _ => Ok(__FieldTag::Unknown(value.to_string())),
2685                        }
2686                    }
2687                }
2688                deserializer.deserialize_identifier(Visitor)
2689            }
2690        }
2691        struct Visitor;
2692        impl<'de> serde::de::Visitor<'de> for Visitor {
2693            type Value = ListDeviceSessionsResponse;
2694            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2695                formatter.write_str("struct ListDeviceSessionsResponse")
2696            }
2697            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
2698            where
2699                A: serde::de::MapAccess<'de>,
2700            {
2701                #[allow(unused_imports)]
2702                use serde::de::Error;
2703                use std::option::Option::Some;
2704                let mut fields = std::collections::HashSet::new();
2705                let mut result = Self::Value::new();
2706                while let Some(tag) = map.next_key::<__FieldTag>()? {
2707                    #[allow(clippy::match_single_binding)]
2708                    match tag {
2709                        __FieldTag::__device_sessions => {
2710                            if !fields.insert(__FieldTag::__device_sessions) {
2711                                return std::result::Result::Err(A::Error::duplicate_field(
2712                                    "multiple values for device_sessions",
2713                                ));
2714                            }
2715                            result.device_sessions = map.next_value::<std::option::Option<std::vec::Vec<crate::model::DeviceSession>>>()?.unwrap_or_default();
2716                        }
2717                        __FieldTag::__next_page_token => {
2718                            if !fields.insert(__FieldTag::__next_page_token) {
2719                                return std::result::Result::Err(A::Error::duplicate_field(
2720                                    "multiple values for next_page_token",
2721                                ));
2722                            }
2723                            result.next_page_token = map
2724                                .next_value::<std::option::Option<std::string::String>>()?
2725                                .unwrap_or_default();
2726                        }
2727                        __FieldTag::Unknown(key) => {
2728                            let value = map.next_value::<serde_json::Value>()?;
2729                            result._unknown_fields.insert(key, value);
2730                        }
2731                    }
2732                }
2733                std::result::Result::Ok(result)
2734            }
2735        }
2736        deserializer.deserialize_any(Visitor)
2737    }
2738}
2739
2740#[doc(hidden)]
2741impl serde::ser::Serialize for ListDeviceSessionsResponse {
2742    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2743    where
2744        S: serde::ser::Serializer,
2745    {
2746        use serde::ser::SerializeMap;
2747        #[allow(unused_imports)]
2748        use std::option::Option::Some;
2749        let mut state = serializer.serialize_map(std::option::Option::None)?;
2750        if !self.device_sessions.is_empty() {
2751            state.serialize_entry("deviceSessions", &self.device_sessions)?;
2752        }
2753        if !self.next_page_token.is_empty() {
2754            state.serialize_entry("nextPageToken", &self.next_page_token)?;
2755        }
2756        if !self._unknown_fields.is_empty() {
2757            for (key, value) in self._unknown_fields.iter() {
2758                state.serialize_entry(key, &value)?;
2759            }
2760        }
2761        state.end()
2762    }
2763}
2764
2765impl std::fmt::Debug for ListDeviceSessionsResponse {
2766    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2767        let mut debug_struct = f.debug_struct("ListDeviceSessionsResponse");
2768        debug_struct.field("device_sessions", &self.device_sessions);
2769        debug_struct.field("next_page_token", &self.next_page_token);
2770        if !self._unknown_fields.is_empty() {
2771            debug_struct.field("_unknown_fields", &self._unknown_fields);
2772        }
2773        debug_struct.finish()
2774    }
2775}
2776
2777/// Request message for DirectAccessService.GetDeviceSession.
2778#[derive(Clone, Default, PartialEq)]
2779#[non_exhaustive]
2780pub struct GetDeviceSessionRequest {
2781    /// Required. Name of the DeviceSession, e.g.
2782    /// "projects/{project_id}/deviceSessions/{session_id}"
2783    pub name: std::string::String,
2784
2785    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2786}
2787
2788impl GetDeviceSessionRequest {
2789    pub fn new() -> Self {
2790        std::default::Default::default()
2791    }
2792
2793    /// Sets the value of [name][crate::model::GetDeviceSessionRequest::name].
2794    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2795        self.name = v.into();
2796        self
2797    }
2798}
2799
2800impl wkt::message::Message for GetDeviceSessionRequest {
2801    fn typename() -> &'static str {
2802        "type.googleapis.com/google.cloud.devicestreaming.v1.GetDeviceSessionRequest"
2803    }
2804}
2805
2806#[doc(hidden)]
2807impl<'de> serde::de::Deserialize<'de> for GetDeviceSessionRequest {
2808    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2809    where
2810        D: serde::Deserializer<'de>,
2811    {
2812        #[allow(non_camel_case_types)]
2813        #[doc(hidden)]
2814        #[derive(PartialEq, Eq, Hash)]
2815        enum __FieldTag {
2816            __name,
2817            Unknown(std::string::String),
2818        }
2819        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
2820            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2821            where
2822                D: serde::Deserializer<'de>,
2823            {
2824                struct Visitor;
2825                impl<'de> serde::de::Visitor<'de> for Visitor {
2826                    type Value = __FieldTag;
2827                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2828                        formatter.write_str("a field name for GetDeviceSessionRequest")
2829                    }
2830                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
2831                    where
2832                        E: serde::de::Error,
2833                    {
2834                        use std::result::Result::Ok;
2835                        use std::string::ToString;
2836                        match value {
2837                            "name" => Ok(__FieldTag::__name),
2838                            _ => Ok(__FieldTag::Unknown(value.to_string())),
2839                        }
2840                    }
2841                }
2842                deserializer.deserialize_identifier(Visitor)
2843            }
2844        }
2845        struct Visitor;
2846        impl<'de> serde::de::Visitor<'de> for Visitor {
2847            type Value = GetDeviceSessionRequest;
2848            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2849                formatter.write_str("struct GetDeviceSessionRequest")
2850            }
2851            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
2852            where
2853                A: serde::de::MapAccess<'de>,
2854            {
2855                #[allow(unused_imports)]
2856                use serde::de::Error;
2857                use std::option::Option::Some;
2858                let mut fields = std::collections::HashSet::new();
2859                let mut result = Self::Value::new();
2860                while let Some(tag) = map.next_key::<__FieldTag>()? {
2861                    #[allow(clippy::match_single_binding)]
2862                    match tag {
2863                        __FieldTag::__name => {
2864                            if !fields.insert(__FieldTag::__name) {
2865                                return std::result::Result::Err(A::Error::duplicate_field(
2866                                    "multiple values for name",
2867                                ));
2868                            }
2869                            result.name = map
2870                                .next_value::<std::option::Option<std::string::String>>()?
2871                                .unwrap_or_default();
2872                        }
2873                        __FieldTag::Unknown(key) => {
2874                            let value = map.next_value::<serde_json::Value>()?;
2875                            result._unknown_fields.insert(key, value);
2876                        }
2877                    }
2878                }
2879                std::result::Result::Ok(result)
2880            }
2881        }
2882        deserializer.deserialize_any(Visitor)
2883    }
2884}
2885
2886#[doc(hidden)]
2887impl serde::ser::Serialize for GetDeviceSessionRequest {
2888    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2889    where
2890        S: serde::ser::Serializer,
2891    {
2892        use serde::ser::SerializeMap;
2893        #[allow(unused_imports)]
2894        use std::option::Option::Some;
2895        let mut state = serializer.serialize_map(std::option::Option::None)?;
2896        if !self.name.is_empty() {
2897            state.serialize_entry("name", &self.name)?;
2898        }
2899        if !self._unknown_fields.is_empty() {
2900            for (key, value) in self._unknown_fields.iter() {
2901                state.serialize_entry(key, &value)?;
2902            }
2903        }
2904        state.end()
2905    }
2906}
2907
2908impl std::fmt::Debug for GetDeviceSessionRequest {
2909    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2910        let mut debug_struct = f.debug_struct("GetDeviceSessionRequest");
2911        debug_struct.field("name", &self.name);
2912        if !self._unknown_fields.is_empty() {
2913            debug_struct.field("_unknown_fields", &self._unknown_fields);
2914        }
2915        debug_struct.finish()
2916    }
2917}
2918
2919/// Request message for DirectAccessService.CancelDeviceSession.
2920#[derive(Clone, Default, PartialEq)]
2921#[non_exhaustive]
2922pub struct CancelDeviceSessionRequest {
2923    /// Required. Name of the DeviceSession, e.g.
2924    /// "projects/{project_id}/deviceSessions/{session_id}"
2925    pub name: std::string::String,
2926
2927    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2928}
2929
2930impl CancelDeviceSessionRequest {
2931    pub fn new() -> Self {
2932        std::default::Default::default()
2933    }
2934
2935    /// Sets the value of [name][crate::model::CancelDeviceSessionRequest::name].
2936    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2937        self.name = v.into();
2938        self
2939    }
2940}
2941
2942impl wkt::message::Message for CancelDeviceSessionRequest {
2943    fn typename() -> &'static str {
2944        "type.googleapis.com/google.cloud.devicestreaming.v1.CancelDeviceSessionRequest"
2945    }
2946}
2947
2948#[doc(hidden)]
2949impl<'de> serde::de::Deserialize<'de> for CancelDeviceSessionRequest {
2950    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2951    where
2952        D: serde::Deserializer<'de>,
2953    {
2954        #[allow(non_camel_case_types)]
2955        #[doc(hidden)]
2956        #[derive(PartialEq, Eq, Hash)]
2957        enum __FieldTag {
2958            __name,
2959            Unknown(std::string::String),
2960        }
2961        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
2962            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2963            where
2964                D: serde::Deserializer<'de>,
2965            {
2966                struct Visitor;
2967                impl<'de> serde::de::Visitor<'de> for Visitor {
2968                    type Value = __FieldTag;
2969                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2970                        formatter.write_str("a field name for CancelDeviceSessionRequest")
2971                    }
2972                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
2973                    where
2974                        E: serde::de::Error,
2975                    {
2976                        use std::result::Result::Ok;
2977                        use std::string::ToString;
2978                        match value {
2979                            "name" => Ok(__FieldTag::__name),
2980                            _ => Ok(__FieldTag::Unknown(value.to_string())),
2981                        }
2982                    }
2983                }
2984                deserializer.deserialize_identifier(Visitor)
2985            }
2986        }
2987        struct Visitor;
2988        impl<'de> serde::de::Visitor<'de> for Visitor {
2989            type Value = CancelDeviceSessionRequest;
2990            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2991                formatter.write_str("struct CancelDeviceSessionRequest")
2992            }
2993            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
2994            where
2995                A: serde::de::MapAccess<'de>,
2996            {
2997                #[allow(unused_imports)]
2998                use serde::de::Error;
2999                use std::option::Option::Some;
3000                let mut fields = std::collections::HashSet::new();
3001                let mut result = Self::Value::new();
3002                while let Some(tag) = map.next_key::<__FieldTag>()? {
3003                    #[allow(clippy::match_single_binding)]
3004                    match tag {
3005                        __FieldTag::__name => {
3006                            if !fields.insert(__FieldTag::__name) {
3007                                return std::result::Result::Err(A::Error::duplicate_field(
3008                                    "multiple values for name",
3009                                ));
3010                            }
3011                            result.name = map
3012                                .next_value::<std::option::Option<std::string::String>>()?
3013                                .unwrap_or_default();
3014                        }
3015                        __FieldTag::Unknown(key) => {
3016                            let value = map.next_value::<serde_json::Value>()?;
3017                            result._unknown_fields.insert(key, value);
3018                        }
3019                    }
3020                }
3021                std::result::Result::Ok(result)
3022            }
3023        }
3024        deserializer.deserialize_any(Visitor)
3025    }
3026}
3027
3028#[doc(hidden)]
3029impl serde::ser::Serialize for CancelDeviceSessionRequest {
3030    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3031    where
3032        S: serde::ser::Serializer,
3033    {
3034        use serde::ser::SerializeMap;
3035        #[allow(unused_imports)]
3036        use std::option::Option::Some;
3037        let mut state = serializer.serialize_map(std::option::Option::None)?;
3038        if !self.name.is_empty() {
3039            state.serialize_entry("name", &self.name)?;
3040        }
3041        if !self._unknown_fields.is_empty() {
3042            for (key, value) in self._unknown_fields.iter() {
3043                state.serialize_entry(key, &value)?;
3044            }
3045        }
3046        state.end()
3047    }
3048}
3049
3050impl std::fmt::Debug for CancelDeviceSessionRequest {
3051    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3052        let mut debug_struct = f.debug_struct("CancelDeviceSessionRequest");
3053        debug_struct.field("name", &self.name);
3054        if !self._unknown_fields.is_empty() {
3055            debug_struct.field("_unknown_fields", &self._unknown_fields);
3056        }
3057        debug_struct.finish()
3058    }
3059}
3060
3061/// Request message for DirectAccessService.UpdateDeviceSession.
3062#[derive(Clone, Default, PartialEq)]
3063#[non_exhaustive]
3064pub struct UpdateDeviceSessionRequest {
3065    /// Required. DeviceSession to update.
3066    /// The DeviceSession's `name` field is used to identify the session to update
3067    /// "projects/{project_id}/deviceSessions/{session_id}"
3068    pub device_session: std::option::Option<crate::model::DeviceSession>,
3069
3070    /// Optional. The list of fields to update.
3071    pub update_mask: std::option::Option<wkt::FieldMask>,
3072
3073    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3074}
3075
3076impl UpdateDeviceSessionRequest {
3077    pub fn new() -> Self {
3078        std::default::Default::default()
3079    }
3080
3081    /// Sets the value of [device_session][crate::model::UpdateDeviceSessionRequest::device_session].
3082    pub fn set_device_session<T>(mut self, v: T) -> Self
3083    where
3084        T: std::convert::Into<crate::model::DeviceSession>,
3085    {
3086        self.device_session = std::option::Option::Some(v.into());
3087        self
3088    }
3089
3090    /// Sets or clears the value of [device_session][crate::model::UpdateDeviceSessionRequest::device_session].
3091    pub fn set_or_clear_device_session<T>(mut self, v: std::option::Option<T>) -> Self
3092    where
3093        T: std::convert::Into<crate::model::DeviceSession>,
3094    {
3095        self.device_session = v.map(|x| x.into());
3096        self
3097    }
3098
3099    /// Sets the value of [update_mask][crate::model::UpdateDeviceSessionRequest::update_mask].
3100    pub fn set_update_mask<T>(mut self, v: T) -> Self
3101    where
3102        T: std::convert::Into<wkt::FieldMask>,
3103    {
3104        self.update_mask = std::option::Option::Some(v.into());
3105        self
3106    }
3107
3108    /// Sets or clears the value of [update_mask][crate::model::UpdateDeviceSessionRequest::update_mask].
3109    pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
3110    where
3111        T: std::convert::Into<wkt::FieldMask>,
3112    {
3113        self.update_mask = v.map(|x| x.into());
3114        self
3115    }
3116}
3117
3118impl wkt::message::Message for UpdateDeviceSessionRequest {
3119    fn typename() -> &'static str {
3120        "type.googleapis.com/google.cloud.devicestreaming.v1.UpdateDeviceSessionRequest"
3121    }
3122}
3123
3124#[doc(hidden)]
3125impl<'de> serde::de::Deserialize<'de> for UpdateDeviceSessionRequest {
3126    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3127    where
3128        D: serde::Deserializer<'de>,
3129    {
3130        #[allow(non_camel_case_types)]
3131        #[doc(hidden)]
3132        #[derive(PartialEq, Eq, Hash)]
3133        enum __FieldTag {
3134            __device_session,
3135            __update_mask,
3136            Unknown(std::string::String),
3137        }
3138        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
3139            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3140            where
3141                D: serde::Deserializer<'de>,
3142            {
3143                struct Visitor;
3144                impl<'de> serde::de::Visitor<'de> for Visitor {
3145                    type Value = __FieldTag;
3146                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3147                        formatter.write_str("a field name for UpdateDeviceSessionRequest")
3148                    }
3149                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
3150                    where
3151                        E: serde::de::Error,
3152                    {
3153                        use std::result::Result::Ok;
3154                        use std::string::ToString;
3155                        match value {
3156                            "deviceSession" => Ok(__FieldTag::__device_session),
3157                            "device_session" => Ok(__FieldTag::__device_session),
3158                            "updateMask" => Ok(__FieldTag::__update_mask),
3159                            "update_mask" => Ok(__FieldTag::__update_mask),
3160                            _ => Ok(__FieldTag::Unknown(value.to_string())),
3161                        }
3162                    }
3163                }
3164                deserializer.deserialize_identifier(Visitor)
3165            }
3166        }
3167        struct Visitor;
3168        impl<'de> serde::de::Visitor<'de> for Visitor {
3169            type Value = UpdateDeviceSessionRequest;
3170            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3171                formatter.write_str("struct UpdateDeviceSessionRequest")
3172            }
3173            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
3174            where
3175                A: serde::de::MapAccess<'de>,
3176            {
3177                #[allow(unused_imports)]
3178                use serde::de::Error;
3179                use std::option::Option::Some;
3180                let mut fields = std::collections::HashSet::new();
3181                let mut result = Self::Value::new();
3182                while let Some(tag) = map.next_key::<__FieldTag>()? {
3183                    #[allow(clippy::match_single_binding)]
3184                    match tag {
3185                        __FieldTag::__device_session => {
3186                            if !fields.insert(__FieldTag::__device_session) {
3187                                return std::result::Result::Err(A::Error::duplicate_field(
3188                                    "multiple values for device_session",
3189                                ));
3190                            }
3191                            result.device_session = map
3192                                .next_value::<std::option::Option<crate::model::DeviceSession>>()?;
3193                        }
3194                        __FieldTag::__update_mask => {
3195                            if !fields.insert(__FieldTag::__update_mask) {
3196                                return std::result::Result::Err(A::Error::duplicate_field(
3197                                    "multiple values for update_mask",
3198                                ));
3199                            }
3200                            result.update_mask =
3201                                map.next_value::<std::option::Option<wkt::FieldMask>>()?;
3202                        }
3203                        __FieldTag::Unknown(key) => {
3204                            let value = map.next_value::<serde_json::Value>()?;
3205                            result._unknown_fields.insert(key, value);
3206                        }
3207                    }
3208                }
3209                std::result::Result::Ok(result)
3210            }
3211        }
3212        deserializer.deserialize_any(Visitor)
3213    }
3214}
3215
3216#[doc(hidden)]
3217impl serde::ser::Serialize for UpdateDeviceSessionRequest {
3218    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3219    where
3220        S: serde::ser::Serializer,
3221    {
3222        use serde::ser::SerializeMap;
3223        #[allow(unused_imports)]
3224        use std::option::Option::Some;
3225        let mut state = serializer.serialize_map(std::option::Option::None)?;
3226        if self.device_session.is_some() {
3227            state.serialize_entry("deviceSession", &self.device_session)?;
3228        }
3229        if self.update_mask.is_some() {
3230            state.serialize_entry("updateMask", &self.update_mask)?;
3231        }
3232        if !self._unknown_fields.is_empty() {
3233            for (key, value) in self._unknown_fields.iter() {
3234                state.serialize_entry(key, &value)?;
3235            }
3236        }
3237        state.end()
3238    }
3239}
3240
3241impl std::fmt::Debug for UpdateDeviceSessionRequest {
3242    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3243        let mut debug_struct = f.debug_struct("UpdateDeviceSessionRequest");
3244        debug_struct.field("device_session", &self.device_session);
3245        debug_struct.field("update_mask", &self.update_mask);
3246        if !self._unknown_fields.is_empty() {
3247            debug_struct.field("_unknown_fields", &self._unknown_fields);
3248        }
3249        debug_struct.finish()
3250    }
3251}
3252
3253/// Protobuf message describing the device message, used from several RPCs.
3254#[derive(Clone, Default, PartialEq)]
3255#[non_exhaustive]
3256pub struct DeviceSession {
3257    /// Optional. Name of the DeviceSession, e.g.
3258    /// "projects/{project_id}/deviceSessions/{session_id}"
3259    pub name: std::string::String,
3260
3261    /// Output only. The title of the DeviceSession to be presented in the UI.
3262    pub display_name: std::string::String,
3263
3264    /// Output only. Current state of the DeviceSession.
3265    pub state: crate::model::device_session::SessionState,
3266
3267    /// Output only. The historical state transitions of the session_state message
3268    /// including the current session state.
3269    pub state_histories: std::vec::Vec<crate::model::device_session::SessionStateEvent>,
3270
3271    /// Output only. The interval of time that this device must be interacted with
3272    /// before it transitions from ACTIVE to TIMEOUT_INACTIVITY.
3273    pub inactivity_timeout: std::option::Option<wkt::Duration>,
3274
3275    /// Output only. The time that the Session was created.
3276    pub create_time: std::option::Option<wkt::Timestamp>,
3277
3278    /// Output only. The timestamp that the session first became ACTIVE.
3279    pub active_start_time: std::option::Option<wkt::Timestamp>,
3280
3281    /// Required. The requested device
3282    pub android_device: std::option::Option<crate::model::AndroidDevice>,
3283
3284    /// The amount of time that a device will be initially allocated for.
3285    pub expiration: std::option::Option<crate::model::device_session::Expiration>,
3286
3287    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3288}
3289
3290impl DeviceSession {
3291    pub fn new() -> Self {
3292        std::default::Default::default()
3293    }
3294
3295    /// Sets the value of [name][crate::model::DeviceSession::name].
3296    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3297        self.name = v.into();
3298        self
3299    }
3300
3301    /// Sets the value of [display_name][crate::model::DeviceSession::display_name].
3302    pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3303        self.display_name = v.into();
3304        self
3305    }
3306
3307    /// Sets the value of [state][crate::model::DeviceSession::state].
3308    pub fn set_state<T: std::convert::Into<crate::model::device_session::SessionState>>(
3309        mut self,
3310        v: T,
3311    ) -> Self {
3312        self.state = v.into();
3313        self
3314    }
3315
3316    /// Sets the value of [state_histories][crate::model::DeviceSession::state_histories].
3317    pub fn set_state_histories<T, V>(mut self, v: T) -> Self
3318    where
3319        T: std::iter::IntoIterator<Item = V>,
3320        V: std::convert::Into<crate::model::device_session::SessionStateEvent>,
3321    {
3322        use std::iter::Iterator;
3323        self.state_histories = v.into_iter().map(|i| i.into()).collect();
3324        self
3325    }
3326
3327    /// Sets the value of [inactivity_timeout][crate::model::DeviceSession::inactivity_timeout].
3328    pub fn set_inactivity_timeout<T>(mut self, v: T) -> Self
3329    where
3330        T: std::convert::Into<wkt::Duration>,
3331    {
3332        self.inactivity_timeout = std::option::Option::Some(v.into());
3333        self
3334    }
3335
3336    /// Sets or clears the value of [inactivity_timeout][crate::model::DeviceSession::inactivity_timeout].
3337    pub fn set_or_clear_inactivity_timeout<T>(mut self, v: std::option::Option<T>) -> Self
3338    where
3339        T: std::convert::Into<wkt::Duration>,
3340    {
3341        self.inactivity_timeout = v.map(|x| x.into());
3342        self
3343    }
3344
3345    /// Sets the value of [create_time][crate::model::DeviceSession::create_time].
3346    pub fn set_create_time<T>(mut self, v: T) -> Self
3347    where
3348        T: std::convert::Into<wkt::Timestamp>,
3349    {
3350        self.create_time = std::option::Option::Some(v.into());
3351        self
3352    }
3353
3354    /// Sets or clears the value of [create_time][crate::model::DeviceSession::create_time].
3355    pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
3356    where
3357        T: std::convert::Into<wkt::Timestamp>,
3358    {
3359        self.create_time = v.map(|x| x.into());
3360        self
3361    }
3362
3363    /// Sets the value of [active_start_time][crate::model::DeviceSession::active_start_time].
3364    pub fn set_active_start_time<T>(mut self, v: T) -> Self
3365    where
3366        T: std::convert::Into<wkt::Timestamp>,
3367    {
3368        self.active_start_time = std::option::Option::Some(v.into());
3369        self
3370    }
3371
3372    /// Sets or clears the value of [active_start_time][crate::model::DeviceSession::active_start_time].
3373    pub fn set_or_clear_active_start_time<T>(mut self, v: std::option::Option<T>) -> Self
3374    where
3375        T: std::convert::Into<wkt::Timestamp>,
3376    {
3377        self.active_start_time = v.map(|x| x.into());
3378        self
3379    }
3380
3381    /// Sets the value of [android_device][crate::model::DeviceSession::android_device].
3382    pub fn set_android_device<T>(mut self, v: T) -> Self
3383    where
3384        T: std::convert::Into<crate::model::AndroidDevice>,
3385    {
3386        self.android_device = std::option::Option::Some(v.into());
3387        self
3388    }
3389
3390    /// Sets or clears the value of [android_device][crate::model::DeviceSession::android_device].
3391    pub fn set_or_clear_android_device<T>(mut self, v: std::option::Option<T>) -> Self
3392    where
3393        T: std::convert::Into<crate::model::AndroidDevice>,
3394    {
3395        self.android_device = v.map(|x| x.into());
3396        self
3397    }
3398
3399    /// Sets the value of [expiration][crate::model::DeviceSession::expiration].
3400    ///
3401    /// Note that all the setters affecting `expiration` are mutually
3402    /// exclusive.
3403    pub fn set_expiration<
3404        T: std::convert::Into<std::option::Option<crate::model::device_session::Expiration>>,
3405    >(
3406        mut self,
3407        v: T,
3408    ) -> Self {
3409        self.expiration = v.into();
3410        self
3411    }
3412
3413    /// The value of [expiration][crate::model::DeviceSession::expiration]
3414    /// if it holds a `Ttl`, `None` if the field is not set or
3415    /// holds a different branch.
3416    pub fn ttl(&self) -> std::option::Option<&std::boxed::Box<wkt::Duration>> {
3417        #[allow(unreachable_patterns)]
3418        self.expiration.as_ref().and_then(|v| match v {
3419            crate::model::device_session::Expiration::Ttl(v) => std::option::Option::Some(v),
3420            _ => std::option::Option::None,
3421        })
3422    }
3423
3424    /// Sets the value of [expiration][crate::model::DeviceSession::expiration]
3425    /// to hold a `Ttl`.
3426    ///
3427    /// Note that all the setters affecting `expiration` are
3428    /// mutually exclusive.
3429    pub fn set_ttl<T: std::convert::Into<std::boxed::Box<wkt::Duration>>>(mut self, v: T) -> Self {
3430        self.expiration =
3431            std::option::Option::Some(crate::model::device_session::Expiration::Ttl(v.into()));
3432        self
3433    }
3434
3435    /// The value of [expiration][crate::model::DeviceSession::expiration]
3436    /// if it holds a `ExpireTime`, `None` if the field is not set or
3437    /// holds a different branch.
3438    pub fn expire_time(&self) -> std::option::Option<&std::boxed::Box<wkt::Timestamp>> {
3439        #[allow(unreachable_patterns)]
3440        self.expiration.as_ref().and_then(|v| match v {
3441            crate::model::device_session::Expiration::ExpireTime(v) => std::option::Option::Some(v),
3442            _ => std::option::Option::None,
3443        })
3444    }
3445
3446    /// Sets the value of [expiration][crate::model::DeviceSession::expiration]
3447    /// to hold a `ExpireTime`.
3448    ///
3449    /// Note that all the setters affecting `expiration` are
3450    /// mutually exclusive.
3451    pub fn set_expire_time<T: std::convert::Into<std::boxed::Box<wkt::Timestamp>>>(
3452        mut self,
3453        v: T,
3454    ) -> Self {
3455        self.expiration = std::option::Option::Some(
3456            crate::model::device_session::Expiration::ExpireTime(v.into()),
3457        );
3458        self
3459    }
3460}
3461
3462impl wkt::message::Message for DeviceSession {
3463    fn typename() -> &'static str {
3464        "type.googleapis.com/google.cloud.devicestreaming.v1.DeviceSession"
3465    }
3466}
3467
3468#[doc(hidden)]
3469impl<'de> serde::de::Deserialize<'de> for DeviceSession {
3470    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3471    where
3472        D: serde::Deserializer<'de>,
3473    {
3474        #[allow(non_camel_case_types)]
3475        #[doc(hidden)]
3476        #[derive(PartialEq, Eq, Hash)]
3477        enum __FieldTag {
3478            __name,
3479            __display_name,
3480            __state,
3481            __state_histories,
3482            __ttl,
3483            __expire_time,
3484            __inactivity_timeout,
3485            __create_time,
3486            __active_start_time,
3487            __android_device,
3488            Unknown(std::string::String),
3489        }
3490        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
3491            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3492            where
3493                D: serde::Deserializer<'de>,
3494            {
3495                struct Visitor;
3496                impl<'de> serde::de::Visitor<'de> for Visitor {
3497                    type Value = __FieldTag;
3498                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3499                        formatter.write_str("a field name for DeviceSession")
3500                    }
3501                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
3502                    where
3503                        E: serde::de::Error,
3504                    {
3505                        use std::result::Result::Ok;
3506                        use std::string::ToString;
3507                        match value {
3508                            "name" => Ok(__FieldTag::__name),
3509                            "displayName" => Ok(__FieldTag::__display_name),
3510                            "display_name" => Ok(__FieldTag::__display_name),
3511                            "state" => Ok(__FieldTag::__state),
3512                            "stateHistories" => Ok(__FieldTag::__state_histories),
3513                            "state_histories" => Ok(__FieldTag::__state_histories),
3514                            "ttl" => Ok(__FieldTag::__ttl),
3515                            "expireTime" => Ok(__FieldTag::__expire_time),
3516                            "expire_time" => Ok(__FieldTag::__expire_time),
3517                            "inactivityTimeout" => Ok(__FieldTag::__inactivity_timeout),
3518                            "inactivity_timeout" => Ok(__FieldTag::__inactivity_timeout),
3519                            "createTime" => Ok(__FieldTag::__create_time),
3520                            "create_time" => Ok(__FieldTag::__create_time),
3521                            "activeStartTime" => Ok(__FieldTag::__active_start_time),
3522                            "active_start_time" => Ok(__FieldTag::__active_start_time),
3523                            "androidDevice" => Ok(__FieldTag::__android_device),
3524                            "android_device" => Ok(__FieldTag::__android_device),
3525                            _ => Ok(__FieldTag::Unknown(value.to_string())),
3526                        }
3527                    }
3528                }
3529                deserializer.deserialize_identifier(Visitor)
3530            }
3531        }
3532        struct Visitor;
3533        impl<'de> serde::de::Visitor<'de> for Visitor {
3534            type Value = DeviceSession;
3535            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3536                formatter.write_str("struct DeviceSession")
3537            }
3538            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
3539            where
3540                A: serde::de::MapAccess<'de>,
3541            {
3542                #[allow(unused_imports)]
3543                use serde::de::Error;
3544                use std::option::Option::Some;
3545                let mut fields = std::collections::HashSet::new();
3546                let mut result = Self::Value::new();
3547                while let Some(tag) = map.next_key::<__FieldTag>()? {
3548                    #[allow(clippy::match_single_binding)]
3549                    match tag {
3550                        __FieldTag::__name => {
3551                            if !fields.insert(__FieldTag::__name) {
3552                                return std::result::Result::Err(A::Error::duplicate_field(
3553                                    "multiple values for name",
3554                                ));
3555                            }
3556                            result.name = map
3557                                .next_value::<std::option::Option<std::string::String>>()?
3558                                .unwrap_or_default();
3559                        }
3560                        __FieldTag::__display_name => {
3561                            if !fields.insert(__FieldTag::__display_name) {
3562                                return std::result::Result::Err(A::Error::duplicate_field(
3563                                    "multiple values for display_name",
3564                                ));
3565                            }
3566                            result.display_name = map
3567                                .next_value::<std::option::Option<std::string::String>>()?
3568                                .unwrap_or_default();
3569                        }
3570                        __FieldTag::__state => {
3571                            if !fields.insert(__FieldTag::__state) {
3572                                return std::result::Result::Err(A::Error::duplicate_field(
3573                                    "multiple values for state",
3574                                ));
3575                            }
3576                            result.state = map.next_value::<std::option::Option<crate::model::device_session::SessionState>>()?.unwrap_or_default();
3577                        }
3578                        __FieldTag::__state_histories => {
3579                            if !fields.insert(__FieldTag::__state_histories) {
3580                                return std::result::Result::Err(A::Error::duplicate_field(
3581                                    "multiple values for state_histories",
3582                                ));
3583                            }
3584                            result.state_histories = map
3585                                .next_value::<std::option::Option<
3586                                    std::vec::Vec<crate::model::device_session::SessionStateEvent>,
3587                                >>()?
3588                                .unwrap_or_default();
3589                        }
3590                        __FieldTag::__ttl => {
3591                            if !fields.insert(__FieldTag::__ttl) {
3592                                return std::result::Result::Err(A::Error::duplicate_field(
3593                                    "multiple values for ttl",
3594                                ));
3595                            }
3596                            if result.expiration.is_some() {
3597                                return std::result::Result::Err(A::Error::duplicate_field(
3598                                    "multiple values for `expiration`, a oneof with full ID .google.cloud.devicestreaming.v1.DeviceSession.ttl, latest field was ttl",
3599                                ));
3600                            }
3601                            result.expiration = std::option::Option::Some(
3602                                crate::model::device_session::Expiration::Ttl(
3603                                    map.next_value::<std::option::Option<std::boxed::Box<wkt::Duration>>>()?.unwrap_or_default()
3604                                ),
3605                            );
3606                        }
3607                        __FieldTag::__expire_time => {
3608                            if !fields.insert(__FieldTag::__expire_time) {
3609                                return std::result::Result::Err(A::Error::duplicate_field(
3610                                    "multiple values for expire_time",
3611                                ));
3612                            }
3613                            if result.expiration.is_some() {
3614                                return std::result::Result::Err(A::Error::duplicate_field(
3615                                    "multiple values for `expiration`, a oneof with full ID .google.cloud.devicestreaming.v1.DeviceSession.expire_time, latest field was expireTime",
3616                                ));
3617                            }
3618                            result.expiration = std::option::Option::Some(
3619                                crate::model::device_session::Expiration::ExpireTime(
3620                                    map.next_value::<std::option::Option<std::boxed::Box<wkt::Timestamp>>>()?.unwrap_or_default()
3621                                ),
3622                            );
3623                        }
3624                        __FieldTag::__inactivity_timeout => {
3625                            if !fields.insert(__FieldTag::__inactivity_timeout) {
3626                                return std::result::Result::Err(A::Error::duplicate_field(
3627                                    "multiple values for inactivity_timeout",
3628                                ));
3629                            }
3630                            result.inactivity_timeout =
3631                                map.next_value::<std::option::Option<wkt::Duration>>()?;
3632                        }
3633                        __FieldTag::__create_time => {
3634                            if !fields.insert(__FieldTag::__create_time) {
3635                                return std::result::Result::Err(A::Error::duplicate_field(
3636                                    "multiple values for create_time",
3637                                ));
3638                            }
3639                            result.create_time =
3640                                map.next_value::<std::option::Option<wkt::Timestamp>>()?;
3641                        }
3642                        __FieldTag::__active_start_time => {
3643                            if !fields.insert(__FieldTag::__active_start_time) {
3644                                return std::result::Result::Err(A::Error::duplicate_field(
3645                                    "multiple values for active_start_time",
3646                                ));
3647                            }
3648                            result.active_start_time =
3649                                map.next_value::<std::option::Option<wkt::Timestamp>>()?;
3650                        }
3651                        __FieldTag::__android_device => {
3652                            if !fields.insert(__FieldTag::__android_device) {
3653                                return std::result::Result::Err(A::Error::duplicate_field(
3654                                    "multiple values for android_device",
3655                                ));
3656                            }
3657                            result.android_device = map
3658                                .next_value::<std::option::Option<crate::model::AndroidDevice>>()?;
3659                        }
3660                        __FieldTag::Unknown(key) => {
3661                            let value = map.next_value::<serde_json::Value>()?;
3662                            result._unknown_fields.insert(key, value);
3663                        }
3664                    }
3665                }
3666                std::result::Result::Ok(result)
3667            }
3668        }
3669        deserializer.deserialize_any(Visitor)
3670    }
3671}
3672
3673#[doc(hidden)]
3674impl serde::ser::Serialize for DeviceSession {
3675    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3676    where
3677        S: serde::ser::Serializer,
3678    {
3679        use serde::ser::SerializeMap;
3680        #[allow(unused_imports)]
3681        use std::option::Option::Some;
3682        let mut state = serializer.serialize_map(std::option::Option::None)?;
3683        if !self.name.is_empty() {
3684            state.serialize_entry("name", &self.name)?;
3685        }
3686        if !self.display_name.is_empty() {
3687            state.serialize_entry("displayName", &self.display_name)?;
3688        }
3689        if !wkt::internal::is_default(&self.state) {
3690            state.serialize_entry("state", &self.state)?;
3691        }
3692        if !self.state_histories.is_empty() {
3693            state.serialize_entry("stateHistories", &self.state_histories)?;
3694        }
3695        if let Some(value) = self.ttl() {
3696            state.serialize_entry("ttl", value)?;
3697        }
3698        if let Some(value) = self.expire_time() {
3699            state.serialize_entry("expireTime", value)?;
3700        }
3701        if self.inactivity_timeout.is_some() {
3702            state.serialize_entry("inactivityTimeout", &self.inactivity_timeout)?;
3703        }
3704        if self.create_time.is_some() {
3705            state.serialize_entry("createTime", &self.create_time)?;
3706        }
3707        if self.active_start_time.is_some() {
3708            state.serialize_entry("activeStartTime", &self.active_start_time)?;
3709        }
3710        if self.android_device.is_some() {
3711            state.serialize_entry("androidDevice", &self.android_device)?;
3712        }
3713        if !self._unknown_fields.is_empty() {
3714            for (key, value) in self._unknown_fields.iter() {
3715                state.serialize_entry(key, &value)?;
3716            }
3717        }
3718        state.end()
3719    }
3720}
3721
3722impl std::fmt::Debug for DeviceSession {
3723    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3724        let mut debug_struct = f.debug_struct("DeviceSession");
3725        debug_struct.field("name", &self.name);
3726        debug_struct.field("display_name", &self.display_name);
3727        debug_struct.field("state", &self.state);
3728        debug_struct.field("state_histories", &self.state_histories);
3729        debug_struct.field("inactivity_timeout", &self.inactivity_timeout);
3730        debug_struct.field("create_time", &self.create_time);
3731        debug_struct.field("active_start_time", &self.active_start_time);
3732        debug_struct.field("android_device", &self.android_device);
3733        debug_struct.field("expiration", &self.expiration);
3734        if !self._unknown_fields.is_empty() {
3735            debug_struct.field("_unknown_fields", &self._unknown_fields);
3736        }
3737        debug_struct.finish()
3738    }
3739}
3740
3741/// Defines additional types related to [DeviceSession].
3742pub mod device_session {
3743    #[allow(unused_imports)]
3744    use super::*;
3745
3746    /// A message encapsulating a series of Session states and the time that the
3747    /// DeviceSession first entered those states.
3748    #[derive(Clone, Default, PartialEq)]
3749    #[non_exhaustive]
3750    pub struct SessionStateEvent {
3751        /// Output only. The session_state tracked by this event
3752        pub session_state: crate::model::device_session::SessionState,
3753
3754        /// Output only. The time that the session_state first encountered that
3755        /// state.
3756        pub event_time: std::option::Option<wkt::Timestamp>,
3757
3758        /// Output only. A human-readable message to explain the state.
3759        pub state_message: std::string::String,
3760
3761        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3762    }
3763
3764    impl SessionStateEvent {
3765        pub fn new() -> Self {
3766            std::default::Default::default()
3767        }
3768
3769        /// Sets the value of [session_state][crate::model::device_session::SessionStateEvent::session_state].
3770        pub fn set_session_state<
3771            T: std::convert::Into<crate::model::device_session::SessionState>,
3772        >(
3773            mut self,
3774            v: T,
3775        ) -> Self {
3776            self.session_state = v.into();
3777            self
3778        }
3779
3780        /// Sets the value of [event_time][crate::model::device_session::SessionStateEvent::event_time].
3781        pub fn set_event_time<T>(mut self, v: T) -> Self
3782        where
3783            T: std::convert::Into<wkt::Timestamp>,
3784        {
3785            self.event_time = std::option::Option::Some(v.into());
3786            self
3787        }
3788
3789        /// Sets or clears the value of [event_time][crate::model::device_session::SessionStateEvent::event_time].
3790        pub fn set_or_clear_event_time<T>(mut self, v: std::option::Option<T>) -> Self
3791        where
3792            T: std::convert::Into<wkt::Timestamp>,
3793        {
3794            self.event_time = v.map(|x| x.into());
3795            self
3796        }
3797
3798        /// Sets the value of [state_message][crate::model::device_session::SessionStateEvent::state_message].
3799        pub fn set_state_message<T: std::convert::Into<std::string::String>>(
3800            mut self,
3801            v: T,
3802        ) -> Self {
3803            self.state_message = v.into();
3804            self
3805        }
3806    }
3807
3808    impl wkt::message::Message for SessionStateEvent {
3809        fn typename() -> &'static str {
3810            "type.googleapis.com/google.cloud.devicestreaming.v1.DeviceSession.SessionStateEvent"
3811        }
3812    }
3813
3814    #[doc(hidden)]
3815    impl<'de> serde::de::Deserialize<'de> for SessionStateEvent {
3816        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3817        where
3818            D: serde::Deserializer<'de>,
3819        {
3820            #[allow(non_camel_case_types)]
3821            #[doc(hidden)]
3822            #[derive(PartialEq, Eq, Hash)]
3823            enum __FieldTag {
3824                __session_state,
3825                __event_time,
3826                __state_message,
3827                Unknown(std::string::String),
3828            }
3829            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
3830                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3831                where
3832                    D: serde::Deserializer<'de>,
3833                {
3834                    struct Visitor;
3835                    impl<'de> serde::de::Visitor<'de> for Visitor {
3836                        type Value = __FieldTag;
3837                        fn expecting(
3838                            &self,
3839                            formatter: &mut std::fmt::Formatter,
3840                        ) -> std::fmt::Result {
3841                            formatter.write_str("a field name for SessionStateEvent")
3842                        }
3843                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
3844                        where
3845                            E: serde::de::Error,
3846                        {
3847                            use std::result::Result::Ok;
3848                            use std::string::ToString;
3849                            match value {
3850                                "sessionState" => Ok(__FieldTag::__session_state),
3851                                "session_state" => Ok(__FieldTag::__session_state),
3852                                "eventTime" => Ok(__FieldTag::__event_time),
3853                                "event_time" => Ok(__FieldTag::__event_time),
3854                                "stateMessage" => Ok(__FieldTag::__state_message),
3855                                "state_message" => Ok(__FieldTag::__state_message),
3856                                _ => Ok(__FieldTag::Unknown(value.to_string())),
3857                            }
3858                        }
3859                    }
3860                    deserializer.deserialize_identifier(Visitor)
3861                }
3862            }
3863            struct Visitor;
3864            impl<'de> serde::de::Visitor<'de> for Visitor {
3865                type Value = SessionStateEvent;
3866                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3867                    formatter.write_str("struct SessionStateEvent")
3868                }
3869                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
3870                where
3871                    A: serde::de::MapAccess<'de>,
3872                {
3873                    #[allow(unused_imports)]
3874                    use serde::de::Error;
3875                    use std::option::Option::Some;
3876                    let mut fields = std::collections::HashSet::new();
3877                    let mut result = Self::Value::new();
3878                    while let Some(tag) = map.next_key::<__FieldTag>()? {
3879                        #[allow(clippy::match_single_binding)]
3880                        match tag {
3881                            __FieldTag::__session_state => {
3882                                if !fields.insert(__FieldTag::__session_state) {
3883                                    return std::result::Result::Err(A::Error::duplicate_field(
3884                                        "multiple values for session_state",
3885                                    ));
3886                                }
3887                                result.session_state =
3888                                    map.next_value::<std::option::Option<
3889                                        crate::model::device_session::SessionState,
3890                                    >>()?
3891                                    .unwrap_or_default();
3892                            }
3893                            __FieldTag::__event_time => {
3894                                if !fields.insert(__FieldTag::__event_time) {
3895                                    return std::result::Result::Err(A::Error::duplicate_field(
3896                                        "multiple values for event_time",
3897                                    ));
3898                                }
3899                                result.event_time =
3900                                    map.next_value::<std::option::Option<wkt::Timestamp>>()?;
3901                            }
3902                            __FieldTag::__state_message => {
3903                                if !fields.insert(__FieldTag::__state_message) {
3904                                    return std::result::Result::Err(A::Error::duplicate_field(
3905                                        "multiple values for state_message",
3906                                    ));
3907                                }
3908                                result.state_message = map
3909                                    .next_value::<std::option::Option<std::string::String>>()?
3910                                    .unwrap_or_default();
3911                            }
3912                            __FieldTag::Unknown(key) => {
3913                                let value = map.next_value::<serde_json::Value>()?;
3914                                result._unknown_fields.insert(key, value);
3915                            }
3916                        }
3917                    }
3918                    std::result::Result::Ok(result)
3919                }
3920            }
3921            deserializer.deserialize_any(Visitor)
3922        }
3923    }
3924
3925    #[doc(hidden)]
3926    impl serde::ser::Serialize for SessionStateEvent {
3927        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3928        where
3929            S: serde::ser::Serializer,
3930        {
3931            use serde::ser::SerializeMap;
3932            #[allow(unused_imports)]
3933            use std::option::Option::Some;
3934            let mut state = serializer.serialize_map(std::option::Option::None)?;
3935            if !wkt::internal::is_default(&self.session_state) {
3936                state.serialize_entry("sessionState", &self.session_state)?;
3937            }
3938            if self.event_time.is_some() {
3939                state.serialize_entry("eventTime", &self.event_time)?;
3940            }
3941            if !self.state_message.is_empty() {
3942                state.serialize_entry("stateMessage", &self.state_message)?;
3943            }
3944            if !self._unknown_fields.is_empty() {
3945                for (key, value) in self._unknown_fields.iter() {
3946                    state.serialize_entry(key, &value)?;
3947                }
3948            }
3949            state.end()
3950        }
3951    }
3952
3953    impl std::fmt::Debug for SessionStateEvent {
3954        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3955            let mut debug_struct = f.debug_struct("SessionStateEvent");
3956            debug_struct.field("session_state", &self.session_state);
3957            debug_struct.field("event_time", &self.event_time);
3958            debug_struct.field("state_message", &self.state_message);
3959            if !self._unknown_fields.is_empty() {
3960                debug_struct.field("_unknown_fields", &self._unknown_fields);
3961            }
3962            debug_struct.finish()
3963        }
3964    }
3965
3966    /// The state that the DeviceSession resides.
3967    ///
3968    /// # Working with unknown values
3969    ///
3970    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
3971    /// additional enum variants at any time. Adding new variants is not considered
3972    /// a breaking change. Applications should write their code in anticipation of:
3973    ///
3974    /// - New values appearing in future releases of the client library, **and**
3975    /// - New values received dynamically, without application changes.
3976    ///
3977    /// Please consult the [Working with enums] section in the user guide for some
3978    /// guidelines.
3979    ///
3980    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
3981    #[derive(Clone, Debug, PartialEq)]
3982    #[non_exhaustive]
3983    pub enum SessionState {
3984        /// Default value. This value is unused.
3985        Unspecified,
3986        /// Initial state of a session request. The session is being validated for
3987        /// correctness and a device is not yet requested.
3988        Requested,
3989        /// The session has been validated and is in the queue for a device.
3990        Pending,
3991        /// The session has been granted and the device is accepting
3992        /// connections.
3993        Active,
3994        /// The session duration exceeded the device's reservation time period and
3995        /// timed out automatically.
3996        Expired,
3997        /// The user is finished with the session and it was canceled by the user
3998        /// while the request was still getting allocated or after allocation and
3999        /// during device usage period.
4000        Finished,
4001        /// Unable to complete the session because the device was unavailable and
4002        /// it failed to allocate through the scheduler. For example, a device not
4003        /// in the catalog was requested or the request expired in the allocation
4004        /// queue.
4005        Unavailable,
4006        /// Unable to complete the session for an internal reason, such as an
4007        /// infrastructure failure.
4008        Error,
4009        /// If set, the enum was initialized with an unknown value.
4010        ///
4011        /// Applications can examine the value using [SessionState::value] or
4012        /// [SessionState::name].
4013        UnknownValue(session_state::UnknownValue),
4014    }
4015
4016    #[doc(hidden)]
4017    pub mod session_state {
4018        #[allow(unused_imports)]
4019        use super::*;
4020        #[derive(Clone, Debug, PartialEq)]
4021        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
4022    }
4023
4024    impl SessionState {
4025        /// Gets the enum value.
4026        ///
4027        /// Returns `None` if the enum contains an unknown value deserialized from
4028        /// the string representation of enums.
4029        pub fn value(&self) -> std::option::Option<i32> {
4030            match self {
4031                Self::Unspecified => std::option::Option::Some(0),
4032                Self::Requested => std::option::Option::Some(1),
4033                Self::Pending => std::option::Option::Some(2),
4034                Self::Active => std::option::Option::Some(3),
4035                Self::Expired => std::option::Option::Some(4),
4036                Self::Finished => std::option::Option::Some(5),
4037                Self::Unavailable => std::option::Option::Some(6),
4038                Self::Error => std::option::Option::Some(7),
4039                Self::UnknownValue(u) => u.0.value(),
4040            }
4041        }
4042
4043        /// Gets the enum value as a string.
4044        ///
4045        /// Returns `None` if the enum contains an unknown value deserialized from
4046        /// the integer representation of enums.
4047        pub fn name(&self) -> std::option::Option<&str> {
4048            match self {
4049                Self::Unspecified => std::option::Option::Some("SESSION_STATE_UNSPECIFIED"),
4050                Self::Requested => std::option::Option::Some("REQUESTED"),
4051                Self::Pending => std::option::Option::Some("PENDING"),
4052                Self::Active => std::option::Option::Some("ACTIVE"),
4053                Self::Expired => std::option::Option::Some("EXPIRED"),
4054                Self::Finished => std::option::Option::Some("FINISHED"),
4055                Self::Unavailable => std::option::Option::Some("UNAVAILABLE"),
4056                Self::Error => std::option::Option::Some("ERROR"),
4057                Self::UnknownValue(u) => u.0.name(),
4058            }
4059        }
4060    }
4061
4062    impl std::default::Default for SessionState {
4063        fn default() -> Self {
4064            use std::convert::From;
4065            Self::from(0)
4066        }
4067    }
4068
4069    impl std::fmt::Display for SessionState {
4070        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
4071            wkt::internal::display_enum(f, self.name(), self.value())
4072        }
4073    }
4074
4075    impl std::convert::From<i32> for SessionState {
4076        fn from(value: i32) -> Self {
4077            match value {
4078                0 => Self::Unspecified,
4079                1 => Self::Requested,
4080                2 => Self::Pending,
4081                3 => Self::Active,
4082                4 => Self::Expired,
4083                5 => Self::Finished,
4084                6 => Self::Unavailable,
4085                7 => Self::Error,
4086                _ => Self::UnknownValue(session_state::UnknownValue(
4087                    wkt::internal::UnknownEnumValue::Integer(value),
4088                )),
4089            }
4090        }
4091    }
4092
4093    impl std::convert::From<&str> for SessionState {
4094        fn from(value: &str) -> Self {
4095            use std::string::ToString;
4096            match value {
4097                "SESSION_STATE_UNSPECIFIED" => Self::Unspecified,
4098                "REQUESTED" => Self::Requested,
4099                "PENDING" => Self::Pending,
4100                "ACTIVE" => Self::Active,
4101                "EXPIRED" => Self::Expired,
4102                "FINISHED" => Self::Finished,
4103                "UNAVAILABLE" => Self::Unavailable,
4104                "ERROR" => Self::Error,
4105                _ => Self::UnknownValue(session_state::UnknownValue(
4106                    wkt::internal::UnknownEnumValue::String(value.to_string()),
4107                )),
4108            }
4109        }
4110    }
4111
4112    impl serde::ser::Serialize for SessionState {
4113        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4114        where
4115            S: serde::Serializer,
4116        {
4117            match self {
4118                Self::Unspecified => serializer.serialize_i32(0),
4119                Self::Requested => serializer.serialize_i32(1),
4120                Self::Pending => serializer.serialize_i32(2),
4121                Self::Active => serializer.serialize_i32(3),
4122                Self::Expired => serializer.serialize_i32(4),
4123                Self::Finished => serializer.serialize_i32(5),
4124                Self::Unavailable => serializer.serialize_i32(6),
4125                Self::Error => serializer.serialize_i32(7),
4126                Self::UnknownValue(u) => u.0.serialize(serializer),
4127            }
4128        }
4129    }
4130
4131    impl<'de> serde::de::Deserialize<'de> for SessionState {
4132        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4133        where
4134            D: serde::Deserializer<'de>,
4135        {
4136            deserializer.deserialize_any(wkt::internal::EnumVisitor::<SessionState>::new(
4137                ".google.cloud.devicestreaming.v1.DeviceSession.SessionState",
4138            ))
4139        }
4140    }
4141
4142    /// The amount of time that a device will be initially allocated for.
4143    #[derive(Clone, Debug, PartialEq)]
4144    #[non_exhaustive]
4145    pub enum Expiration {
4146        /// Optional. The amount of time that a device will be initially allocated
4147        /// for. This can eventually be extended with the UpdateDeviceSession RPC.
4148        /// Default: 15 minutes.
4149        Ttl(std::boxed::Box<wkt::Duration>),
4150        /// Optional. If the device is still in use at this time, any connections
4151        /// will be ended and the SessionState will transition from ACTIVE to
4152        /// FINISHED.
4153        ExpireTime(std::boxed::Box<wkt::Timestamp>),
4154    }
4155}
4156
4157/// A single Android device.
4158#[derive(Clone, Default, PartialEq)]
4159#[non_exhaustive]
4160pub struct AndroidDevice {
4161    /// Required. The id of the Android device to be used.
4162    /// Use the TestEnvironmentDiscoveryService to get supported options.
4163    pub android_model_id: std::string::String,
4164
4165    /// Required. The id of the Android OS version to be used.
4166    /// Use the TestEnvironmentDiscoveryService to get supported options.
4167    pub android_version_id: std::string::String,
4168
4169    /// Optional. The locale the test device used for testing.
4170    /// Use the TestEnvironmentDiscoveryService to get supported options.
4171    pub locale: std::string::String,
4172
4173    /// Optional. How the device is oriented during the test.
4174    /// Use the TestEnvironmentDiscoveryService to get supported options.
4175    pub orientation: std::string::String,
4176
4177    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4178}
4179
4180impl AndroidDevice {
4181    pub fn new() -> Self {
4182        std::default::Default::default()
4183    }
4184
4185    /// Sets the value of [android_model_id][crate::model::AndroidDevice::android_model_id].
4186    pub fn set_android_model_id<T: std::convert::Into<std::string::String>>(
4187        mut self,
4188        v: T,
4189    ) -> Self {
4190        self.android_model_id = v.into();
4191        self
4192    }
4193
4194    /// Sets the value of [android_version_id][crate::model::AndroidDevice::android_version_id].
4195    pub fn set_android_version_id<T: std::convert::Into<std::string::String>>(
4196        mut self,
4197        v: T,
4198    ) -> Self {
4199        self.android_version_id = v.into();
4200        self
4201    }
4202
4203    /// Sets the value of [locale][crate::model::AndroidDevice::locale].
4204    pub fn set_locale<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4205        self.locale = v.into();
4206        self
4207    }
4208
4209    /// Sets the value of [orientation][crate::model::AndroidDevice::orientation].
4210    pub fn set_orientation<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4211        self.orientation = v.into();
4212        self
4213    }
4214}
4215
4216impl wkt::message::Message for AndroidDevice {
4217    fn typename() -> &'static str {
4218        "type.googleapis.com/google.cloud.devicestreaming.v1.AndroidDevice"
4219    }
4220}
4221
4222#[doc(hidden)]
4223impl<'de> serde::de::Deserialize<'de> for AndroidDevice {
4224    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4225    where
4226        D: serde::Deserializer<'de>,
4227    {
4228        #[allow(non_camel_case_types)]
4229        #[doc(hidden)]
4230        #[derive(PartialEq, Eq, Hash)]
4231        enum __FieldTag {
4232            __android_model_id,
4233            __android_version_id,
4234            __locale,
4235            __orientation,
4236            Unknown(std::string::String),
4237        }
4238        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
4239            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4240            where
4241                D: serde::Deserializer<'de>,
4242            {
4243                struct Visitor;
4244                impl<'de> serde::de::Visitor<'de> for Visitor {
4245                    type Value = __FieldTag;
4246                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4247                        formatter.write_str("a field name for AndroidDevice")
4248                    }
4249                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
4250                    where
4251                        E: serde::de::Error,
4252                    {
4253                        use std::result::Result::Ok;
4254                        use std::string::ToString;
4255                        match value {
4256                            "androidModelId" => Ok(__FieldTag::__android_model_id),
4257                            "android_model_id" => Ok(__FieldTag::__android_model_id),
4258                            "androidVersionId" => Ok(__FieldTag::__android_version_id),
4259                            "android_version_id" => Ok(__FieldTag::__android_version_id),
4260                            "locale" => Ok(__FieldTag::__locale),
4261                            "orientation" => Ok(__FieldTag::__orientation),
4262                            _ => Ok(__FieldTag::Unknown(value.to_string())),
4263                        }
4264                    }
4265                }
4266                deserializer.deserialize_identifier(Visitor)
4267            }
4268        }
4269        struct Visitor;
4270        impl<'de> serde::de::Visitor<'de> for Visitor {
4271            type Value = AndroidDevice;
4272            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4273                formatter.write_str("struct AndroidDevice")
4274            }
4275            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
4276            where
4277                A: serde::de::MapAccess<'de>,
4278            {
4279                #[allow(unused_imports)]
4280                use serde::de::Error;
4281                use std::option::Option::Some;
4282                let mut fields = std::collections::HashSet::new();
4283                let mut result = Self::Value::new();
4284                while let Some(tag) = map.next_key::<__FieldTag>()? {
4285                    #[allow(clippy::match_single_binding)]
4286                    match tag {
4287                        __FieldTag::__android_model_id => {
4288                            if !fields.insert(__FieldTag::__android_model_id) {
4289                                return std::result::Result::Err(A::Error::duplicate_field(
4290                                    "multiple values for android_model_id",
4291                                ));
4292                            }
4293                            result.android_model_id = map
4294                                .next_value::<std::option::Option<std::string::String>>()?
4295                                .unwrap_or_default();
4296                        }
4297                        __FieldTag::__android_version_id => {
4298                            if !fields.insert(__FieldTag::__android_version_id) {
4299                                return std::result::Result::Err(A::Error::duplicate_field(
4300                                    "multiple values for android_version_id",
4301                                ));
4302                            }
4303                            result.android_version_id = map
4304                                .next_value::<std::option::Option<std::string::String>>()?
4305                                .unwrap_or_default();
4306                        }
4307                        __FieldTag::__locale => {
4308                            if !fields.insert(__FieldTag::__locale) {
4309                                return std::result::Result::Err(A::Error::duplicate_field(
4310                                    "multiple values for locale",
4311                                ));
4312                            }
4313                            result.locale = map
4314                                .next_value::<std::option::Option<std::string::String>>()?
4315                                .unwrap_or_default();
4316                        }
4317                        __FieldTag::__orientation => {
4318                            if !fields.insert(__FieldTag::__orientation) {
4319                                return std::result::Result::Err(A::Error::duplicate_field(
4320                                    "multiple values for orientation",
4321                                ));
4322                            }
4323                            result.orientation = map
4324                                .next_value::<std::option::Option<std::string::String>>()?
4325                                .unwrap_or_default();
4326                        }
4327                        __FieldTag::Unknown(key) => {
4328                            let value = map.next_value::<serde_json::Value>()?;
4329                            result._unknown_fields.insert(key, value);
4330                        }
4331                    }
4332                }
4333                std::result::Result::Ok(result)
4334            }
4335        }
4336        deserializer.deserialize_any(Visitor)
4337    }
4338}
4339
4340#[doc(hidden)]
4341impl serde::ser::Serialize for AndroidDevice {
4342    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4343    where
4344        S: serde::ser::Serializer,
4345    {
4346        use serde::ser::SerializeMap;
4347        #[allow(unused_imports)]
4348        use std::option::Option::Some;
4349        let mut state = serializer.serialize_map(std::option::Option::None)?;
4350        if !self.android_model_id.is_empty() {
4351            state.serialize_entry("androidModelId", &self.android_model_id)?;
4352        }
4353        if !self.android_version_id.is_empty() {
4354            state.serialize_entry("androidVersionId", &self.android_version_id)?;
4355        }
4356        if !self.locale.is_empty() {
4357            state.serialize_entry("locale", &self.locale)?;
4358        }
4359        if !self.orientation.is_empty() {
4360            state.serialize_entry("orientation", &self.orientation)?;
4361        }
4362        if !self._unknown_fields.is_empty() {
4363            for (key, value) in self._unknown_fields.iter() {
4364                state.serialize_entry(key, &value)?;
4365            }
4366        }
4367        state.end()
4368    }
4369}
4370
4371impl std::fmt::Debug for AndroidDevice {
4372    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4373        let mut debug_struct = f.debug_struct("AndroidDevice");
4374        debug_struct.field("android_model_id", &self.android_model_id);
4375        debug_struct.field("android_version_id", &self.android_version_id);
4376        debug_struct.field("locale", &self.locale);
4377        debug_struct.field("orientation", &self.orientation);
4378        if !self._unknown_fields.is_empty() {
4379            debug_struct.field("_unknown_fields", &self._unknown_fields);
4380        }
4381        debug_struct.finish()
4382    }
4383}