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