Skip to main content

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