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 { Some((responder)) } else { None }
1344    }
1345
1346    #[allow(irrefutable_let_patterns)]
1347    pub fn into_query(self) -> Option<(DeviceQueryResponder)> {
1348        if let DeviceRequest::Query { responder } = self { Some((responder)) } else { None }
1349    }
1350
1351    #[allow(irrefutable_let_patterns)]
1352    pub fn into_read(self) -> Option<(u64, DeviceReadResponder)> {
1353        if let DeviceRequest::Read { count, responder } = self {
1354            Some((count, responder))
1355        } else {
1356            None
1357        }
1358    }
1359
1360    #[allow(irrefutable_let_patterns)]
1361    pub fn into_write(self) -> Option<(Vec<u8>, DeviceWriteResponder)> {
1362        if let DeviceRequest::Write { data, responder } = self {
1363            Some((data, responder))
1364        } else {
1365            None
1366        }
1367    }
1368
1369    #[allow(irrefutable_let_patterns)]
1370    pub fn into_describe(self) -> Option<(DeviceDescribeResponder)> {
1371        if let DeviceRequest::Describe { responder } = self { Some((responder)) } else { None }
1372    }
1373
1374    #[allow(irrefutable_let_patterns)]
1375    pub fn into_open_client(
1376        self,
1377    ) -> Option<(u32, fidl::endpoints::ServerEnd<DeviceMarker>, DeviceOpenClientResponder)> {
1378        if let DeviceRequest::OpenClient { id, client, responder } = self {
1379            Some((id, client, responder))
1380        } else {
1381            None
1382        }
1383    }
1384
1385    #[allow(irrefutable_let_patterns)]
1386    pub fn into_clr_set_feature(self) -> Option<(u32, u32, DeviceClrSetFeatureResponder)> {
1387        if let DeviceRequest::ClrSetFeature { clr, set, responder } = self {
1388            Some((clr, set, responder))
1389        } else {
1390            None
1391        }
1392    }
1393
1394    #[allow(irrefutable_let_patterns)]
1395    pub fn into_get_window_size(self) -> Option<(DeviceGetWindowSizeResponder)> {
1396        if let DeviceRequest::GetWindowSize { responder } = self { Some((responder)) } else { None }
1397    }
1398
1399    #[allow(irrefutable_let_patterns)]
1400    pub fn into_make_active(self) -> Option<(u32, DeviceMakeActiveResponder)> {
1401        if let DeviceRequest::MakeActive { client_pty_id, responder } = self {
1402            Some((client_pty_id, responder))
1403        } else {
1404            None
1405        }
1406    }
1407
1408    #[allow(irrefutable_let_patterns)]
1409    pub fn into_read_events(self) -> Option<(DeviceReadEventsResponder)> {
1410        if let DeviceRequest::ReadEvents { responder } = self { Some((responder)) } else { None }
1411    }
1412
1413    #[allow(irrefutable_let_patterns)]
1414    pub fn into_set_window_size(self) -> Option<(WindowSize, DeviceSetWindowSizeResponder)> {
1415        if let DeviceRequest::SetWindowSize { size, responder } = self {
1416            Some((size, responder))
1417        } else {
1418            None
1419        }
1420    }
1421
1422    /// Name of the method defined in FIDL
1423    pub fn method_name(&self) -> &'static str {
1424        match *self {
1425            DeviceRequest::Clone { .. } => "clone",
1426            DeviceRequest::Close { .. } => "close",
1427            DeviceRequest::Query { .. } => "query",
1428            DeviceRequest::Read { .. } => "read",
1429            DeviceRequest::Write { .. } => "write",
1430            DeviceRequest::Describe { .. } => "describe",
1431            DeviceRequest::OpenClient { .. } => "open_client",
1432            DeviceRequest::ClrSetFeature { .. } => "clr_set_feature",
1433            DeviceRequest::GetWindowSize { .. } => "get_window_size",
1434            DeviceRequest::MakeActive { .. } => "make_active",
1435            DeviceRequest::ReadEvents { .. } => "read_events",
1436            DeviceRequest::SetWindowSize { .. } => "set_window_size",
1437        }
1438    }
1439}
1440
1441#[derive(Debug, Clone)]
1442pub struct DeviceControlHandle {
1443    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1444}
1445
1446impl fidl::endpoints::ControlHandle for DeviceControlHandle {
1447    fn shutdown(&self) {
1448        self.inner.shutdown()
1449    }
1450    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1451        self.inner.shutdown_with_epitaph(status)
1452    }
1453
1454    fn is_closed(&self) -> bool {
1455        self.inner.channel().is_closed()
1456    }
1457    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1458        self.inner.channel().on_closed()
1459    }
1460
1461    #[cfg(target_os = "fuchsia")]
1462    fn signal_peer(
1463        &self,
1464        clear_mask: zx::Signals,
1465        set_mask: zx::Signals,
1466    ) -> Result<(), zx_status::Status> {
1467        use fidl::Peered;
1468        self.inner.channel().signal_peer(clear_mask, set_mask)
1469    }
1470}
1471
1472impl DeviceControlHandle {}
1473
1474#[must_use = "FIDL methods require a response to be sent"]
1475#[derive(Debug)]
1476pub struct DeviceCloseResponder {
1477    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1478    tx_id: u32,
1479}
1480
1481/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1482/// if the responder is dropped without sending a response, so that the client
1483/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1484impl std::ops::Drop for DeviceCloseResponder {
1485    fn drop(&mut self) {
1486        self.control_handle.shutdown();
1487        // Safety: drops once, never accessed again
1488        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1489    }
1490}
1491
1492impl fidl::endpoints::Responder for DeviceCloseResponder {
1493    type ControlHandle = DeviceControlHandle;
1494
1495    fn control_handle(&self) -> &DeviceControlHandle {
1496        &self.control_handle
1497    }
1498
1499    fn drop_without_shutdown(mut self) {
1500        // Safety: drops once, never accessed again due to mem::forget
1501        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1502        // Prevent Drop from running (which would shut down the channel)
1503        std::mem::forget(self);
1504    }
1505}
1506
1507impl DeviceCloseResponder {
1508    /// Sends a response to the FIDL transaction.
1509    ///
1510    /// Sets the channel to shutdown if an error occurs.
1511    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1512        let _result = self.send_raw(result);
1513        if _result.is_err() {
1514            self.control_handle.shutdown();
1515        }
1516        self.drop_without_shutdown();
1517        _result
1518    }
1519
1520    /// Similar to "send" but does not shutdown the channel if an error occurs.
1521    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1522        let _result = self.send_raw(result);
1523        self.drop_without_shutdown();
1524        _result
1525    }
1526
1527    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1528        self.control_handle
1529            .inner
1530            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1531                result,
1532                self.tx_id,
1533                0x5ac5d459ad7f657e,
1534                fidl::encoding::DynamicFlags::empty(),
1535            )
1536    }
1537}
1538
1539#[must_use = "FIDL methods require a response to be sent"]
1540#[derive(Debug)]
1541pub struct DeviceQueryResponder {
1542    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1543    tx_id: u32,
1544}
1545
1546/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1547/// if the responder is dropped without sending a response, so that the client
1548/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1549impl std::ops::Drop for DeviceQueryResponder {
1550    fn drop(&mut self) {
1551        self.control_handle.shutdown();
1552        // Safety: drops once, never accessed again
1553        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1554    }
1555}
1556
1557impl fidl::endpoints::Responder for DeviceQueryResponder {
1558    type ControlHandle = DeviceControlHandle;
1559
1560    fn control_handle(&self) -> &DeviceControlHandle {
1561        &self.control_handle
1562    }
1563
1564    fn drop_without_shutdown(mut self) {
1565        // Safety: drops once, never accessed again due to mem::forget
1566        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1567        // Prevent Drop from running (which would shut down the channel)
1568        std::mem::forget(self);
1569    }
1570}
1571
1572impl DeviceQueryResponder {
1573    /// Sends a response to the FIDL transaction.
1574    ///
1575    /// Sets the channel to shutdown if an error occurs.
1576    pub fn send(self, mut protocol: &[u8]) -> Result<(), fidl::Error> {
1577        let _result = self.send_raw(protocol);
1578        if _result.is_err() {
1579            self.control_handle.shutdown();
1580        }
1581        self.drop_without_shutdown();
1582        _result
1583    }
1584
1585    /// Similar to "send" but does not shutdown the channel if an error occurs.
1586    pub fn send_no_shutdown_on_err(self, mut protocol: &[u8]) -> Result<(), fidl::Error> {
1587        let _result = self.send_raw(protocol);
1588        self.drop_without_shutdown();
1589        _result
1590    }
1591
1592    fn send_raw(&self, mut protocol: &[u8]) -> Result<(), fidl::Error> {
1593        self.control_handle.inner.send::<fidl_fuchsia_unknown::QueryableQueryResponse>(
1594            (protocol,),
1595            self.tx_id,
1596            0x2658edee9decfc06,
1597            fidl::encoding::DynamicFlags::empty(),
1598        )
1599    }
1600}
1601
1602#[must_use = "FIDL methods require a response to be sent"]
1603#[derive(Debug)]
1604pub struct DeviceReadResponder {
1605    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1606    tx_id: u32,
1607}
1608
1609/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1610/// if the responder is dropped without sending a response, so that the client
1611/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1612impl std::ops::Drop for DeviceReadResponder {
1613    fn drop(&mut self) {
1614        self.control_handle.shutdown();
1615        // Safety: drops once, never accessed again
1616        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1617    }
1618}
1619
1620impl fidl::endpoints::Responder for DeviceReadResponder {
1621    type ControlHandle = DeviceControlHandle;
1622
1623    fn control_handle(&self) -> &DeviceControlHandle {
1624        &self.control_handle
1625    }
1626
1627    fn drop_without_shutdown(mut self) {
1628        // Safety: drops once, never accessed again due to mem::forget
1629        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1630        // Prevent Drop from running (which would shut down the channel)
1631        std::mem::forget(self);
1632    }
1633}
1634
1635impl DeviceReadResponder {
1636    /// Sends a response to the FIDL transaction.
1637    ///
1638    /// Sets the channel to shutdown if an error occurs.
1639    pub fn send(self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
1640        let _result = self.send_raw(result);
1641        if _result.is_err() {
1642            self.control_handle.shutdown();
1643        }
1644        self.drop_without_shutdown();
1645        _result
1646    }
1647
1648    /// Similar to "send" but does not shutdown the channel if an error occurs.
1649    pub fn send_no_shutdown_on_err(
1650        self,
1651        mut result: Result<&[u8], i32>,
1652    ) -> Result<(), fidl::Error> {
1653        let _result = self.send_raw(result);
1654        self.drop_without_shutdown();
1655        _result
1656    }
1657
1658    fn send_raw(&self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
1659        self.control_handle.inner.send::<fidl::encoding::ResultType<
1660            fidl_fuchsia_io::ReadableReadResponse,
1661            i32,
1662        >>(
1663            result.map(|data| (data,)),
1664            self.tx_id,
1665            0x57e419a298c8ede,
1666            fidl::encoding::DynamicFlags::empty(),
1667        )
1668    }
1669}
1670
1671#[must_use = "FIDL methods require a response to be sent"]
1672#[derive(Debug)]
1673pub struct DeviceWriteResponder {
1674    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1675    tx_id: u32,
1676}
1677
1678/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1679/// if the responder is dropped without sending a response, so that the client
1680/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1681impl std::ops::Drop for DeviceWriteResponder {
1682    fn drop(&mut self) {
1683        self.control_handle.shutdown();
1684        // Safety: drops once, never accessed again
1685        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1686    }
1687}
1688
1689impl fidl::endpoints::Responder for DeviceWriteResponder {
1690    type ControlHandle = DeviceControlHandle;
1691
1692    fn control_handle(&self) -> &DeviceControlHandle {
1693        &self.control_handle
1694    }
1695
1696    fn drop_without_shutdown(mut self) {
1697        // Safety: drops once, never accessed again due to mem::forget
1698        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1699        // Prevent Drop from running (which would shut down the channel)
1700        std::mem::forget(self);
1701    }
1702}
1703
1704impl DeviceWriteResponder {
1705    /// Sends a response to the FIDL transaction.
1706    ///
1707    /// Sets the channel to shutdown if an error occurs.
1708    pub fn send(self, mut result: Result<u64, i32>) -> Result<(), fidl::Error> {
1709        let _result = self.send_raw(result);
1710        if _result.is_err() {
1711            self.control_handle.shutdown();
1712        }
1713        self.drop_without_shutdown();
1714        _result
1715    }
1716
1717    /// Similar to "send" but does not shutdown the channel if an error occurs.
1718    pub fn send_no_shutdown_on_err(self, mut result: Result<u64, i32>) -> Result<(), fidl::Error> {
1719        let _result = self.send_raw(result);
1720        self.drop_without_shutdown();
1721        _result
1722    }
1723
1724    fn send_raw(&self, mut result: Result<u64, i32>) -> Result<(), fidl::Error> {
1725        self.control_handle.inner.send::<fidl::encoding::ResultType<
1726            fidl_fuchsia_io::WritableWriteResponse,
1727            i32,
1728        >>(
1729            result.map(|actual_count| (actual_count,)),
1730            self.tx_id,
1731            0x6a31437832469f82,
1732            fidl::encoding::DynamicFlags::empty(),
1733        )
1734    }
1735}
1736
1737#[must_use = "FIDL methods require a response to be sent"]
1738#[derive(Debug)]
1739pub struct DeviceDescribeResponder {
1740    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1741    tx_id: u32,
1742}
1743
1744/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1745/// if the responder is dropped without sending a response, so that the client
1746/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1747impl std::ops::Drop for DeviceDescribeResponder {
1748    fn drop(&mut self) {
1749        self.control_handle.shutdown();
1750        // Safety: drops once, never accessed again
1751        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1752    }
1753}
1754
1755impl fidl::endpoints::Responder for DeviceDescribeResponder {
1756    type ControlHandle = DeviceControlHandle;
1757
1758    fn control_handle(&self) -> &DeviceControlHandle {
1759        &self.control_handle
1760    }
1761
1762    fn drop_without_shutdown(mut self) {
1763        // Safety: drops once, never accessed again due to mem::forget
1764        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1765        // Prevent Drop from running (which would shut down the channel)
1766        std::mem::forget(self);
1767    }
1768}
1769
1770impl DeviceDescribeResponder {
1771    /// Sends a response to the FIDL transaction.
1772    ///
1773    /// Sets the channel to shutdown if an error occurs.
1774    pub fn send(self, mut payload: DeviceDescribeResponse) -> Result<(), fidl::Error> {
1775        let _result = self.send_raw(payload);
1776        if _result.is_err() {
1777            self.control_handle.shutdown();
1778        }
1779        self.drop_without_shutdown();
1780        _result
1781    }
1782
1783    /// Similar to "send" but does not shutdown the channel if an error occurs.
1784    pub fn send_no_shutdown_on_err(
1785        self,
1786        mut payload: DeviceDescribeResponse,
1787    ) -> Result<(), fidl::Error> {
1788        let _result = self.send_raw(payload);
1789        self.drop_without_shutdown();
1790        _result
1791    }
1792
1793    fn send_raw(&self, mut payload: DeviceDescribeResponse) -> Result<(), fidl::Error> {
1794        self.control_handle.inner.send::<DeviceDescribeResponse>(
1795            &mut payload,
1796            self.tx_id,
1797            0x585d4b390fe996f5,
1798            fidl::encoding::DynamicFlags::empty(),
1799        )
1800    }
1801}
1802
1803#[must_use = "FIDL methods require a response to be sent"]
1804#[derive(Debug)]
1805pub struct DeviceOpenClientResponder {
1806    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1807    tx_id: u32,
1808}
1809
1810/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1811/// if the responder is dropped without sending a response, so that the client
1812/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1813impl std::ops::Drop for DeviceOpenClientResponder {
1814    fn drop(&mut self) {
1815        self.control_handle.shutdown();
1816        // Safety: drops once, never accessed again
1817        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1818    }
1819}
1820
1821impl fidl::endpoints::Responder for DeviceOpenClientResponder {
1822    type ControlHandle = DeviceControlHandle;
1823
1824    fn control_handle(&self) -> &DeviceControlHandle {
1825        &self.control_handle
1826    }
1827
1828    fn drop_without_shutdown(mut self) {
1829        // Safety: drops once, never accessed again due to mem::forget
1830        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1831        // Prevent Drop from running (which would shut down the channel)
1832        std::mem::forget(self);
1833    }
1834}
1835
1836impl DeviceOpenClientResponder {
1837    /// Sends a response to the FIDL transaction.
1838    ///
1839    /// Sets the channel to shutdown if an error occurs.
1840    pub fn send(self, mut s: i32) -> Result<(), fidl::Error> {
1841        let _result = self.send_raw(s);
1842        if _result.is_err() {
1843            self.control_handle.shutdown();
1844        }
1845        self.drop_without_shutdown();
1846        _result
1847    }
1848
1849    /// Similar to "send" but does not shutdown the channel if an error occurs.
1850    pub fn send_no_shutdown_on_err(self, mut s: i32) -> Result<(), fidl::Error> {
1851        let _result = self.send_raw(s);
1852        self.drop_without_shutdown();
1853        _result
1854    }
1855
1856    fn send_raw(&self, mut s: i32) -> Result<(), fidl::Error> {
1857        self.control_handle.inner.send::<DeviceOpenClientResponse>(
1858            (s,),
1859            self.tx_id,
1860            0x78f040fe6a1ebb3,
1861            fidl::encoding::DynamicFlags::empty(),
1862        )
1863    }
1864}
1865
1866#[must_use = "FIDL methods require a response to be sent"]
1867#[derive(Debug)]
1868pub struct DeviceClrSetFeatureResponder {
1869    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1870    tx_id: u32,
1871}
1872
1873/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1874/// if the responder is dropped without sending a response, so that the client
1875/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1876impl std::ops::Drop for DeviceClrSetFeatureResponder {
1877    fn drop(&mut self) {
1878        self.control_handle.shutdown();
1879        // Safety: drops once, never accessed again
1880        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1881    }
1882}
1883
1884impl fidl::endpoints::Responder for DeviceClrSetFeatureResponder {
1885    type ControlHandle = DeviceControlHandle;
1886
1887    fn control_handle(&self) -> &DeviceControlHandle {
1888        &self.control_handle
1889    }
1890
1891    fn drop_without_shutdown(mut self) {
1892        // Safety: drops once, never accessed again due to mem::forget
1893        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1894        // Prevent Drop from running (which would shut down the channel)
1895        std::mem::forget(self);
1896    }
1897}
1898
1899impl DeviceClrSetFeatureResponder {
1900    /// Sends a response to the FIDL transaction.
1901    ///
1902    /// Sets the channel to shutdown if an error occurs.
1903    pub fn send(self, mut status: i32, mut features: u32) -> Result<(), fidl::Error> {
1904        let _result = self.send_raw(status, features);
1905        if _result.is_err() {
1906            self.control_handle.shutdown();
1907        }
1908        self.drop_without_shutdown();
1909        _result
1910    }
1911
1912    /// Similar to "send" but does not shutdown the channel if an error occurs.
1913    pub fn send_no_shutdown_on_err(
1914        self,
1915        mut status: i32,
1916        mut features: u32,
1917    ) -> Result<(), fidl::Error> {
1918        let _result = self.send_raw(status, features);
1919        self.drop_without_shutdown();
1920        _result
1921    }
1922
1923    fn send_raw(&self, mut status: i32, mut features: u32) -> Result<(), fidl::Error> {
1924        self.control_handle.inner.send::<DeviceClrSetFeatureResponse>(
1925            (status, features),
1926            self.tx_id,
1927            0x6367986e6053a15e,
1928            fidl::encoding::DynamicFlags::empty(),
1929        )
1930    }
1931}
1932
1933#[must_use = "FIDL methods require a response to be sent"]
1934#[derive(Debug)]
1935pub struct DeviceGetWindowSizeResponder {
1936    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1937    tx_id: u32,
1938}
1939
1940/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1941/// if the responder is dropped without sending a response, so that the client
1942/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1943impl std::ops::Drop for DeviceGetWindowSizeResponder {
1944    fn drop(&mut self) {
1945        self.control_handle.shutdown();
1946        // Safety: drops once, never accessed again
1947        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1948    }
1949}
1950
1951impl fidl::endpoints::Responder for DeviceGetWindowSizeResponder {
1952    type ControlHandle = DeviceControlHandle;
1953
1954    fn control_handle(&self) -> &DeviceControlHandle {
1955        &self.control_handle
1956    }
1957
1958    fn drop_without_shutdown(mut self) {
1959        // Safety: drops once, never accessed again due to mem::forget
1960        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1961        // Prevent Drop from running (which would shut down the channel)
1962        std::mem::forget(self);
1963    }
1964}
1965
1966impl DeviceGetWindowSizeResponder {
1967    /// Sends a response to the FIDL transaction.
1968    ///
1969    /// Sets the channel to shutdown if an error occurs.
1970    pub fn send(self, mut status: i32, mut size: &WindowSize) -> Result<(), fidl::Error> {
1971        let _result = self.send_raw(status, size);
1972        if _result.is_err() {
1973            self.control_handle.shutdown();
1974        }
1975        self.drop_without_shutdown();
1976        _result
1977    }
1978
1979    /// Similar to "send" but does not shutdown the channel if an error occurs.
1980    pub fn send_no_shutdown_on_err(
1981        self,
1982        mut status: i32,
1983        mut size: &WindowSize,
1984    ) -> Result<(), fidl::Error> {
1985        let _result = self.send_raw(status, size);
1986        self.drop_without_shutdown();
1987        _result
1988    }
1989
1990    fn send_raw(&self, mut status: i32, mut size: &WindowSize) -> Result<(), fidl::Error> {
1991        self.control_handle.inner.send::<DeviceGetWindowSizeResponse>(
1992            (status, size),
1993            self.tx_id,
1994            0x747bed0460f5f9f7,
1995            fidl::encoding::DynamicFlags::empty(),
1996        )
1997    }
1998}
1999
2000#[must_use = "FIDL methods require a response to be sent"]
2001#[derive(Debug)]
2002pub struct DeviceMakeActiveResponder {
2003    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2004    tx_id: u32,
2005}
2006
2007/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2008/// if the responder is dropped without sending a response, so that the client
2009/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2010impl std::ops::Drop for DeviceMakeActiveResponder {
2011    fn drop(&mut self) {
2012        self.control_handle.shutdown();
2013        // Safety: drops once, never accessed again
2014        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2015    }
2016}
2017
2018impl fidl::endpoints::Responder for DeviceMakeActiveResponder {
2019    type ControlHandle = DeviceControlHandle;
2020
2021    fn control_handle(&self) -> &DeviceControlHandle {
2022        &self.control_handle
2023    }
2024
2025    fn drop_without_shutdown(mut self) {
2026        // Safety: drops once, never accessed again due to mem::forget
2027        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2028        // Prevent Drop from running (which would shut down the channel)
2029        std::mem::forget(self);
2030    }
2031}
2032
2033impl DeviceMakeActiveResponder {
2034    /// Sends a response to the FIDL transaction.
2035    ///
2036    /// Sets the channel to shutdown if an error occurs.
2037    pub fn send(self, mut status: i32) -> Result<(), fidl::Error> {
2038        let _result = self.send_raw(status);
2039        if _result.is_err() {
2040            self.control_handle.shutdown();
2041        }
2042        self.drop_without_shutdown();
2043        _result
2044    }
2045
2046    /// Similar to "send" but does not shutdown the channel if an error occurs.
2047    pub fn send_no_shutdown_on_err(self, mut status: i32) -> Result<(), fidl::Error> {
2048        let _result = self.send_raw(status);
2049        self.drop_without_shutdown();
2050        _result
2051    }
2052
2053    fn send_raw(&self, mut status: i32) -> Result<(), fidl::Error> {
2054        self.control_handle.inner.send::<DeviceMakeActiveResponse>(
2055            (status,),
2056            self.tx_id,
2057            0x2763944f30ee2a62,
2058            fidl::encoding::DynamicFlags::empty(),
2059        )
2060    }
2061}
2062
2063#[must_use = "FIDL methods require a response to be sent"]
2064#[derive(Debug)]
2065pub struct DeviceReadEventsResponder {
2066    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2067    tx_id: u32,
2068}
2069
2070/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2071/// if the responder is dropped without sending a response, so that the client
2072/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2073impl std::ops::Drop for DeviceReadEventsResponder {
2074    fn drop(&mut self) {
2075        self.control_handle.shutdown();
2076        // Safety: drops once, never accessed again
2077        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2078    }
2079}
2080
2081impl fidl::endpoints::Responder for DeviceReadEventsResponder {
2082    type ControlHandle = DeviceControlHandle;
2083
2084    fn control_handle(&self) -> &DeviceControlHandle {
2085        &self.control_handle
2086    }
2087
2088    fn drop_without_shutdown(mut self) {
2089        // Safety: drops once, never accessed again due to mem::forget
2090        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2091        // Prevent Drop from running (which would shut down the channel)
2092        std::mem::forget(self);
2093    }
2094}
2095
2096impl DeviceReadEventsResponder {
2097    /// Sends a response to the FIDL transaction.
2098    ///
2099    /// Sets the channel to shutdown if an error occurs.
2100    pub fn send(self, mut status: i32, mut events: u32) -> Result<(), fidl::Error> {
2101        let _result = self.send_raw(status, events);
2102        if _result.is_err() {
2103            self.control_handle.shutdown();
2104        }
2105        self.drop_without_shutdown();
2106        _result
2107    }
2108
2109    /// Similar to "send" but does not shutdown the channel if an error occurs.
2110    pub fn send_no_shutdown_on_err(
2111        self,
2112        mut status: i32,
2113        mut events: u32,
2114    ) -> Result<(), fidl::Error> {
2115        let _result = self.send_raw(status, events);
2116        self.drop_without_shutdown();
2117        _result
2118    }
2119
2120    fn send_raw(&self, mut status: i32, mut events: u32) -> Result<(), fidl::Error> {
2121        self.control_handle.inner.send::<DeviceReadEventsResponse>(
2122            (status, events),
2123            self.tx_id,
2124            0xede96f3e3258f62,
2125            fidl::encoding::DynamicFlags::empty(),
2126        )
2127    }
2128}
2129
2130#[must_use = "FIDL methods require a response to be sent"]
2131#[derive(Debug)]
2132pub struct DeviceSetWindowSizeResponder {
2133    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2134    tx_id: u32,
2135}
2136
2137/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2138/// if the responder is dropped without sending a response, so that the client
2139/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2140impl std::ops::Drop for DeviceSetWindowSizeResponder {
2141    fn drop(&mut self) {
2142        self.control_handle.shutdown();
2143        // Safety: drops once, never accessed again
2144        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2145    }
2146}
2147
2148impl fidl::endpoints::Responder for DeviceSetWindowSizeResponder {
2149    type ControlHandle = DeviceControlHandle;
2150
2151    fn control_handle(&self) -> &DeviceControlHandle {
2152        &self.control_handle
2153    }
2154
2155    fn drop_without_shutdown(mut self) {
2156        // Safety: drops once, never accessed again due to mem::forget
2157        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2158        // Prevent Drop from running (which would shut down the channel)
2159        std::mem::forget(self);
2160    }
2161}
2162
2163impl DeviceSetWindowSizeResponder {
2164    /// Sends a response to the FIDL transaction.
2165    ///
2166    /// Sets the channel to shutdown if an error occurs.
2167    pub fn send(self, mut status: i32) -> Result<(), fidl::Error> {
2168        let _result = self.send_raw(status);
2169        if _result.is_err() {
2170            self.control_handle.shutdown();
2171        }
2172        self.drop_without_shutdown();
2173        _result
2174    }
2175
2176    /// Similar to "send" but does not shutdown the channel if an error occurs.
2177    pub fn send_no_shutdown_on_err(self, mut status: i32) -> Result<(), fidl::Error> {
2178        let _result = self.send_raw(status);
2179        self.drop_without_shutdown();
2180        _result
2181    }
2182
2183    fn send_raw(&self, mut status: i32) -> Result<(), fidl::Error> {
2184        self.control_handle.inner.send::<DeviceSetWindowSizeResponse>(
2185            (status,),
2186            self.tx_id,
2187            0x17d1cb37377e7928,
2188            fidl::encoding::DynamicFlags::empty(),
2189        )
2190    }
2191}
2192
2193#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2194pub struct ServiceMarker;
2195
2196#[cfg(target_os = "fuchsia")]
2197impl fidl::endpoints::ServiceMarker for ServiceMarker {
2198    type Proxy = ServiceProxy;
2199    type Request = ServiceRequest;
2200    const SERVICE_NAME: &'static str = "fuchsia.hardware.pty.Service";
2201}
2202
2203/// A request for one of the member protocols of Service.
2204///
2205#[cfg(target_os = "fuchsia")]
2206pub enum ServiceRequest {
2207    Device(DeviceRequestStream),
2208}
2209
2210#[cfg(target_os = "fuchsia")]
2211impl fidl::endpoints::ServiceRequest for ServiceRequest {
2212    type Service = ServiceMarker;
2213
2214    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
2215        match name {
2216            "device" => Self::Device(
2217                <DeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
2218            ),
2219            _ => panic!("no such member protocol name for service Service"),
2220        }
2221    }
2222
2223    fn member_names() -> &'static [&'static str] {
2224        &["device"]
2225    }
2226}
2227#[cfg(target_os = "fuchsia")]
2228pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
2229
2230#[cfg(target_os = "fuchsia")]
2231impl fidl::endpoints::ServiceProxy for ServiceProxy {
2232    type Service = ServiceMarker;
2233
2234    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
2235        Self(opener)
2236    }
2237}
2238
2239#[cfg(target_os = "fuchsia")]
2240impl ServiceProxy {
2241    pub fn connect_to_device(&self) -> Result<DeviceProxy, fidl::Error> {
2242        let (proxy, server_end) = fidl::endpoints::create_proxy::<DeviceMarker>();
2243        self.connect_channel_to_device(server_end)?;
2244        Ok(proxy)
2245    }
2246
2247    /// Like `connect_to_device`, but returns a sync proxy.
2248    /// See [`Self::connect_to_device`] for more details.
2249    pub fn connect_to_device_sync(&self) -> Result<DeviceSynchronousProxy, fidl::Error> {
2250        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DeviceMarker>();
2251        self.connect_channel_to_device(server_end)?;
2252        Ok(proxy)
2253    }
2254
2255    /// Like `connect_to_device`, but accepts a server end.
2256    /// See [`Self::connect_to_device`] for more details.
2257    pub fn connect_channel_to_device(
2258        &self,
2259        server_end: fidl::endpoints::ServerEnd<DeviceMarker>,
2260    ) -> Result<(), fidl::Error> {
2261        self.0.open_member("device", server_end.into_channel())
2262    }
2263
2264    pub fn instance_name(&self) -> &str {
2265        self.0.instance_name()
2266    }
2267}
2268
2269mod internal {
2270    use super::*;
2271
2272    impl fidl::encoding::ResourceTypeMarker for DeviceOpenClientRequest {
2273        type Borrowed<'a> = &'a mut Self;
2274        fn take_or_borrow<'a>(
2275            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2276        ) -> Self::Borrowed<'a> {
2277            value
2278        }
2279    }
2280
2281    unsafe impl fidl::encoding::TypeMarker for DeviceOpenClientRequest {
2282        type Owned = Self;
2283
2284        #[inline(always)]
2285        fn inline_align(_context: fidl::encoding::Context) -> usize {
2286            4
2287        }
2288
2289        #[inline(always)]
2290        fn inline_size(_context: fidl::encoding::Context) -> usize {
2291            8
2292        }
2293    }
2294
2295    unsafe impl
2296        fidl::encoding::Encode<
2297            DeviceOpenClientRequest,
2298            fidl::encoding::DefaultFuchsiaResourceDialect,
2299        > for &mut DeviceOpenClientRequest
2300    {
2301        #[inline]
2302        unsafe fn encode(
2303            self,
2304            encoder: &mut fidl::encoding::Encoder<
2305                '_,
2306                fidl::encoding::DefaultFuchsiaResourceDialect,
2307            >,
2308            offset: usize,
2309            _depth: fidl::encoding::Depth,
2310        ) -> fidl::Result<()> {
2311            encoder.debug_check_bounds::<DeviceOpenClientRequest>(offset);
2312            // Delegate to tuple encoding.
2313            fidl::encoding::Encode::<DeviceOpenClientRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2314                (
2315                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
2316                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.client),
2317                ),
2318                encoder, offset, _depth
2319            )
2320        }
2321    }
2322    unsafe impl<
2323        T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
2324        T1: fidl::encoding::Encode<
2325                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
2326                fidl::encoding::DefaultFuchsiaResourceDialect,
2327            >,
2328    >
2329        fidl::encoding::Encode<
2330            DeviceOpenClientRequest,
2331            fidl::encoding::DefaultFuchsiaResourceDialect,
2332        > for (T0, T1)
2333    {
2334        #[inline]
2335        unsafe fn encode(
2336            self,
2337            encoder: &mut fidl::encoding::Encoder<
2338                '_,
2339                fidl::encoding::DefaultFuchsiaResourceDialect,
2340            >,
2341            offset: usize,
2342            depth: fidl::encoding::Depth,
2343        ) -> fidl::Result<()> {
2344            encoder.debug_check_bounds::<DeviceOpenClientRequest>(offset);
2345            // Zero out padding regions. There's no need to apply masks
2346            // because the unmasked parts will be overwritten by fields.
2347            // Write the fields.
2348            self.0.encode(encoder, offset + 0, depth)?;
2349            self.1.encode(encoder, offset + 4, depth)?;
2350            Ok(())
2351        }
2352    }
2353
2354    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2355        for DeviceOpenClientRequest
2356    {
2357        #[inline(always)]
2358        fn new_empty() -> Self {
2359            Self {
2360                id: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
2361                client: fidl::new_empty!(
2362                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
2363                    fidl::encoding::DefaultFuchsiaResourceDialect
2364                ),
2365            }
2366        }
2367
2368        #[inline]
2369        unsafe fn decode(
2370            &mut self,
2371            decoder: &mut fidl::encoding::Decoder<
2372                '_,
2373                fidl::encoding::DefaultFuchsiaResourceDialect,
2374            >,
2375            offset: usize,
2376            _depth: fidl::encoding::Depth,
2377        ) -> fidl::Result<()> {
2378            decoder.debug_check_bounds::<Self>(offset);
2379            // Verify that padding bytes are zero.
2380            fidl::decode!(
2381                u32,
2382                fidl::encoding::DefaultFuchsiaResourceDialect,
2383                &mut self.id,
2384                decoder,
2385                offset + 0,
2386                _depth
2387            )?;
2388            fidl::decode!(
2389                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
2390                fidl::encoding::DefaultFuchsiaResourceDialect,
2391                &mut self.client,
2392                decoder,
2393                offset + 4,
2394                _depth
2395            )?;
2396            Ok(())
2397        }
2398    }
2399
2400    impl DeviceDescribeResponse {
2401        #[inline(always)]
2402        fn max_ordinal_present(&self) -> u64 {
2403            if let Some(_) = self.event {
2404                return 1;
2405            }
2406            0
2407        }
2408    }
2409
2410    impl fidl::encoding::ResourceTypeMarker for DeviceDescribeResponse {
2411        type Borrowed<'a> = &'a mut Self;
2412        fn take_or_borrow<'a>(
2413            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2414        ) -> Self::Borrowed<'a> {
2415            value
2416        }
2417    }
2418
2419    unsafe impl fidl::encoding::TypeMarker for DeviceDescribeResponse {
2420        type Owned = Self;
2421
2422        #[inline(always)]
2423        fn inline_align(_context: fidl::encoding::Context) -> usize {
2424            8
2425        }
2426
2427        #[inline(always)]
2428        fn inline_size(_context: fidl::encoding::Context) -> usize {
2429            16
2430        }
2431    }
2432
2433    unsafe impl
2434        fidl::encoding::Encode<
2435            DeviceDescribeResponse,
2436            fidl::encoding::DefaultFuchsiaResourceDialect,
2437        > for &mut DeviceDescribeResponse
2438    {
2439        unsafe fn encode(
2440            self,
2441            encoder: &mut fidl::encoding::Encoder<
2442                '_,
2443                fidl::encoding::DefaultFuchsiaResourceDialect,
2444            >,
2445            offset: usize,
2446            mut depth: fidl::encoding::Depth,
2447        ) -> fidl::Result<()> {
2448            encoder.debug_check_bounds::<DeviceDescribeResponse>(offset);
2449            // Vector header
2450            let max_ordinal: u64 = self.max_ordinal_present();
2451            encoder.write_num(max_ordinal, offset);
2452            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2453            // Calling encoder.out_of_line_offset(0) is not allowed.
2454            if max_ordinal == 0 {
2455                return Ok(());
2456            }
2457            depth.increment()?;
2458            let envelope_size = 8;
2459            let bytes_len = max_ordinal as usize * envelope_size;
2460            #[allow(unused_variables)]
2461            let offset = encoder.out_of_line_offset(bytes_len);
2462            let mut _prev_end_offset: usize = 0;
2463            if 1 > max_ordinal {
2464                return Ok(());
2465            }
2466
2467            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2468            // are envelope_size bytes.
2469            let cur_offset: usize = (1 - 1) * envelope_size;
2470
2471            // Zero reserved fields.
2472            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2473
2474            // Safety:
2475            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2476            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2477            //   envelope_size bytes, there is always sufficient room.
2478            fidl::encoding::encode_in_envelope_optional::<
2479                fidl::encoding::HandleType<
2480                    fidl::EventPair,
2481                    { fidl::ObjectType::EVENTPAIR.into_raw() },
2482                    2147483648,
2483                >,
2484                fidl::encoding::DefaultFuchsiaResourceDialect,
2485            >(
2486                self.event.as_mut().map(
2487                    <fidl::encoding::HandleType<
2488                        fidl::EventPair,
2489                        { fidl::ObjectType::EVENTPAIR.into_raw() },
2490                        2147483648,
2491                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
2492                ),
2493                encoder,
2494                offset + cur_offset,
2495                depth,
2496            )?;
2497
2498            _prev_end_offset = cur_offset + envelope_size;
2499
2500            Ok(())
2501        }
2502    }
2503
2504    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2505        for DeviceDescribeResponse
2506    {
2507        #[inline(always)]
2508        fn new_empty() -> Self {
2509            Self::default()
2510        }
2511
2512        unsafe fn decode(
2513            &mut self,
2514            decoder: &mut fidl::encoding::Decoder<
2515                '_,
2516                fidl::encoding::DefaultFuchsiaResourceDialect,
2517            >,
2518            offset: usize,
2519            mut depth: fidl::encoding::Depth,
2520        ) -> fidl::Result<()> {
2521            decoder.debug_check_bounds::<Self>(offset);
2522            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2523                None => return Err(fidl::Error::NotNullable),
2524                Some(len) => len,
2525            };
2526            // Calling decoder.out_of_line_offset(0) is not allowed.
2527            if len == 0 {
2528                return Ok(());
2529            };
2530            depth.increment()?;
2531            let envelope_size = 8;
2532            let bytes_len = len * envelope_size;
2533            let offset = decoder.out_of_line_offset(bytes_len)?;
2534            // Decode the envelope for each type.
2535            let mut _next_ordinal_to_read = 0;
2536            let mut next_offset = offset;
2537            let end_offset = offset + bytes_len;
2538            _next_ordinal_to_read += 1;
2539            if next_offset >= end_offset {
2540                return Ok(());
2541            }
2542
2543            // Decode unknown envelopes for gaps in ordinals.
2544            while _next_ordinal_to_read < 1 {
2545                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2546                _next_ordinal_to_read += 1;
2547                next_offset += envelope_size;
2548            }
2549
2550            let next_out_of_line = decoder.next_out_of_line();
2551            let handles_before = decoder.remaining_handles();
2552            if let Some((inlined, num_bytes, num_handles)) =
2553                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2554            {
2555                let member_inline_size = <fidl::encoding::HandleType<
2556                    fidl::EventPair,
2557                    { fidl::ObjectType::EVENTPAIR.into_raw() },
2558                    2147483648,
2559                > as fidl::encoding::TypeMarker>::inline_size(
2560                    decoder.context
2561                );
2562                if inlined != (member_inline_size <= 4) {
2563                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2564                }
2565                let inner_offset;
2566                let mut inner_depth = depth.clone();
2567                if inlined {
2568                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2569                    inner_offset = next_offset;
2570                } else {
2571                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2572                    inner_depth.increment()?;
2573                }
2574                let val_ref =
2575                self.event.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
2576                fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
2577                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2578                {
2579                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2580                }
2581                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2582                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2583                }
2584            }
2585
2586            next_offset += envelope_size;
2587
2588            // Decode the remaining unknown envelopes.
2589            while next_offset < end_offset {
2590                _next_ordinal_to_read += 1;
2591                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2592                next_offset += envelope_size;
2593            }
2594
2595            Ok(())
2596        }
2597    }
2598}