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