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