fidl_fuchsia_hardware_pty/
fidl_fuchsia_hardware_pty.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_hardware_pty__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct DeviceOpenClientRequest {
16    pub id: u32,
17    pub client: fidl::endpoints::ServerEnd<DeviceMarker>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DeviceOpenClientRequest {}
21
22#[derive(Debug, Default, PartialEq)]
23pub struct DeviceDescribeResponse {
24    /// An optional event which transmits information about a device's state.
25    ///
26    /// The [`DeviceSignal`] values may be observed on this event.
27    pub event: Option<fidl::EventPair>,
28    #[doc(hidden)]
29    pub __source_breaking: fidl::marker::SourceBreaking,
30}
31
32impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DeviceDescribeResponse {}
33
34#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
35pub struct DeviceMarker;
36
37impl fidl::endpoints::ProtocolMarker for DeviceMarker {
38    type Proxy = DeviceProxy;
39    type RequestStream = DeviceRequestStream;
40    #[cfg(target_os = "fuchsia")]
41    type SynchronousProxy = DeviceSynchronousProxy;
42
43    const DEBUG_NAME: &'static str = "fuchsia.hardware.pty.Device";
44}
45impl fidl::endpoints::DiscoverableProtocolMarker for DeviceMarker {}
46
47pub trait DeviceProxyInterface: Send + Sync {
48    fn r#clone(
49        &self,
50        request: fidl::endpoints::ServerEnd<fidl_fuchsia_unknown::CloneableMarker>,
51    ) -> Result<(), fidl::Error>;
52    type CloseResponseFut: std::future::Future<
53            Output = Result<fidl_fuchsia_unknown::CloseableCloseResult, fidl::Error>,
54        > + Send;
55    fn r#close(&self) -> Self::CloseResponseFut;
56    type QueryResponseFut: std::future::Future<Output = Result<Vec<u8>, fidl::Error>> + Send;
57    fn r#query(&self) -> Self::QueryResponseFut;
58    type ReadResponseFut: std::future::Future<Output = Result<fidl_fuchsia_io::ReadableReadResult, fidl::Error>>
59        + Send;
60    fn r#read(&self, count: u64) -> Self::ReadResponseFut;
61    type WriteResponseFut: std::future::Future<Output = Result<fidl_fuchsia_io::WritableWriteResult, fidl::Error>>
62        + Send;
63    fn r#write(&self, data: &[u8]) -> Self::WriteResponseFut;
64    type DescribeResponseFut: std::future::Future<Output = Result<DeviceDescribeResponse, fidl::Error>>
65        + Send;
66    fn r#describe(&self) -> Self::DescribeResponseFut;
67    type OpenClientResponseFut: std::future::Future<Output = Result<i32, fidl::Error>> + Send;
68    fn r#open_client(
69        &self,
70        id: u32,
71        client: fidl::endpoints::ServerEnd<DeviceMarker>,
72    ) -> Self::OpenClientResponseFut;
73    type ClrSetFeatureResponseFut: std::future::Future<Output = Result<(i32, u32), fidl::Error>>
74        + Send;
75    fn r#clr_set_feature(&self, clr: u32, set: u32) -> Self::ClrSetFeatureResponseFut;
76    type GetWindowSizeResponseFut: std::future::Future<Output = Result<(i32, WindowSize), fidl::Error>>
77        + Send;
78    fn r#get_window_size(&self) -> Self::GetWindowSizeResponseFut;
79    type MakeActiveResponseFut: std::future::Future<Output = Result<i32, fidl::Error>> + Send;
80    fn r#make_active(&self, client_pty_id: u32) -> Self::MakeActiveResponseFut;
81    type ReadEventsResponseFut: std::future::Future<Output = Result<(i32, u32), fidl::Error>> + Send;
82    fn r#read_events(&self) -> Self::ReadEventsResponseFut;
83    type SetWindowSizeResponseFut: std::future::Future<Output = Result<i32, fidl::Error>> + Send;
84    fn r#set_window_size(&self, size: &WindowSize) -> Self::SetWindowSizeResponseFut;
85}
86#[derive(Debug)]
87#[cfg(target_os = "fuchsia")]
88pub struct DeviceSynchronousProxy {
89    client: fidl::client::sync::Client,
90}
91
92#[cfg(target_os = "fuchsia")]
93impl fidl::endpoints::SynchronousProxy for DeviceSynchronousProxy {
94    type Proxy = DeviceProxy;
95    type Protocol = DeviceMarker;
96
97    fn from_channel(inner: fidl::Channel) -> Self {
98        Self::new(inner)
99    }
100
101    fn into_channel(self) -> fidl::Channel {
102        self.client.into_channel()
103    }
104
105    fn as_channel(&self) -> &fidl::Channel {
106        self.client.as_channel()
107    }
108}
109
110#[cfg(target_os = "fuchsia")]
111impl DeviceSynchronousProxy {
112    pub fn new(channel: fidl::Channel) -> Self {
113        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
114        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
115    }
116
117    pub fn into_channel(self) -> fidl::Channel {
118        self.client.into_channel()
119    }
120
121    /// Waits until an event arrives and returns it. It is safe for other
122    /// threads to make concurrent requests while waiting for an event.
123    pub fn wait_for_event(
124        &self,
125        deadline: zx::MonotonicInstant,
126    ) -> Result<DeviceEvent, fidl::Error> {
127        DeviceEvent::decode(self.client.wait_for_event(deadline)?)
128    }
129
130    pub fn r#clone(
131        &self,
132        mut request: fidl::endpoints::ServerEnd<fidl_fuchsia_unknown::CloneableMarker>,
133    ) -> Result<(), fidl::Error> {
134        self.client.send::<fidl_fuchsia_unknown::CloneableCloneRequest>(
135            (request,),
136            0x20d8a7aba2168a79,
137            fidl::encoding::DynamicFlags::empty(),
138        )
139    }
140
141    /// Terminates the connection.
142    ///
143    /// After calling `Close`, the client must not send any other requests.
144    ///
145    /// Servers, after sending the status response, should close the connection
146    /// regardless of status and without sending an epitaph.
147    ///
148    /// Closing the client end of the channel should be semantically equivalent
149    /// to calling `Close` without knowing when the close has completed or its
150    /// status.
151    pub fn r#close(
152        &self,
153        ___deadline: zx::MonotonicInstant,
154    ) -> Result<fidl_fuchsia_unknown::CloseableCloseResult, fidl::Error> {
155        let _response = self.client.send_query::<
156            fidl::encoding::EmptyPayload,
157            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
158        >(
159            (),
160            0x5ac5d459ad7f657e,
161            fidl::encoding::DynamicFlags::empty(),
162            ___deadline,
163        )?;
164        Ok(_response.map(|x| x))
165    }
166
167    pub fn r#query(&self, ___deadline: zx::MonotonicInstant) -> Result<Vec<u8>, fidl::Error> {
168        let _response = self.client.send_query::<
169            fidl::encoding::EmptyPayload,
170            fidl_fuchsia_unknown::QueryableQueryResponse,
171        >(
172            (),
173            0x2658edee9decfc06,
174            fidl::encoding::DynamicFlags::empty(),
175            ___deadline,
176        )?;
177        Ok(_response.protocol)
178    }
179
180    /// Reads up to 'count' bytes at the seek offset.
181    /// The seek offset is moved forward by the number of bytes read.
182    ///
183    /// ## Invariants
184    ///
185    /// * The returned `data.length` will never be greater than `count`.
186    /// * If `data.length` is less than `count`, it means that the seek offset
187    ///   has reached the end of file as part of this operation.
188    /// * If `data.length` is zero while `count` is not, it means that the
189    ///   seek offset is already at or beyond the end of file, and no data could
190    ///   be read.
191    /// * If `count` is zero, the server should perform all the checks ensuring
192    ///   read access without actually read anything, and return an empty
193    ///   `data` vector.
194    ///
195    /// This method requires the [`Rights.READ_BYTES`] right.
196    ///
197    /// Returns `ZX_ERR_OUT_OF_RANGE` if `count` is greater than `MAX_TRANSFER_SIZE`.
198    pub fn r#read(
199        &self,
200        mut count: u64,
201        ___deadline: zx::MonotonicInstant,
202    ) -> Result<fidl_fuchsia_io::ReadableReadResult, fidl::Error> {
203        let _response = self.client.send_query::<
204            fidl_fuchsia_io::ReadableReadRequest,
205            fidl::encoding::ResultType<fidl_fuchsia_io::ReadableReadResponse, i32>,
206        >(
207            (count,),
208            0x57e419a298c8ede,
209            fidl::encoding::DynamicFlags::empty(),
210            ___deadline,
211        )?;
212        Ok(_response.map(|x| x.data))
213    }
214
215    /// Writes data at the seek offset.
216    /// The seek offset is moved forward by the number of bytes written.
217    /// If the file is in append mode, the seek offset is first set to the end
218    /// of the file, followed by the write, in one atomic step.
219    ///
220    /// The file size may grow if the seek offset plus `data.length` is beyond
221    /// the current end of file.
222    ///
223    /// + request `data` the byte buffer to write to the file.
224    /// - response `actual_count` the number of bytes written.
225    ///
226    /// ## Invariants
227    ///
228    /// * The returned `actual_count` will never be greater than `data.length`.
229    /// * If the server is unable to write all the data due to e.g. not enough
230    ///   space, `actual_count` may be less than `data.length`.  If no bytes
231    ///   could be written, an error is returned.
232    /// * If `data.length` is zero, the server should perform all the checks
233    ///   ensuring write access without mutating the file and return a
234    ///   successful write of zero bytes.  The seek offset is still updated if
235    ///   in append mode.
236    ///
237    /// This method requires the [`Rights.WRITE_BYTES`] right.
238    pub fn r#write(
239        &self,
240        mut data: &[u8],
241        ___deadline: zx::MonotonicInstant,
242    ) -> Result<fidl_fuchsia_io::WritableWriteResult, fidl::Error> {
243        let _response = self.client.send_query::<
244            fidl_fuchsia_io::WritableWriteRequest,
245            fidl::encoding::ResultType<fidl_fuchsia_io::WritableWriteResponse, i32>,
246        >(
247            (data,),
248            0x6a31437832469f82,
249            fidl::encoding::DynamicFlags::empty(),
250            ___deadline,
251        )?;
252        Ok(_response.map(|x| x.actual_count))
253    }
254
255    pub fn r#describe(
256        &self,
257        ___deadline: zx::MonotonicInstant,
258    ) -> Result<DeviceDescribeResponse, fidl::Error> {
259        let _response =
260            self.client.send_query::<fidl::encoding::EmptyPayload, DeviceDescribeResponse>(
261                (),
262                0x585d4b390fe996f5,
263                fidl::encoding::DynamicFlags::empty(),
264                ___deadline,
265            )?;
266        Ok(_response)
267    }
268
269    /// Open a client PTY device with a unique `id`. `client` should be a handle
270    /// to one endpoint of a channel that (on success) will become an open
271    /// connection to the newly created device. On failure, the channel will be
272    /// closed. Closing the channel will close the connection and release the
273    /// device. If the provided `id` is 0, then the new client is a controlling
274    /// client and has the capability to open additional clients. If the
275    /// current device is not a controlling client, `ZX_ERR_ACCESS_DENIED` will be
276    /// returned. If `id` is not unique, `ZX_ERR_INVALID_ARGS` will be returned.
277    /// Otherwise the status code from `device_add` is passed on.
278    pub fn r#open_client(
279        &self,
280        mut id: u32,
281        mut client: fidl::endpoints::ServerEnd<DeviceMarker>,
282        ___deadline: zx::MonotonicInstant,
283    ) -> Result<i32, fidl::Error> {
284        let _response =
285            self.client.send_query::<DeviceOpenClientRequest, DeviceOpenClientResponse>(
286                (id, client),
287                0x78f040fe6a1ebb3,
288                fidl::encoding::DynamicFlags::empty(),
289                ___deadline,
290            )?;
291        Ok(_response.s)
292    }
293
294    /// allowed on Client PTYs
295    /// -----------------------------
296    /// Clear and/or Set PTY Features
297    pub fn r#clr_set_feature(
298        &self,
299        mut clr: u32,
300        mut set: u32,
301        ___deadline: zx::MonotonicInstant,
302    ) -> Result<(i32, u32), fidl::Error> {
303        let _response =
304            self.client.send_query::<DeviceClrSetFeatureRequest, DeviceClrSetFeatureResponse>(
305                (clr, set),
306                0x6367986e6053a15e,
307                fidl::encoding::DynamicFlags::empty(),
308                ___deadline,
309            )?;
310        Ok((_response.status, _response.features))
311    }
312
313    /// Obtain the window size (in character cells)
314    pub fn r#get_window_size(
315        &self,
316        ___deadline: zx::MonotonicInstant,
317    ) -> Result<(i32, WindowSize), fidl::Error> {
318        let _response =
319            self.client.send_query::<fidl::encoding::EmptyPayload, DeviceGetWindowSizeResponse>(
320                (),
321                0x747bed0460f5f9f7,
322                fidl::encoding::DynamicFlags::empty(),
323                ___deadline,
324            )?;
325        Ok((_response.status, _response.size))
326    }
327
328    /// allowed on the Controlling PTY
329    /// -------------------------------------
330    /// Select which Client PTY receives input.
331    /// Reads will simply block on non-active PTYs.
332    pub fn r#make_active(
333        &self,
334        mut client_pty_id: u32,
335        ___deadline: zx::MonotonicInstant,
336    ) -> Result<i32, fidl::Error> {
337        let _response =
338            self.client.send_query::<DeviceMakeActiveRequest, DeviceMakeActiveResponse>(
339                (client_pty_id,),
340                0x2763944f30ee2a62,
341                fidl::encoding::DynamicFlags::empty(),
342                ___deadline,
343            )?;
344        Ok(_response.status)
345    }
346
347    /// Returns pending OOB events, simultaneously clearing them
348    pub fn r#read_events(
349        &self,
350        ___deadline: zx::MonotonicInstant,
351    ) -> Result<(i32, u32), fidl::Error> {
352        let _response =
353            self.client.send_query::<fidl::encoding::EmptyPayload, DeviceReadEventsResponse>(
354                (),
355                0xede96f3e3258f62,
356                fidl::encoding::DynamicFlags::empty(),
357                ___deadline,
358            )?;
359        Ok((_response.status, _response.events))
360    }
361
362    /// allowed on the Server PTY
363    /// --------------------------------
364    /// Sets the window size
365    pub fn r#set_window_size(
366        &self,
367        mut size: &WindowSize,
368        ___deadline: zx::MonotonicInstant,
369    ) -> Result<i32, fidl::Error> {
370        let _response =
371            self.client.send_query::<DeviceSetWindowSizeRequest, DeviceSetWindowSizeResponse>(
372                (size,),
373                0x17d1cb37377e7928,
374                fidl::encoding::DynamicFlags::empty(),
375                ___deadline,
376            )?;
377        Ok(_response.status)
378    }
379}
380
381#[cfg(target_os = "fuchsia")]
382impl From<DeviceSynchronousProxy> for zx::Handle {
383    fn from(value: DeviceSynchronousProxy) -> Self {
384        value.into_channel().into()
385    }
386}
387
388#[cfg(target_os = "fuchsia")]
389impl From<fidl::Channel> for DeviceSynchronousProxy {
390    fn from(value: fidl::Channel) -> Self {
391        Self::new(value)
392    }
393}
394
395#[cfg(target_os = "fuchsia")]
396impl fidl::endpoints::FromClient for DeviceSynchronousProxy {
397    type Protocol = DeviceMarker;
398
399    fn from_client(value: fidl::endpoints::ClientEnd<DeviceMarker>) -> Self {
400        Self::new(value.into_channel())
401    }
402}
403
404#[derive(Debug, Clone)]
405pub struct DeviceProxy {
406    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
407}
408
409impl fidl::endpoints::Proxy for DeviceProxy {
410    type Protocol = DeviceMarker;
411
412    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
413        Self::new(inner)
414    }
415
416    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
417        self.client.into_channel().map_err(|client| Self { client })
418    }
419
420    fn as_channel(&self) -> &::fidl::AsyncChannel {
421        self.client.as_channel()
422    }
423}
424
425impl DeviceProxy {
426    /// Create a new Proxy for fuchsia.hardware.pty/Device.
427    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
428        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
429        Self { client: fidl::client::Client::new(channel, protocol_name) }
430    }
431
432    /// Get a Stream of events from the remote end of the protocol.
433    ///
434    /// # Panics
435    ///
436    /// Panics if the event stream was already taken.
437    pub fn take_event_stream(&self) -> DeviceEventStream {
438        DeviceEventStream { event_receiver: self.client.take_event_receiver() }
439    }
440
441    pub fn r#clone(
442        &self,
443        mut request: fidl::endpoints::ServerEnd<fidl_fuchsia_unknown::CloneableMarker>,
444    ) -> Result<(), fidl::Error> {
445        DeviceProxyInterface::r#clone(self, request)
446    }
447
448    /// Terminates the connection.
449    ///
450    /// After calling `Close`, the client must not send any other requests.
451    ///
452    /// Servers, after sending the status response, should close the connection
453    /// regardless of status and without sending an epitaph.
454    ///
455    /// Closing the client end of the channel should be semantically equivalent
456    /// to calling `Close` without knowing when the close has completed or its
457    /// status.
458    pub fn r#close(
459        &self,
460    ) -> fidl::client::QueryResponseFut<
461        fidl_fuchsia_unknown::CloseableCloseResult,
462        fidl::encoding::DefaultFuchsiaResourceDialect,
463    > {
464        DeviceProxyInterface::r#close(self)
465    }
466
467    pub fn r#query(
468        &self,
469    ) -> fidl::client::QueryResponseFut<Vec<u8>, fidl::encoding::DefaultFuchsiaResourceDialect>
470    {
471        DeviceProxyInterface::r#query(self)
472    }
473
474    /// Reads up to 'count' bytes at the seek offset.
475    /// The seek offset is moved forward by the number of bytes read.
476    ///
477    /// ## Invariants
478    ///
479    /// * The returned `data.length` will never be greater than `count`.
480    /// * If `data.length` is less than `count`, it means that the seek offset
481    ///   has reached the end of file as part of this operation.
482    /// * If `data.length` is zero while `count` is not, it means that the
483    ///   seek offset is already at or beyond the end of file, and no data could
484    ///   be read.
485    /// * If `count` is zero, the server should perform all the checks ensuring
486    ///   read access without actually read anything, and return an empty
487    ///   `data` vector.
488    ///
489    /// This method requires the [`Rights.READ_BYTES`] right.
490    ///
491    /// Returns `ZX_ERR_OUT_OF_RANGE` if `count` is greater than `MAX_TRANSFER_SIZE`.
492    pub fn r#read(
493        &self,
494        mut count: u64,
495    ) -> fidl::client::QueryResponseFut<
496        fidl_fuchsia_io::ReadableReadResult,
497        fidl::encoding::DefaultFuchsiaResourceDialect,
498    > {
499        DeviceProxyInterface::r#read(self, count)
500    }
501
502    /// Writes data at the seek offset.
503    /// The seek offset is moved forward by the number of bytes written.
504    /// If the file is in append mode, the seek offset is first set to the end
505    /// of the file, followed by the write, in one atomic step.
506    ///
507    /// The file size may grow if the seek offset plus `data.length` is beyond
508    /// the current end of file.
509    ///
510    /// + request `data` the byte buffer to write to the file.
511    /// - response `actual_count` the number of bytes written.
512    ///
513    /// ## Invariants
514    ///
515    /// * The returned `actual_count` will never be greater than `data.length`.
516    /// * If the server is unable to write all the data due to e.g. not enough
517    ///   space, `actual_count` may be less than `data.length`.  If no bytes
518    ///   could be written, an error is returned.
519    /// * If `data.length` is zero, the server should perform all the checks
520    ///   ensuring write access without mutating the file and return a
521    ///   successful write of zero bytes.  The seek offset is still updated if
522    ///   in append mode.
523    ///
524    /// This method requires the [`Rights.WRITE_BYTES`] right.
525    pub fn r#write(
526        &self,
527        mut data: &[u8],
528    ) -> fidl::client::QueryResponseFut<
529        fidl_fuchsia_io::WritableWriteResult,
530        fidl::encoding::DefaultFuchsiaResourceDialect,
531    > {
532        DeviceProxyInterface::r#write(self, data)
533    }
534
535    pub fn r#describe(
536        &self,
537    ) -> fidl::client::QueryResponseFut<
538        DeviceDescribeResponse,
539        fidl::encoding::DefaultFuchsiaResourceDialect,
540    > {
541        DeviceProxyInterface::r#describe(self)
542    }
543
544    /// Open a client PTY device with a unique `id`. `client` should be a handle
545    /// to one endpoint of a channel that (on success) will become an open
546    /// connection to the newly created device. On failure, the channel will be
547    /// closed. Closing the channel will close the connection and release the
548    /// device. If the provided `id` is 0, then the new client is a controlling
549    /// client and has the capability to open additional clients. If the
550    /// current device is not a controlling client, `ZX_ERR_ACCESS_DENIED` will be
551    /// returned. If `id` is not unique, `ZX_ERR_INVALID_ARGS` will be returned.
552    /// Otherwise the status code from `device_add` is passed on.
553    pub fn r#open_client(
554        &self,
555        mut id: u32,
556        mut client: fidl::endpoints::ServerEnd<DeviceMarker>,
557    ) -> fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect> {
558        DeviceProxyInterface::r#open_client(self, id, client)
559    }
560
561    /// allowed on Client PTYs
562    /// -----------------------------
563    /// Clear and/or Set PTY Features
564    pub fn r#clr_set_feature(
565        &self,
566        mut clr: u32,
567        mut set: u32,
568    ) -> fidl::client::QueryResponseFut<(i32, u32), fidl::encoding::DefaultFuchsiaResourceDialect>
569    {
570        DeviceProxyInterface::r#clr_set_feature(self, clr, set)
571    }
572
573    /// Obtain the window size (in character cells)
574    pub fn r#get_window_size(
575        &self,
576    ) -> fidl::client::QueryResponseFut<
577        (i32, WindowSize),
578        fidl::encoding::DefaultFuchsiaResourceDialect,
579    > {
580        DeviceProxyInterface::r#get_window_size(self)
581    }
582
583    /// allowed on the Controlling PTY
584    /// -------------------------------------
585    /// Select which Client PTY receives input.
586    /// Reads will simply block on non-active PTYs.
587    pub fn r#make_active(
588        &self,
589        mut client_pty_id: u32,
590    ) -> fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect> {
591        DeviceProxyInterface::r#make_active(self, client_pty_id)
592    }
593
594    /// Returns pending OOB events, simultaneously clearing them
595    pub fn r#read_events(
596        &self,
597    ) -> fidl::client::QueryResponseFut<(i32, u32), fidl::encoding::DefaultFuchsiaResourceDialect>
598    {
599        DeviceProxyInterface::r#read_events(self)
600    }
601
602    /// allowed on the Server PTY
603    /// --------------------------------
604    /// Sets the window size
605    pub fn r#set_window_size(
606        &self,
607        mut size: &WindowSize,
608    ) -> fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect> {
609        DeviceProxyInterface::r#set_window_size(self, size)
610    }
611}
612
613impl DeviceProxyInterface for DeviceProxy {
614    fn r#clone(
615        &self,
616        mut request: fidl::endpoints::ServerEnd<fidl_fuchsia_unknown::CloneableMarker>,
617    ) -> Result<(), fidl::Error> {
618        self.client.send::<fidl_fuchsia_unknown::CloneableCloneRequest>(
619            (request,),
620            0x20d8a7aba2168a79,
621            fidl::encoding::DynamicFlags::empty(),
622        )
623    }
624
625    type CloseResponseFut = fidl::client::QueryResponseFut<
626        fidl_fuchsia_unknown::CloseableCloseResult,
627        fidl::encoding::DefaultFuchsiaResourceDialect,
628    >;
629    fn r#close(&self) -> Self::CloseResponseFut {
630        fn _decode(
631            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
632        ) -> Result<fidl_fuchsia_unknown::CloseableCloseResult, fidl::Error> {
633            let _response = fidl::client::decode_transaction_body::<
634                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
635                fidl::encoding::DefaultFuchsiaResourceDialect,
636                0x5ac5d459ad7f657e,
637            >(_buf?)?;
638            Ok(_response.map(|x| x))
639        }
640        self.client.send_query_and_decode::<
641            fidl::encoding::EmptyPayload,
642            fidl_fuchsia_unknown::CloseableCloseResult,
643        >(
644            (),
645            0x5ac5d459ad7f657e,
646            fidl::encoding::DynamicFlags::empty(),
647            _decode,
648        )
649    }
650
651    type QueryResponseFut =
652        fidl::client::QueryResponseFut<Vec<u8>, fidl::encoding::DefaultFuchsiaResourceDialect>;
653    fn r#query(&self) -> Self::QueryResponseFut {
654        fn _decode(
655            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
656        ) -> Result<Vec<u8>, fidl::Error> {
657            let _response = fidl::client::decode_transaction_body::<
658                fidl_fuchsia_unknown::QueryableQueryResponse,
659                fidl::encoding::DefaultFuchsiaResourceDialect,
660                0x2658edee9decfc06,
661            >(_buf?)?;
662            Ok(_response.protocol)
663        }
664        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<u8>>(
665            (),
666            0x2658edee9decfc06,
667            fidl::encoding::DynamicFlags::empty(),
668            _decode,
669        )
670    }
671
672    type ReadResponseFut = fidl::client::QueryResponseFut<
673        fidl_fuchsia_io::ReadableReadResult,
674        fidl::encoding::DefaultFuchsiaResourceDialect,
675    >;
676    fn r#read(&self, mut count: u64) -> Self::ReadResponseFut {
677        fn _decode(
678            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
679        ) -> Result<fidl_fuchsia_io::ReadableReadResult, fidl::Error> {
680            let _response = fidl::client::decode_transaction_body::<
681                fidl::encoding::ResultType<fidl_fuchsia_io::ReadableReadResponse, i32>,
682                fidl::encoding::DefaultFuchsiaResourceDialect,
683                0x57e419a298c8ede,
684            >(_buf?)?;
685            Ok(_response.map(|x| x.data))
686        }
687        self.client.send_query_and_decode::<
688            fidl_fuchsia_io::ReadableReadRequest,
689            fidl_fuchsia_io::ReadableReadResult,
690        >(
691            (count,),
692            0x57e419a298c8ede,
693            fidl::encoding::DynamicFlags::empty(),
694            _decode,
695        )
696    }
697
698    type WriteResponseFut = fidl::client::QueryResponseFut<
699        fidl_fuchsia_io::WritableWriteResult,
700        fidl::encoding::DefaultFuchsiaResourceDialect,
701    >;
702    fn r#write(&self, mut data: &[u8]) -> Self::WriteResponseFut {
703        fn _decode(
704            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
705        ) -> Result<fidl_fuchsia_io::WritableWriteResult, fidl::Error> {
706            let _response = fidl::client::decode_transaction_body::<
707                fidl::encoding::ResultType<fidl_fuchsia_io::WritableWriteResponse, i32>,
708                fidl::encoding::DefaultFuchsiaResourceDialect,
709                0x6a31437832469f82,
710            >(_buf?)?;
711            Ok(_response.map(|x| x.actual_count))
712        }
713        self.client.send_query_and_decode::<
714            fidl_fuchsia_io::WritableWriteRequest,
715            fidl_fuchsia_io::WritableWriteResult,
716        >(
717            (data,),
718            0x6a31437832469f82,
719            fidl::encoding::DynamicFlags::empty(),
720            _decode,
721        )
722    }
723
724    type DescribeResponseFut = fidl::client::QueryResponseFut<
725        DeviceDescribeResponse,
726        fidl::encoding::DefaultFuchsiaResourceDialect,
727    >;
728    fn r#describe(&self) -> Self::DescribeResponseFut {
729        fn _decode(
730            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
731        ) -> Result<DeviceDescribeResponse, fidl::Error> {
732            let _response = fidl::client::decode_transaction_body::<
733                DeviceDescribeResponse,
734                fidl::encoding::DefaultFuchsiaResourceDialect,
735                0x585d4b390fe996f5,
736            >(_buf?)?;
737            Ok(_response)
738        }
739        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, DeviceDescribeResponse>(
740            (),
741            0x585d4b390fe996f5,
742            fidl::encoding::DynamicFlags::empty(),
743            _decode,
744        )
745    }
746
747    type OpenClientResponseFut =
748        fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect>;
749    fn r#open_client(
750        &self,
751        mut id: u32,
752        mut client: fidl::endpoints::ServerEnd<DeviceMarker>,
753    ) -> Self::OpenClientResponseFut {
754        fn _decode(
755            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
756        ) -> Result<i32, fidl::Error> {
757            let _response = fidl::client::decode_transaction_body::<
758                DeviceOpenClientResponse,
759                fidl::encoding::DefaultFuchsiaResourceDialect,
760                0x78f040fe6a1ebb3,
761            >(_buf?)?;
762            Ok(_response.s)
763        }
764        self.client.send_query_and_decode::<DeviceOpenClientRequest, i32>(
765            (id, client),
766            0x78f040fe6a1ebb3,
767            fidl::encoding::DynamicFlags::empty(),
768            _decode,
769        )
770    }
771
772    type ClrSetFeatureResponseFut =
773        fidl::client::QueryResponseFut<(i32, u32), fidl::encoding::DefaultFuchsiaResourceDialect>;
774    fn r#clr_set_feature(&self, mut clr: u32, mut set: u32) -> Self::ClrSetFeatureResponseFut {
775        fn _decode(
776            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
777        ) -> Result<(i32, u32), fidl::Error> {
778            let _response = fidl::client::decode_transaction_body::<
779                DeviceClrSetFeatureResponse,
780                fidl::encoding::DefaultFuchsiaResourceDialect,
781                0x6367986e6053a15e,
782            >(_buf?)?;
783            Ok((_response.status, _response.features))
784        }
785        self.client.send_query_and_decode::<DeviceClrSetFeatureRequest, (i32, u32)>(
786            (clr, set),
787            0x6367986e6053a15e,
788            fidl::encoding::DynamicFlags::empty(),
789            _decode,
790        )
791    }
792
793    type GetWindowSizeResponseFut = fidl::client::QueryResponseFut<
794        (i32, WindowSize),
795        fidl::encoding::DefaultFuchsiaResourceDialect,
796    >;
797    fn r#get_window_size(&self) -> Self::GetWindowSizeResponseFut {
798        fn _decode(
799            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
800        ) -> Result<(i32, WindowSize), fidl::Error> {
801            let _response = fidl::client::decode_transaction_body::<
802                DeviceGetWindowSizeResponse,
803                fidl::encoding::DefaultFuchsiaResourceDialect,
804                0x747bed0460f5f9f7,
805            >(_buf?)?;
806            Ok((_response.status, _response.size))
807        }
808        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, (i32, WindowSize)>(
809            (),
810            0x747bed0460f5f9f7,
811            fidl::encoding::DynamicFlags::empty(),
812            _decode,
813        )
814    }
815
816    type MakeActiveResponseFut =
817        fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect>;
818    fn r#make_active(&self, mut client_pty_id: u32) -> Self::MakeActiveResponseFut {
819        fn _decode(
820            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
821        ) -> Result<i32, fidl::Error> {
822            let _response = fidl::client::decode_transaction_body::<
823                DeviceMakeActiveResponse,
824                fidl::encoding::DefaultFuchsiaResourceDialect,
825                0x2763944f30ee2a62,
826            >(_buf?)?;
827            Ok(_response.status)
828        }
829        self.client.send_query_and_decode::<DeviceMakeActiveRequest, i32>(
830            (client_pty_id,),
831            0x2763944f30ee2a62,
832            fidl::encoding::DynamicFlags::empty(),
833            _decode,
834        )
835    }
836
837    type ReadEventsResponseFut =
838        fidl::client::QueryResponseFut<(i32, u32), fidl::encoding::DefaultFuchsiaResourceDialect>;
839    fn r#read_events(&self) -> Self::ReadEventsResponseFut {
840        fn _decode(
841            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
842        ) -> Result<(i32, u32), fidl::Error> {
843            let _response = fidl::client::decode_transaction_body::<
844                DeviceReadEventsResponse,
845                fidl::encoding::DefaultFuchsiaResourceDialect,
846                0xede96f3e3258f62,
847            >(_buf?)?;
848            Ok((_response.status, _response.events))
849        }
850        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, (i32, u32)>(
851            (),
852            0xede96f3e3258f62,
853            fidl::encoding::DynamicFlags::empty(),
854            _decode,
855        )
856    }
857
858    type SetWindowSizeResponseFut =
859        fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect>;
860    fn r#set_window_size(&self, mut size: &WindowSize) -> Self::SetWindowSizeResponseFut {
861        fn _decode(
862            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
863        ) -> Result<i32, fidl::Error> {
864            let _response = fidl::client::decode_transaction_body::<
865                DeviceSetWindowSizeResponse,
866                fidl::encoding::DefaultFuchsiaResourceDialect,
867                0x17d1cb37377e7928,
868            >(_buf?)?;
869            Ok(_response.status)
870        }
871        self.client.send_query_and_decode::<DeviceSetWindowSizeRequest, i32>(
872            (size,),
873            0x17d1cb37377e7928,
874            fidl::encoding::DynamicFlags::empty(),
875            _decode,
876        )
877    }
878}
879
880pub struct DeviceEventStream {
881    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
882}
883
884impl std::marker::Unpin for DeviceEventStream {}
885
886impl futures::stream::FusedStream for DeviceEventStream {
887    fn is_terminated(&self) -> bool {
888        self.event_receiver.is_terminated()
889    }
890}
891
892impl futures::Stream for DeviceEventStream {
893    type Item = Result<DeviceEvent, fidl::Error>;
894
895    fn poll_next(
896        mut self: std::pin::Pin<&mut Self>,
897        cx: &mut std::task::Context<'_>,
898    ) -> std::task::Poll<Option<Self::Item>> {
899        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
900            &mut self.event_receiver,
901            cx
902        )?) {
903            Some(buf) => std::task::Poll::Ready(Some(DeviceEvent::decode(buf))),
904            None => std::task::Poll::Ready(None),
905        }
906    }
907}
908
909#[derive(Debug)]
910pub enum DeviceEvent {}
911
912impl DeviceEvent {
913    /// Decodes a message buffer as a [`DeviceEvent`].
914    fn decode(
915        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
916    ) -> Result<DeviceEvent, fidl::Error> {
917        let (bytes, _handles) = buf.split_mut();
918        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
919        debug_assert_eq!(tx_header.tx_id, 0);
920        match tx_header.ordinal {
921            _ => Err(fidl::Error::UnknownOrdinal {
922                ordinal: tx_header.ordinal,
923                protocol_name: <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
924            }),
925        }
926    }
927}
928
929/// A Stream of incoming requests for fuchsia.hardware.pty/Device.
930pub struct DeviceRequestStream {
931    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
932    is_terminated: bool,
933}
934
935impl std::marker::Unpin for DeviceRequestStream {}
936
937impl futures::stream::FusedStream for DeviceRequestStream {
938    fn is_terminated(&self) -> bool {
939        self.is_terminated
940    }
941}
942
943impl fidl::endpoints::RequestStream for DeviceRequestStream {
944    type Protocol = DeviceMarker;
945    type ControlHandle = DeviceControlHandle;
946
947    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
948        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
949    }
950
951    fn control_handle(&self) -> Self::ControlHandle {
952        DeviceControlHandle { inner: self.inner.clone() }
953    }
954
955    fn into_inner(
956        self,
957    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
958    {
959        (self.inner, self.is_terminated)
960    }
961
962    fn from_inner(
963        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
964        is_terminated: bool,
965    ) -> Self {
966        Self { inner, is_terminated }
967    }
968}
969
970impl futures::Stream for DeviceRequestStream {
971    type Item = Result<DeviceRequest, fidl::Error>;
972
973    fn poll_next(
974        mut self: std::pin::Pin<&mut Self>,
975        cx: &mut std::task::Context<'_>,
976    ) -> std::task::Poll<Option<Self::Item>> {
977        let this = &mut *self;
978        if this.inner.check_shutdown(cx) {
979            this.is_terminated = true;
980            return std::task::Poll::Ready(None);
981        }
982        if this.is_terminated {
983            panic!("polled DeviceRequestStream after completion");
984        }
985        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
986            |bytes, handles| {
987                match this.inner.channel().read_etc(cx, bytes, handles) {
988                    std::task::Poll::Ready(Ok(())) => {}
989                    std::task::Poll::Pending => return std::task::Poll::Pending,
990                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
991                        this.is_terminated = true;
992                        return std::task::Poll::Ready(None);
993                    }
994                    std::task::Poll::Ready(Err(e)) => {
995                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
996                            e.into(),
997                        ))))
998                    }
999                }
1000
1001                // A message has been received from the channel
1002                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1003
1004                std::task::Poll::Ready(Some(match header.ordinal {
1005                    0x20d8a7aba2168a79 => {
1006                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1007                        let mut req = fidl::new_empty!(
1008                            fidl_fuchsia_unknown::CloneableCloneRequest,
1009                            fidl::encoding::DefaultFuchsiaResourceDialect
1010                        );
1011                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl_fuchsia_unknown::CloneableCloneRequest>(&header, _body_bytes, handles, &mut req)?;
1012                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1013                        Ok(DeviceRequest::Clone { request: req.request, control_handle })
1014                    }
1015                    0x5ac5d459ad7f657e => {
1016                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1017                        let mut req = fidl::new_empty!(
1018                            fidl::encoding::EmptyPayload,
1019                            fidl::encoding::DefaultFuchsiaResourceDialect
1020                        );
1021                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1022                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1023                        Ok(DeviceRequest::Close {
1024                            responder: DeviceCloseResponder {
1025                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1026                                tx_id: header.tx_id,
1027                            },
1028                        })
1029                    }
1030                    0x2658edee9decfc06 => {
1031                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1032                        let mut req = fidl::new_empty!(
1033                            fidl::encoding::EmptyPayload,
1034                            fidl::encoding::DefaultFuchsiaResourceDialect
1035                        );
1036                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1037                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1038                        Ok(DeviceRequest::Query {
1039                            responder: DeviceQueryResponder {
1040                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1041                                tx_id: header.tx_id,
1042                            },
1043                        })
1044                    }
1045                    0x57e419a298c8ede => {
1046                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1047                        let mut req = fidl::new_empty!(
1048                            fidl_fuchsia_io::ReadableReadRequest,
1049                            fidl::encoding::DefaultFuchsiaResourceDialect
1050                        );
1051                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl_fuchsia_io::ReadableReadRequest>(&header, _body_bytes, handles, &mut req)?;
1052                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1053                        Ok(DeviceRequest::Read {
1054                            count: req.count,
1055
1056                            responder: DeviceReadResponder {
1057                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1058                                tx_id: header.tx_id,
1059                            },
1060                        })
1061                    }
1062                    0x6a31437832469f82 => {
1063                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1064                        let mut req = fidl::new_empty!(
1065                            fidl_fuchsia_io::WritableWriteRequest,
1066                            fidl::encoding::DefaultFuchsiaResourceDialect
1067                        );
1068                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl_fuchsia_io::WritableWriteRequest>(&header, _body_bytes, handles, &mut req)?;
1069                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1070                        Ok(DeviceRequest::Write {
1071                            data: req.data,
1072
1073                            responder: DeviceWriteResponder {
1074                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1075                                tx_id: header.tx_id,
1076                            },
1077                        })
1078                    }
1079                    0x585d4b390fe996f5 => {
1080                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1081                        let mut req = fidl::new_empty!(
1082                            fidl::encoding::EmptyPayload,
1083                            fidl::encoding::DefaultFuchsiaResourceDialect
1084                        );
1085                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1086                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1087                        Ok(DeviceRequest::Describe {
1088                            responder: DeviceDescribeResponder {
1089                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1090                                tx_id: header.tx_id,
1091                            },
1092                        })
1093                    }
1094                    0x78f040fe6a1ebb3 => {
1095                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1096                        let mut req = fidl::new_empty!(
1097                            DeviceOpenClientRequest,
1098                            fidl::encoding::DefaultFuchsiaResourceDialect
1099                        );
1100                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceOpenClientRequest>(&header, _body_bytes, handles, &mut req)?;
1101                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1102                        Ok(DeviceRequest::OpenClient {
1103                            id: req.id,
1104                            client: req.client,
1105
1106                            responder: DeviceOpenClientResponder {
1107                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1108                                tx_id: header.tx_id,
1109                            },
1110                        })
1111                    }
1112                    0x6367986e6053a15e => {
1113                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1114                        let mut req = fidl::new_empty!(
1115                            DeviceClrSetFeatureRequest,
1116                            fidl::encoding::DefaultFuchsiaResourceDialect
1117                        );
1118                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceClrSetFeatureRequest>(&header, _body_bytes, handles, &mut req)?;
1119                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1120                        Ok(DeviceRequest::ClrSetFeature {
1121                            clr: req.clr,
1122                            set: req.set,
1123
1124                            responder: DeviceClrSetFeatureResponder {
1125                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1126                                tx_id: header.tx_id,
1127                            },
1128                        })
1129                    }
1130                    0x747bed0460f5f9f7 => {
1131                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1132                        let mut req = fidl::new_empty!(
1133                            fidl::encoding::EmptyPayload,
1134                            fidl::encoding::DefaultFuchsiaResourceDialect
1135                        );
1136                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1137                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1138                        Ok(DeviceRequest::GetWindowSize {
1139                            responder: DeviceGetWindowSizeResponder {
1140                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1141                                tx_id: header.tx_id,
1142                            },
1143                        })
1144                    }
1145                    0x2763944f30ee2a62 => {
1146                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1147                        let mut req = fidl::new_empty!(
1148                            DeviceMakeActiveRequest,
1149                            fidl::encoding::DefaultFuchsiaResourceDialect
1150                        );
1151                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceMakeActiveRequest>(&header, _body_bytes, handles, &mut req)?;
1152                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1153                        Ok(DeviceRequest::MakeActive {
1154                            client_pty_id: req.client_pty_id,
1155
1156                            responder: DeviceMakeActiveResponder {
1157                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1158                                tx_id: header.tx_id,
1159                            },
1160                        })
1161                    }
1162                    0xede96f3e3258f62 => {
1163                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1164                        let mut req = fidl::new_empty!(
1165                            fidl::encoding::EmptyPayload,
1166                            fidl::encoding::DefaultFuchsiaResourceDialect
1167                        );
1168                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1169                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1170                        Ok(DeviceRequest::ReadEvents {
1171                            responder: DeviceReadEventsResponder {
1172                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1173                                tx_id: header.tx_id,
1174                            },
1175                        })
1176                    }
1177                    0x17d1cb37377e7928 => {
1178                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1179                        let mut req = fidl::new_empty!(
1180                            DeviceSetWindowSizeRequest,
1181                            fidl::encoding::DefaultFuchsiaResourceDialect
1182                        );
1183                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceSetWindowSizeRequest>(&header, _body_bytes, handles, &mut req)?;
1184                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1185                        Ok(DeviceRequest::SetWindowSize {
1186                            size: req.size,
1187
1188                            responder: DeviceSetWindowSizeResponder {
1189                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1190                                tx_id: header.tx_id,
1191                            },
1192                        })
1193                    }
1194                    _ => Err(fidl::Error::UnknownOrdinal {
1195                        ordinal: header.ordinal,
1196                        protocol_name:
1197                            <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1198                    }),
1199                }))
1200            },
1201        )
1202    }
1203}
1204
1205#[derive(Debug)]
1206pub enum DeviceRequest {
1207    Clone {
1208        request: fidl::endpoints::ServerEnd<fidl_fuchsia_unknown::CloneableMarker>,
1209        control_handle: DeviceControlHandle,
1210    },
1211    /// Terminates the connection.
1212    ///
1213    /// After calling `Close`, the client must not send any other requests.
1214    ///
1215    /// Servers, after sending the status response, should close the connection
1216    /// regardless of status and without sending an epitaph.
1217    ///
1218    /// Closing the client end of the channel should be semantically equivalent
1219    /// to calling `Close` without knowing when the close has completed or its
1220    /// status.
1221    Close {
1222        responder: DeviceCloseResponder,
1223    },
1224    Query {
1225        responder: DeviceQueryResponder,
1226    },
1227    /// Reads up to 'count' bytes at the seek offset.
1228    /// The seek offset is moved forward by the number of bytes read.
1229    ///
1230    /// ## Invariants
1231    ///
1232    /// * The returned `data.length` will never be greater than `count`.
1233    /// * If `data.length` is less than `count`, it means that the seek offset
1234    ///   has reached the end of file as part of this operation.
1235    /// * If `data.length` is zero while `count` is not, it means that the
1236    ///   seek offset is already at or beyond the end of file, and no data could
1237    ///   be read.
1238    /// * If `count` is zero, the server should perform all the checks ensuring
1239    ///   read access without actually read anything, and return an empty
1240    ///   `data` vector.
1241    ///
1242    /// This method requires the [`Rights.READ_BYTES`] right.
1243    ///
1244    /// Returns `ZX_ERR_OUT_OF_RANGE` if `count` is greater than `MAX_TRANSFER_SIZE`.
1245    Read {
1246        count: u64,
1247        responder: DeviceReadResponder,
1248    },
1249    /// Writes data at the seek offset.
1250    /// The seek offset is moved forward by the number of bytes written.
1251    /// If the file is in append mode, the seek offset is first set to the end
1252    /// of the file, followed by the write, in one atomic step.
1253    ///
1254    /// The file size may grow if the seek offset plus `data.length` is beyond
1255    /// the current end of file.
1256    ///
1257    /// + request `data` the byte buffer to write to the file.
1258    /// - response `actual_count` the number of bytes written.
1259    ///
1260    /// ## Invariants
1261    ///
1262    /// * The returned `actual_count` will never be greater than `data.length`.
1263    /// * If the server is unable to write all the data due to e.g. not enough
1264    ///   space, `actual_count` may be less than `data.length`.  If no bytes
1265    ///   could be written, an error is returned.
1266    /// * If `data.length` is zero, the server should perform all the checks
1267    ///   ensuring write access without mutating the file and return a
1268    ///   successful write of zero bytes.  The seek offset is still updated if
1269    ///   in append mode.
1270    ///
1271    /// This method requires the [`Rights.WRITE_BYTES`] right.
1272    Write {
1273        data: Vec<u8>,
1274        responder: DeviceWriteResponder,
1275    },
1276    Describe {
1277        responder: DeviceDescribeResponder,
1278    },
1279    /// Open a client PTY device with a unique `id`. `client` should be a handle
1280    /// to one endpoint of a channel that (on success) will become an open
1281    /// connection to the newly created device. On failure, the channel will be
1282    /// closed. Closing the channel will close the connection and release the
1283    /// device. If the provided `id` is 0, then the new client is a controlling
1284    /// client and has the capability to open additional clients. If the
1285    /// current device is not a controlling client, `ZX_ERR_ACCESS_DENIED` will be
1286    /// returned. If `id` is not unique, `ZX_ERR_INVALID_ARGS` will be returned.
1287    /// Otherwise the status code from `device_add` is passed on.
1288    OpenClient {
1289        id: u32,
1290        client: fidl::endpoints::ServerEnd<DeviceMarker>,
1291        responder: DeviceOpenClientResponder,
1292    },
1293    /// allowed on Client PTYs
1294    /// -----------------------------
1295    /// Clear and/or Set PTY Features
1296    ClrSetFeature {
1297        clr: u32,
1298        set: u32,
1299        responder: DeviceClrSetFeatureResponder,
1300    },
1301    /// Obtain the window size (in character cells)
1302    GetWindowSize {
1303        responder: DeviceGetWindowSizeResponder,
1304    },
1305    /// allowed on the Controlling PTY
1306    /// -------------------------------------
1307    /// Select which Client PTY receives input.
1308    /// Reads will simply block on non-active PTYs.
1309    MakeActive {
1310        client_pty_id: u32,
1311        responder: DeviceMakeActiveResponder,
1312    },
1313    /// Returns pending OOB events, simultaneously clearing them
1314    ReadEvents {
1315        responder: DeviceReadEventsResponder,
1316    },
1317    /// allowed on the Server PTY
1318    /// --------------------------------
1319    /// Sets the window size
1320    SetWindowSize {
1321        size: WindowSize,
1322        responder: DeviceSetWindowSizeResponder,
1323    },
1324}
1325
1326impl DeviceRequest {
1327    #[allow(irrefutable_let_patterns)]
1328    pub fn into_clone(
1329        self,
1330    ) -> Option<(
1331        fidl::endpoints::ServerEnd<fidl_fuchsia_unknown::CloneableMarker>,
1332        DeviceControlHandle,
1333    )> {
1334        if let DeviceRequest::Clone { request, control_handle } = self {
1335            Some((request, control_handle))
1336        } else {
1337            None
1338        }
1339    }
1340
1341    #[allow(irrefutable_let_patterns)]
1342    pub fn into_close(self) -> Option<(DeviceCloseResponder)> {
1343        if let DeviceRequest::Close { responder } = self {
1344            Some((responder))
1345        } else {
1346            None
1347        }
1348    }
1349
1350    #[allow(irrefutable_let_patterns)]
1351    pub fn into_query(self) -> Option<(DeviceQueryResponder)> {
1352        if let DeviceRequest::Query { responder } = self {
1353            Some((responder))
1354        } else {
1355            None
1356        }
1357    }
1358
1359    #[allow(irrefutable_let_patterns)]
1360    pub fn into_read(self) -> Option<(u64, DeviceReadResponder)> {
1361        if let DeviceRequest::Read { count, responder } = self {
1362            Some((count, responder))
1363        } else {
1364            None
1365        }
1366    }
1367
1368    #[allow(irrefutable_let_patterns)]
1369    pub fn into_write(self) -> Option<(Vec<u8>, DeviceWriteResponder)> {
1370        if let DeviceRequest::Write { data, responder } = self {
1371            Some((data, responder))
1372        } else {
1373            None
1374        }
1375    }
1376
1377    #[allow(irrefutable_let_patterns)]
1378    pub fn into_describe(self) -> Option<(DeviceDescribeResponder)> {
1379        if let DeviceRequest::Describe { responder } = self {
1380            Some((responder))
1381        } else {
1382            None
1383        }
1384    }
1385
1386    #[allow(irrefutable_let_patterns)]
1387    pub fn into_open_client(
1388        self,
1389    ) -> Option<(u32, fidl::endpoints::ServerEnd<DeviceMarker>, DeviceOpenClientResponder)> {
1390        if let DeviceRequest::OpenClient { id, client, responder } = self {
1391            Some((id, client, responder))
1392        } else {
1393            None
1394        }
1395    }
1396
1397    #[allow(irrefutable_let_patterns)]
1398    pub fn into_clr_set_feature(self) -> Option<(u32, u32, DeviceClrSetFeatureResponder)> {
1399        if let DeviceRequest::ClrSetFeature { clr, set, responder } = self {
1400            Some((clr, set, responder))
1401        } else {
1402            None
1403        }
1404    }
1405
1406    #[allow(irrefutable_let_patterns)]
1407    pub fn into_get_window_size(self) -> Option<(DeviceGetWindowSizeResponder)> {
1408        if let DeviceRequest::GetWindowSize { responder } = self {
1409            Some((responder))
1410        } else {
1411            None
1412        }
1413    }
1414
1415    #[allow(irrefutable_let_patterns)]
1416    pub fn into_make_active(self) -> Option<(u32, DeviceMakeActiveResponder)> {
1417        if let DeviceRequest::MakeActive { client_pty_id, responder } = self {
1418            Some((client_pty_id, responder))
1419        } else {
1420            None
1421        }
1422    }
1423
1424    #[allow(irrefutable_let_patterns)]
1425    pub fn into_read_events(self) -> Option<(DeviceReadEventsResponder)> {
1426        if let DeviceRequest::ReadEvents { responder } = self {
1427            Some((responder))
1428        } else {
1429            None
1430        }
1431    }
1432
1433    #[allow(irrefutable_let_patterns)]
1434    pub fn into_set_window_size(self) -> Option<(WindowSize, DeviceSetWindowSizeResponder)> {
1435        if let DeviceRequest::SetWindowSize { size, responder } = self {
1436            Some((size, responder))
1437        } else {
1438            None
1439        }
1440    }
1441
1442    /// Name of the method defined in FIDL
1443    pub fn method_name(&self) -> &'static str {
1444        match *self {
1445            DeviceRequest::Clone { .. } => "clone",
1446            DeviceRequest::Close { .. } => "close",
1447            DeviceRequest::Query { .. } => "query",
1448            DeviceRequest::Read { .. } => "read",
1449            DeviceRequest::Write { .. } => "write",
1450            DeviceRequest::Describe { .. } => "describe",
1451            DeviceRequest::OpenClient { .. } => "open_client",
1452            DeviceRequest::ClrSetFeature { .. } => "clr_set_feature",
1453            DeviceRequest::GetWindowSize { .. } => "get_window_size",
1454            DeviceRequest::MakeActive { .. } => "make_active",
1455            DeviceRequest::ReadEvents { .. } => "read_events",
1456            DeviceRequest::SetWindowSize { .. } => "set_window_size",
1457        }
1458    }
1459}
1460
1461#[derive(Debug, Clone)]
1462pub struct DeviceControlHandle {
1463    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1464}
1465
1466impl fidl::endpoints::ControlHandle for DeviceControlHandle {
1467    fn shutdown(&self) {
1468        self.inner.shutdown()
1469    }
1470    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1471        self.inner.shutdown_with_epitaph(status)
1472    }
1473
1474    fn is_closed(&self) -> bool {
1475        self.inner.channel().is_closed()
1476    }
1477    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1478        self.inner.channel().on_closed()
1479    }
1480
1481    #[cfg(target_os = "fuchsia")]
1482    fn signal_peer(
1483        &self,
1484        clear_mask: zx::Signals,
1485        set_mask: zx::Signals,
1486    ) -> Result<(), zx_status::Status> {
1487        use fidl::Peered;
1488        self.inner.channel().signal_peer(clear_mask, set_mask)
1489    }
1490}
1491
1492impl DeviceControlHandle {}
1493
1494#[must_use = "FIDL methods require a response to be sent"]
1495#[derive(Debug)]
1496pub struct DeviceCloseResponder {
1497    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1498    tx_id: u32,
1499}
1500
1501/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1502/// if the responder is dropped without sending a response, so that the client
1503/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1504impl std::ops::Drop for DeviceCloseResponder {
1505    fn drop(&mut self) {
1506        self.control_handle.shutdown();
1507        // Safety: drops once, never accessed again
1508        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1509    }
1510}
1511
1512impl fidl::endpoints::Responder for DeviceCloseResponder {
1513    type ControlHandle = DeviceControlHandle;
1514
1515    fn control_handle(&self) -> &DeviceControlHandle {
1516        &self.control_handle
1517    }
1518
1519    fn drop_without_shutdown(mut self) {
1520        // Safety: drops once, never accessed again due to mem::forget
1521        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1522        // Prevent Drop from running (which would shut down the channel)
1523        std::mem::forget(self);
1524    }
1525}
1526
1527impl DeviceCloseResponder {
1528    /// Sends a response to the FIDL transaction.
1529    ///
1530    /// Sets the channel to shutdown if an error occurs.
1531    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1532        let _result = self.send_raw(result);
1533        if _result.is_err() {
1534            self.control_handle.shutdown();
1535        }
1536        self.drop_without_shutdown();
1537        _result
1538    }
1539
1540    /// Similar to "send" but does not shutdown the channel if an error occurs.
1541    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1542        let _result = self.send_raw(result);
1543        self.drop_without_shutdown();
1544        _result
1545    }
1546
1547    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1548        self.control_handle
1549            .inner
1550            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1551                result,
1552                self.tx_id,
1553                0x5ac5d459ad7f657e,
1554                fidl::encoding::DynamicFlags::empty(),
1555            )
1556    }
1557}
1558
1559#[must_use = "FIDL methods require a response to be sent"]
1560#[derive(Debug)]
1561pub struct DeviceQueryResponder {
1562    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1563    tx_id: u32,
1564}
1565
1566/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1567/// if the responder is dropped without sending a response, so that the client
1568/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1569impl std::ops::Drop for DeviceQueryResponder {
1570    fn drop(&mut self) {
1571        self.control_handle.shutdown();
1572        // Safety: drops once, never accessed again
1573        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1574    }
1575}
1576
1577impl fidl::endpoints::Responder for DeviceQueryResponder {
1578    type ControlHandle = DeviceControlHandle;
1579
1580    fn control_handle(&self) -> &DeviceControlHandle {
1581        &self.control_handle
1582    }
1583
1584    fn drop_without_shutdown(mut self) {
1585        // Safety: drops once, never accessed again due to mem::forget
1586        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1587        // Prevent Drop from running (which would shut down the channel)
1588        std::mem::forget(self);
1589    }
1590}
1591
1592impl DeviceQueryResponder {
1593    /// Sends a response to the FIDL transaction.
1594    ///
1595    /// Sets the channel to shutdown if an error occurs.
1596    pub fn send(self, mut protocol: &[u8]) -> Result<(), fidl::Error> {
1597        let _result = self.send_raw(protocol);
1598        if _result.is_err() {
1599            self.control_handle.shutdown();
1600        }
1601        self.drop_without_shutdown();
1602        _result
1603    }
1604
1605    /// Similar to "send" but does not shutdown the channel if an error occurs.
1606    pub fn send_no_shutdown_on_err(self, mut protocol: &[u8]) -> Result<(), fidl::Error> {
1607        let _result = self.send_raw(protocol);
1608        self.drop_without_shutdown();
1609        _result
1610    }
1611
1612    fn send_raw(&self, mut protocol: &[u8]) -> Result<(), fidl::Error> {
1613        self.control_handle.inner.send::<fidl_fuchsia_unknown::QueryableQueryResponse>(
1614            (protocol,),
1615            self.tx_id,
1616            0x2658edee9decfc06,
1617            fidl::encoding::DynamicFlags::empty(),
1618        )
1619    }
1620}
1621
1622#[must_use = "FIDL methods require a response to be sent"]
1623#[derive(Debug)]
1624pub struct DeviceReadResponder {
1625    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1626    tx_id: u32,
1627}
1628
1629/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1630/// if the responder is dropped without sending a response, so that the client
1631/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1632impl std::ops::Drop for DeviceReadResponder {
1633    fn drop(&mut self) {
1634        self.control_handle.shutdown();
1635        // Safety: drops once, never accessed again
1636        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1637    }
1638}
1639
1640impl fidl::endpoints::Responder for DeviceReadResponder {
1641    type ControlHandle = DeviceControlHandle;
1642
1643    fn control_handle(&self) -> &DeviceControlHandle {
1644        &self.control_handle
1645    }
1646
1647    fn drop_without_shutdown(mut self) {
1648        // Safety: drops once, never accessed again due to mem::forget
1649        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1650        // Prevent Drop from running (which would shut down the channel)
1651        std::mem::forget(self);
1652    }
1653}
1654
1655impl DeviceReadResponder {
1656    /// Sends a response to the FIDL transaction.
1657    ///
1658    /// Sets the channel to shutdown if an error occurs.
1659    pub fn send(self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
1660        let _result = self.send_raw(result);
1661        if _result.is_err() {
1662            self.control_handle.shutdown();
1663        }
1664        self.drop_without_shutdown();
1665        _result
1666    }
1667
1668    /// Similar to "send" but does not shutdown the channel if an error occurs.
1669    pub fn send_no_shutdown_on_err(
1670        self,
1671        mut result: Result<&[u8], i32>,
1672    ) -> Result<(), fidl::Error> {
1673        let _result = self.send_raw(result);
1674        self.drop_without_shutdown();
1675        _result
1676    }
1677
1678    fn send_raw(&self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
1679        self.control_handle.inner.send::<fidl::encoding::ResultType<
1680            fidl_fuchsia_io::ReadableReadResponse,
1681            i32,
1682        >>(
1683            result.map(|data| (data,)),
1684            self.tx_id,
1685            0x57e419a298c8ede,
1686            fidl::encoding::DynamicFlags::empty(),
1687        )
1688    }
1689}
1690
1691#[must_use = "FIDL methods require a response to be sent"]
1692#[derive(Debug)]
1693pub struct DeviceWriteResponder {
1694    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1695    tx_id: u32,
1696}
1697
1698/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1699/// if the responder is dropped without sending a response, so that the client
1700/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1701impl std::ops::Drop for DeviceWriteResponder {
1702    fn drop(&mut self) {
1703        self.control_handle.shutdown();
1704        // Safety: drops once, never accessed again
1705        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1706    }
1707}
1708
1709impl fidl::endpoints::Responder for DeviceWriteResponder {
1710    type ControlHandle = DeviceControlHandle;
1711
1712    fn control_handle(&self) -> &DeviceControlHandle {
1713        &self.control_handle
1714    }
1715
1716    fn drop_without_shutdown(mut self) {
1717        // Safety: drops once, never accessed again due to mem::forget
1718        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1719        // Prevent Drop from running (which would shut down the channel)
1720        std::mem::forget(self);
1721    }
1722}
1723
1724impl DeviceWriteResponder {
1725    /// Sends a response to the FIDL transaction.
1726    ///
1727    /// Sets the channel to shutdown if an error occurs.
1728    pub fn send(self, mut result: Result<u64, i32>) -> Result<(), fidl::Error> {
1729        let _result = self.send_raw(result);
1730        if _result.is_err() {
1731            self.control_handle.shutdown();
1732        }
1733        self.drop_without_shutdown();
1734        _result
1735    }
1736
1737    /// Similar to "send" but does not shutdown the channel if an error occurs.
1738    pub fn send_no_shutdown_on_err(self, mut result: Result<u64, i32>) -> Result<(), fidl::Error> {
1739        let _result = self.send_raw(result);
1740        self.drop_without_shutdown();
1741        _result
1742    }
1743
1744    fn send_raw(&self, mut result: Result<u64, i32>) -> Result<(), fidl::Error> {
1745        self.control_handle.inner.send::<fidl::encoding::ResultType<
1746            fidl_fuchsia_io::WritableWriteResponse,
1747            i32,
1748        >>(
1749            result.map(|actual_count| (actual_count,)),
1750            self.tx_id,
1751            0x6a31437832469f82,
1752            fidl::encoding::DynamicFlags::empty(),
1753        )
1754    }
1755}
1756
1757#[must_use = "FIDL methods require a response to be sent"]
1758#[derive(Debug)]
1759pub struct DeviceDescribeResponder {
1760    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1761    tx_id: u32,
1762}
1763
1764/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1765/// if the responder is dropped without sending a response, so that the client
1766/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1767impl std::ops::Drop for DeviceDescribeResponder {
1768    fn drop(&mut self) {
1769        self.control_handle.shutdown();
1770        // Safety: drops once, never accessed again
1771        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1772    }
1773}
1774
1775impl fidl::endpoints::Responder for DeviceDescribeResponder {
1776    type ControlHandle = DeviceControlHandle;
1777
1778    fn control_handle(&self) -> &DeviceControlHandle {
1779        &self.control_handle
1780    }
1781
1782    fn drop_without_shutdown(mut self) {
1783        // Safety: drops once, never accessed again due to mem::forget
1784        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1785        // Prevent Drop from running (which would shut down the channel)
1786        std::mem::forget(self);
1787    }
1788}
1789
1790impl DeviceDescribeResponder {
1791    /// Sends a response to the FIDL transaction.
1792    ///
1793    /// Sets the channel to shutdown if an error occurs.
1794    pub fn send(self, mut payload: DeviceDescribeResponse) -> Result<(), fidl::Error> {
1795        let _result = self.send_raw(payload);
1796        if _result.is_err() {
1797            self.control_handle.shutdown();
1798        }
1799        self.drop_without_shutdown();
1800        _result
1801    }
1802
1803    /// Similar to "send" but does not shutdown the channel if an error occurs.
1804    pub fn send_no_shutdown_on_err(
1805        self,
1806        mut payload: DeviceDescribeResponse,
1807    ) -> Result<(), fidl::Error> {
1808        let _result = self.send_raw(payload);
1809        self.drop_without_shutdown();
1810        _result
1811    }
1812
1813    fn send_raw(&self, mut payload: DeviceDescribeResponse) -> Result<(), fidl::Error> {
1814        self.control_handle.inner.send::<DeviceDescribeResponse>(
1815            &mut payload,
1816            self.tx_id,
1817            0x585d4b390fe996f5,
1818            fidl::encoding::DynamicFlags::empty(),
1819        )
1820    }
1821}
1822
1823#[must_use = "FIDL methods require a response to be sent"]
1824#[derive(Debug)]
1825pub struct DeviceOpenClientResponder {
1826    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1827    tx_id: u32,
1828}
1829
1830/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1831/// if the responder is dropped without sending a response, so that the client
1832/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1833impl std::ops::Drop for DeviceOpenClientResponder {
1834    fn drop(&mut self) {
1835        self.control_handle.shutdown();
1836        // Safety: drops once, never accessed again
1837        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1838    }
1839}
1840
1841impl fidl::endpoints::Responder for DeviceOpenClientResponder {
1842    type ControlHandle = DeviceControlHandle;
1843
1844    fn control_handle(&self) -> &DeviceControlHandle {
1845        &self.control_handle
1846    }
1847
1848    fn drop_without_shutdown(mut self) {
1849        // Safety: drops once, never accessed again due to mem::forget
1850        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1851        // Prevent Drop from running (which would shut down the channel)
1852        std::mem::forget(self);
1853    }
1854}
1855
1856impl DeviceOpenClientResponder {
1857    /// Sends a response to the FIDL transaction.
1858    ///
1859    /// Sets the channel to shutdown if an error occurs.
1860    pub fn send(self, mut s: i32) -> Result<(), fidl::Error> {
1861        let _result = self.send_raw(s);
1862        if _result.is_err() {
1863            self.control_handle.shutdown();
1864        }
1865        self.drop_without_shutdown();
1866        _result
1867    }
1868
1869    /// Similar to "send" but does not shutdown the channel if an error occurs.
1870    pub fn send_no_shutdown_on_err(self, mut s: i32) -> Result<(), fidl::Error> {
1871        let _result = self.send_raw(s);
1872        self.drop_without_shutdown();
1873        _result
1874    }
1875
1876    fn send_raw(&self, mut s: i32) -> Result<(), fidl::Error> {
1877        self.control_handle.inner.send::<DeviceOpenClientResponse>(
1878            (s,),
1879            self.tx_id,
1880            0x78f040fe6a1ebb3,
1881            fidl::encoding::DynamicFlags::empty(),
1882        )
1883    }
1884}
1885
1886#[must_use = "FIDL methods require a response to be sent"]
1887#[derive(Debug)]
1888pub struct DeviceClrSetFeatureResponder {
1889    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1890    tx_id: u32,
1891}
1892
1893/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1894/// if the responder is dropped without sending a response, so that the client
1895/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1896impl std::ops::Drop for DeviceClrSetFeatureResponder {
1897    fn drop(&mut self) {
1898        self.control_handle.shutdown();
1899        // Safety: drops once, never accessed again
1900        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1901    }
1902}
1903
1904impl fidl::endpoints::Responder for DeviceClrSetFeatureResponder {
1905    type ControlHandle = DeviceControlHandle;
1906
1907    fn control_handle(&self) -> &DeviceControlHandle {
1908        &self.control_handle
1909    }
1910
1911    fn drop_without_shutdown(mut self) {
1912        // Safety: drops once, never accessed again due to mem::forget
1913        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1914        // Prevent Drop from running (which would shut down the channel)
1915        std::mem::forget(self);
1916    }
1917}
1918
1919impl DeviceClrSetFeatureResponder {
1920    /// Sends a response to the FIDL transaction.
1921    ///
1922    /// Sets the channel to shutdown if an error occurs.
1923    pub fn send(self, mut status: i32, mut features: u32) -> Result<(), fidl::Error> {
1924        let _result = self.send_raw(status, features);
1925        if _result.is_err() {
1926            self.control_handle.shutdown();
1927        }
1928        self.drop_without_shutdown();
1929        _result
1930    }
1931
1932    /// Similar to "send" but does not shutdown the channel if an error occurs.
1933    pub fn send_no_shutdown_on_err(
1934        self,
1935        mut status: i32,
1936        mut features: u32,
1937    ) -> Result<(), fidl::Error> {
1938        let _result = self.send_raw(status, features);
1939        self.drop_without_shutdown();
1940        _result
1941    }
1942
1943    fn send_raw(&self, mut status: i32, mut features: u32) -> Result<(), fidl::Error> {
1944        self.control_handle.inner.send::<DeviceClrSetFeatureResponse>(
1945            (status, features),
1946            self.tx_id,
1947            0x6367986e6053a15e,
1948            fidl::encoding::DynamicFlags::empty(),
1949        )
1950    }
1951}
1952
1953#[must_use = "FIDL methods require a response to be sent"]
1954#[derive(Debug)]
1955pub struct DeviceGetWindowSizeResponder {
1956    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1957    tx_id: u32,
1958}
1959
1960/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1961/// if the responder is dropped without sending a response, so that the client
1962/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1963impl std::ops::Drop for DeviceGetWindowSizeResponder {
1964    fn drop(&mut self) {
1965        self.control_handle.shutdown();
1966        // Safety: drops once, never accessed again
1967        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1968    }
1969}
1970
1971impl fidl::endpoints::Responder for DeviceGetWindowSizeResponder {
1972    type ControlHandle = DeviceControlHandle;
1973
1974    fn control_handle(&self) -> &DeviceControlHandle {
1975        &self.control_handle
1976    }
1977
1978    fn drop_without_shutdown(mut self) {
1979        // Safety: drops once, never accessed again due to mem::forget
1980        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1981        // Prevent Drop from running (which would shut down the channel)
1982        std::mem::forget(self);
1983    }
1984}
1985
1986impl DeviceGetWindowSizeResponder {
1987    /// Sends a response to the FIDL transaction.
1988    ///
1989    /// Sets the channel to shutdown if an error occurs.
1990    pub fn send(self, mut status: i32, mut size: &WindowSize) -> Result<(), fidl::Error> {
1991        let _result = self.send_raw(status, size);
1992        if _result.is_err() {
1993            self.control_handle.shutdown();
1994        }
1995        self.drop_without_shutdown();
1996        _result
1997    }
1998
1999    /// Similar to "send" but does not shutdown the channel if an error occurs.
2000    pub fn send_no_shutdown_on_err(
2001        self,
2002        mut status: i32,
2003        mut size: &WindowSize,
2004    ) -> Result<(), fidl::Error> {
2005        let _result = self.send_raw(status, size);
2006        self.drop_without_shutdown();
2007        _result
2008    }
2009
2010    fn send_raw(&self, mut status: i32, mut size: &WindowSize) -> Result<(), fidl::Error> {
2011        self.control_handle.inner.send::<DeviceGetWindowSizeResponse>(
2012            (status, size),
2013            self.tx_id,
2014            0x747bed0460f5f9f7,
2015            fidl::encoding::DynamicFlags::empty(),
2016        )
2017    }
2018}
2019
2020#[must_use = "FIDL methods require a response to be sent"]
2021#[derive(Debug)]
2022pub struct DeviceMakeActiveResponder {
2023    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2024    tx_id: u32,
2025}
2026
2027/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2028/// if the responder is dropped without sending a response, so that the client
2029/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2030impl std::ops::Drop for DeviceMakeActiveResponder {
2031    fn drop(&mut self) {
2032        self.control_handle.shutdown();
2033        // Safety: drops once, never accessed again
2034        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2035    }
2036}
2037
2038impl fidl::endpoints::Responder for DeviceMakeActiveResponder {
2039    type ControlHandle = DeviceControlHandle;
2040
2041    fn control_handle(&self) -> &DeviceControlHandle {
2042        &self.control_handle
2043    }
2044
2045    fn drop_without_shutdown(mut self) {
2046        // Safety: drops once, never accessed again due to mem::forget
2047        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2048        // Prevent Drop from running (which would shut down the channel)
2049        std::mem::forget(self);
2050    }
2051}
2052
2053impl DeviceMakeActiveResponder {
2054    /// Sends a response to the FIDL transaction.
2055    ///
2056    /// Sets the channel to shutdown if an error occurs.
2057    pub fn send(self, mut status: i32) -> Result<(), fidl::Error> {
2058        let _result = self.send_raw(status);
2059        if _result.is_err() {
2060            self.control_handle.shutdown();
2061        }
2062        self.drop_without_shutdown();
2063        _result
2064    }
2065
2066    /// Similar to "send" but does not shutdown the channel if an error occurs.
2067    pub fn send_no_shutdown_on_err(self, mut status: i32) -> Result<(), fidl::Error> {
2068        let _result = self.send_raw(status);
2069        self.drop_without_shutdown();
2070        _result
2071    }
2072
2073    fn send_raw(&self, mut status: i32) -> Result<(), fidl::Error> {
2074        self.control_handle.inner.send::<DeviceMakeActiveResponse>(
2075            (status,),
2076            self.tx_id,
2077            0x2763944f30ee2a62,
2078            fidl::encoding::DynamicFlags::empty(),
2079        )
2080    }
2081}
2082
2083#[must_use = "FIDL methods require a response to be sent"]
2084#[derive(Debug)]
2085pub struct DeviceReadEventsResponder {
2086    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2087    tx_id: u32,
2088}
2089
2090/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2091/// if the responder is dropped without sending a response, so that the client
2092/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2093impl std::ops::Drop for DeviceReadEventsResponder {
2094    fn drop(&mut self) {
2095        self.control_handle.shutdown();
2096        // Safety: drops once, never accessed again
2097        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2098    }
2099}
2100
2101impl fidl::endpoints::Responder for DeviceReadEventsResponder {
2102    type ControlHandle = DeviceControlHandle;
2103
2104    fn control_handle(&self) -> &DeviceControlHandle {
2105        &self.control_handle
2106    }
2107
2108    fn drop_without_shutdown(mut self) {
2109        // Safety: drops once, never accessed again due to mem::forget
2110        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2111        // Prevent Drop from running (which would shut down the channel)
2112        std::mem::forget(self);
2113    }
2114}
2115
2116impl DeviceReadEventsResponder {
2117    /// Sends a response to the FIDL transaction.
2118    ///
2119    /// Sets the channel to shutdown if an error occurs.
2120    pub fn send(self, mut status: i32, mut events: u32) -> Result<(), fidl::Error> {
2121        let _result = self.send_raw(status, events);
2122        if _result.is_err() {
2123            self.control_handle.shutdown();
2124        }
2125        self.drop_without_shutdown();
2126        _result
2127    }
2128
2129    /// Similar to "send" but does not shutdown the channel if an error occurs.
2130    pub fn send_no_shutdown_on_err(
2131        self,
2132        mut status: i32,
2133        mut events: u32,
2134    ) -> Result<(), fidl::Error> {
2135        let _result = self.send_raw(status, events);
2136        self.drop_without_shutdown();
2137        _result
2138    }
2139
2140    fn send_raw(&self, mut status: i32, mut events: u32) -> Result<(), fidl::Error> {
2141        self.control_handle.inner.send::<DeviceReadEventsResponse>(
2142            (status, events),
2143            self.tx_id,
2144            0xede96f3e3258f62,
2145            fidl::encoding::DynamicFlags::empty(),
2146        )
2147    }
2148}
2149
2150#[must_use = "FIDL methods require a response to be sent"]
2151#[derive(Debug)]
2152pub struct DeviceSetWindowSizeResponder {
2153    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2154    tx_id: u32,
2155}
2156
2157/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2158/// if the responder is dropped without sending a response, so that the client
2159/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2160impl std::ops::Drop for DeviceSetWindowSizeResponder {
2161    fn drop(&mut self) {
2162        self.control_handle.shutdown();
2163        // Safety: drops once, never accessed again
2164        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2165    }
2166}
2167
2168impl fidl::endpoints::Responder for DeviceSetWindowSizeResponder {
2169    type ControlHandle = DeviceControlHandle;
2170
2171    fn control_handle(&self) -> &DeviceControlHandle {
2172        &self.control_handle
2173    }
2174
2175    fn drop_without_shutdown(mut self) {
2176        // Safety: drops once, never accessed again due to mem::forget
2177        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2178        // Prevent Drop from running (which would shut down the channel)
2179        std::mem::forget(self);
2180    }
2181}
2182
2183impl DeviceSetWindowSizeResponder {
2184    /// Sends a response to the FIDL transaction.
2185    ///
2186    /// Sets the channel to shutdown if an error occurs.
2187    pub fn send(self, mut status: i32) -> Result<(), fidl::Error> {
2188        let _result = self.send_raw(status);
2189        if _result.is_err() {
2190            self.control_handle.shutdown();
2191        }
2192        self.drop_without_shutdown();
2193        _result
2194    }
2195
2196    /// Similar to "send" but does not shutdown the channel if an error occurs.
2197    pub fn send_no_shutdown_on_err(self, mut status: i32) -> Result<(), fidl::Error> {
2198        let _result = self.send_raw(status);
2199        self.drop_without_shutdown();
2200        _result
2201    }
2202
2203    fn send_raw(&self, mut status: i32) -> Result<(), fidl::Error> {
2204        self.control_handle.inner.send::<DeviceSetWindowSizeResponse>(
2205            (status,),
2206            self.tx_id,
2207            0x17d1cb37377e7928,
2208            fidl::encoding::DynamicFlags::empty(),
2209        )
2210    }
2211}
2212
2213#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2214pub struct ServiceMarker;
2215
2216#[cfg(target_os = "fuchsia")]
2217impl fidl::endpoints::ServiceMarker for ServiceMarker {
2218    type Proxy = ServiceProxy;
2219    type Request = ServiceRequest;
2220    const SERVICE_NAME: &'static str = "fuchsia.hardware.pty.Service";
2221}
2222
2223/// A request for one of the member protocols of Service.
2224///
2225#[cfg(target_os = "fuchsia")]
2226pub enum ServiceRequest {
2227    Device(DeviceRequestStream),
2228}
2229
2230#[cfg(target_os = "fuchsia")]
2231impl fidl::endpoints::ServiceRequest for ServiceRequest {
2232    type Service = ServiceMarker;
2233
2234    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
2235        match name {
2236            "device" => Self::Device(
2237                <DeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
2238            ),
2239            _ => panic!("no such member protocol name for service Service"),
2240        }
2241    }
2242
2243    fn member_names() -> &'static [&'static str] {
2244        &["device"]
2245    }
2246}
2247#[cfg(target_os = "fuchsia")]
2248pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
2249
2250#[cfg(target_os = "fuchsia")]
2251impl fidl::endpoints::ServiceProxy for ServiceProxy {
2252    type Service = ServiceMarker;
2253
2254    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
2255        Self(opener)
2256    }
2257}
2258
2259#[cfg(target_os = "fuchsia")]
2260impl ServiceProxy {
2261    pub fn connect_to_device(&self) -> Result<DeviceProxy, fidl::Error> {
2262        let (proxy, server_end) = fidl::endpoints::create_proxy::<DeviceMarker>();
2263        self.connect_channel_to_device(server_end)?;
2264        Ok(proxy)
2265    }
2266
2267    /// Like `connect_to_device`, but returns a sync proxy.
2268    /// See [`Self::connect_to_device`] for more details.
2269    pub fn connect_to_device_sync(&self) -> Result<DeviceSynchronousProxy, fidl::Error> {
2270        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DeviceMarker>();
2271        self.connect_channel_to_device(server_end)?;
2272        Ok(proxy)
2273    }
2274
2275    /// Like `connect_to_device`, but accepts a server end.
2276    /// See [`Self::connect_to_device`] for more details.
2277    pub fn connect_channel_to_device(
2278        &self,
2279        server_end: fidl::endpoints::ServerEnd<DeviceMarker>,
2280    ) -> Result<(), fidl::Error> {
2281        self.0.open_member("device", server_end.into_channel())
2282    }
2283
2284    pub fn instance_name(&self) -> &str {
2285        self.0.instance_name()
2286    }
2287}
2288
2289mod internal {
2290    use super::*;
2291
2292    impl fidl::encoding::ResourceTypeMarker for DeviceOpenClientRequest {
2293        type Borrowed<'a> = &'a mut Self;
2294        fn take_or_borrow<'a>(
2295            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2296        ) -> Self::Borrowed<'a> {
2297            value
2298        }
2299    }
2300
2301    unsafe impl fidl::encoding::TypeMarker for DeviceOpenClientRequest {
2302        type Owned = Self;
2303
2304        #[inline(always)]
2305        fn inline_align(_context: fidl::encoding::Context) -> usize {
2306            4
2307        }
2308
2309        #[inline(always)]
2310        fn inline_size(_context: fidl::encoding::Context) -> usize {
2311            8
2312        }
2313    }
2314
2315    unsafe impl
2316        fidl::encoding::Encode<
2317            DeviceOpenClientRequest,
2318            fidl::encoding::DefaultFuchsiaResourceDialect,
2319        > for &mut DeviceOpenClientRequest
2320    {
2321        #[inline]
2322        unsafe fn encode(
2323            self,
2324            encoder: &mut fidl::encoding::Encoder<
2325                '_,
2326                fidl::encoding::DefaultFuchsiaResourceDialect,
2327            >,
2328            offset: usize,
2329            _depth: fidl::encoding::Depth,
2330        ) -> fidl::Result<()> {
2331            encoder.debug_check_bounds::<DeviceOpenClientRequest>(offset);
2332            // Delegate to tuple encoding.
2333            fidl::encoding::Encode::<DeviceOpenClientRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2334                (
2335                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
2336                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.client),
2337                ),
2338                encoder, offset, _depth
2339            )
2340        }
2341    }
2342    unsafe impl<
2343            T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
2344            T1: fidl::encoding::Encode<
2345                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
2346                fidl::encoding::DefaultFuchsiaResourceDialect,
2347            >,
2348        >
2349        fidl::encoding::Encode<
2350            DeviceOpenClientRequest,
2351            fidl::encoding::DefaultFuchsiaResourceDialect,
2352        > for (T0, T1)
2353    {
2354        #[inline]
2355        unsafe fn encode(
2356            self,
2357            encoder: &mut fidl::encoding::Encoder<
2358                '_,
2359                fidl::encoding::DefaultFuchsiaResourceDialect,
2360            >,
2361            offset: usize,
2362            depth: fidl::encoding::Depth,
2363        ) -> fidl::Result<()> {
2364            encoder.debug_check_bounds::<DeviceOpenClientRequest>(offset);
2365            // Zero out padding regions. There's no need to apply masks
2366            // because the unmasked parts will be overwritten by fields.
2367            // Write the fields.
2368            self.0.encode(encoder, offset + 0, depth)?;
2369            self.1.encode(encoder, offset + 4, depth)?;
2370            Ok(())
2371        }
2372    }
2373
2374    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2375        for DeviceOpenClientRequest
2376    {
2377        #[inline(always)]
2378        fn new_empty() -> Self {
2379            Self {
2380                id: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
2381                client: fidl::new_empty!(
2382                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
2383                    fidl::encoding::DefaultFuchsiaResourceDialect
2384                ),
2385            }
2386        }
2387
2388        #[inline]
2389        unsafe fn decode(
2390            &mut self,
2391            decoder: &mut fidl::encoding::Decoder<
2392                '_,
2393                fidl::encoding::DefaultFuchsiaResourceDialect,
2394            >,
2395            offset: usize,
2396            _depth: fidl::encoding::Depth,
2397        ) -> fidl::Result<()> {
2398            decoder.debug_check_bounds::<Self>(offset);
2399            // Verify that padding bytes are zero.
2400            fidl::decode!(
2401                u32,
2402                fidl::encoding::DefaultFuchsiaResourceDialect,
2403                &mut self.id,
2404                decoder,
2405                offset + 0,
2406                _depth
2407            )?;
2408            fidl::decode!(
2409                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
2410                fidl::encoding::DefaultFuchsiaResourceDialect,
2411                &mut self.client,
2412                decoder,
2413                offset + 4,
2414                _depth
2415            )?;
2416            Ok(())
2417        }
2418    }
2419
2420    impl DeviceDescribeResponse {
2421        #[inline(always)]
2422        fn max_ordinal_present(&self) -> u64 {
2423            if let Some(_) = self.event {
2424                return 1;
2425            }
2426            0
2427        }
2428    }
2429
2430    impl fidl::encoding::ResourceTypeMarker for DeviceDescribeResponse {
2431        type Borrowed<'a> = &'a mut Self;
2432        fn take_or_borrow<'a>(
2433            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2434        ) -> Self::Borrowed<'a> {
2435            value
2436        }
2437    }
2438
2439    unsafe impl fidl::encoding::TypeMarker for DeviceDescribeResponse {
2440        type Owned = Self;
2441
2442        #[inline(always)]
2443        fn inline_align(_context: fidl::encoding::Context) -> usize {
2444            8
2445        }
2446
2447        #[inline(always)]
2448        fn inline_size(_context: fidl::encoding::Context) -> usize {
2449            16
2450        }
2451    }
2452
2453    unsafe impl
2454        fidl::encoding::Encode<
2455            DeviceDescribeResponse,
2456            fidl::encoding::DefaultFuchsiaResourceDialect,
2457        > for &mut DeviceDescribeResponse
2458    {
2459        unsafe fn encode(
2460            self,
2461            encoder: &mut fidl::encoding::Encoder<
2462                '_,
2463                fidl::encoding::DefaultFuchsiaResourceDialect,
2464            >,
2465            offset: usize,
2466            mut depth: fidl::encoding::Depth,
2467        ) -> fidl::Result<()> {
2468            encoder.debug_check_bounds::<DeviceDescribeResponse>(offset);
2469            // Vector header
2470            let max_ordinal: u64 = self.max_ordinal_present();
2471            encoder.write_num(max_ordinal, offset);
2472            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2473            // Calling encoder.out_of_line_offset(0) is not allowed.
2474            if max_ordinal == 0 {
2475                return Ok(());
2476            }
2477            depth.increment()?;
2478            let envelope_size = 8;
2479            let bytes_len = max_ordinal as usize * envelope_size;
2480            #[allow(unused_variables)]
2481            let offset = encoder.out_of_line_offset(bytes_len);
2482            let mut _prev_end_offset: usize = 0;
2483            if 1 > max_ordinal {
2484                return Ok(());
2485            }
2486
2487            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2488            // are envelope_size bytes.
2489            let cur_offset: usize = (1 - 1) * envelope_size;
2490
2491            // Zero reserved fields.
2492            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2493
2494            // Safety:
2495            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2496            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2497            //   envelope_size bytes, there is always sufficient room.
2498            fidl::encoding::encode_in_envelope_optional::<
2499                fidl::encoding::HandleType<
2500                    fidl::EventPair,
2501                    { fidl::ObjectType::EVENTPAIR.into_raw() },
2502                    2147483648,
2503                >,
2504                fidl::encoding::DefaultFuchsiaResourceDialect,
2505            >(
2506                self.event.as_mut().map(
2507                    <fidl::encoding::HandleType<
2508                        fidl::EventPair,
2509                        { fidl::ObjectType::EVENTPAIR.into_raw() },
2510                        2147483648,
2511                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
2512                ),
2513                encoder,
2514                offset + cur_offset,
2515                depth,
2516            )?;
2517
2518            _prev_end_offset = cur_offset + envelope_size;
2519
2520            Ok(())
2521        }
2522    }
2523
2524    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2525        for DeviceDescribeResponse
2526    {
2527        #[inline(always)]
2528        fn new_empty() -> Self {
2529            Self::default()
2530        }
2531
2532        unsafe fn decode(
2533            &mut self,
2534            decoder: &mut fidl::encoding::Decoder<
2535                '_,
2536                fidl::encoding::DefaultFuchsiaResourceDialect,
2537            >,
2538            offset: usize,
2539            mut depth: fidl::encoding::Depth,
2540        ) -> fidl::Result<()> {
2541            decoder.debug_check_bounds::<Self>(offset);
2542            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2543                None => return Err(fidl::Error::NotNullable),
2544                Some(len) => len,
2545            };
2546            // Calling decoder.out_of_line_offset(0) is not allowed.
2547            if len == 0 {
2548                return Ok(());
2549            };
2550            depth.increment()?;
2551            let envelope_size = 8;
2552            let bytes_len = len * envelope_size;
2553            let offset = decoder.out_of_line_offset(bytes_len)?;
2554            // Decode the envelope for each type.
2555            let mut _next_ordinal_to_read = 0;
2556            let mut next_offset = offset;
2557            let end_offset = offset + bytes_len;
2558            _next_ordinal_to_read += 1;
2559            if next_offset >= end_offset {
2560                return Ok(());
2561            }
2562
2563            // Decode unknown envelopes for gaps in ordinals.
2564            while _next_ordinal_to_read < 1 {
2565                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2566                _next_ordinal_to_read += 1;
2567                next_offset += envelope_size;
2568            }
2569
2570            let next_out_of_line = decoder.next_out_of_line();
2571            let handles_before = decoder.remaining_handles();
2572            if let Some((inlined, num_bytes, num_handles)) =
2573                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2574            {
2575                let member_inline_size = <fidl::encoding::HandleType<
2576                    fidl::EventPair,
2577                    { fidl::ObjectType::EVENTPAIR.into_raw() },
2578                    2147483648,
2579                > as fidl::encoding::TypeMarker>::inline_size(
2580                    decoder.context
2581                );
2582                if inlined != (member_inline_size <= 4) {
2583                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2584                }
2585                let inner_offset;
2586                let mut inner_depth = depth.clone();
2587                if inlined {
2588                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2589                    inner_offset = next_offset;
2590                } else {
2591                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2592                    inner_depth.increment()?;
2593                }
2594                let val_ref =
2595                self.event.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
2596                fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
2597                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2598                {
2599                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2600                }
2601                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2602                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2603                }
2604            }
2605
2606            next_offset += envelope_size;
2607
2608            // Decode the remaining unknown envelopes.
2609            while next_offset < end_offset {
2610                _next_ordinal_to_read += 1;
2611                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2612                next_offset += envelope_size;
2613            }
2614
2615            Ok(())
2616        }
2617    }
2618}