Skip to main content

fidl_fuchsia_hardware_serial/
fidl_fuchsia_hardware_serial.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_serial_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct DeviceProxyGetChannelRequest {
16    pub req: fidl::endpoints::ServerEnd<DeviceMarker>,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20    for DeviceProxyGetChannelRequest
21{
22}
23
24#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
25pub struct DeviceMarker;
26
27impl fidl::endpoints::ProtocolMarker for DeviceMarker {
28    type Proxy = DeviceProxy;
29    type RequestStream = DeviceRequestStream;
30    #[cfg(target_os = "fuchsia")]
31    type SynchronousProxy = DeviceSynchronousProxy;
32
33    const DEBUG_NAME: &'static str = "(anonymous) Device";
34}
35pub type DeviceReadResult = Result<Vec<u8>, i32>;
36pub type DeviceWriteResult = Result<(), i32>;
37
38pub trait DeviceProxyInterface: Send + Sync {
39    type GetClassResponseFut: std::future::Future<Output = Result<Class, fidl::Error>> + Send;
40    fn r#get_class(&self) -> Self::GetClassResponseFut;
41    type SetConfigResponseFut: std::future::Future<Output = Result<i32, fidl::Error>> + Send;
42    fn r#set_config(&self, config: &Config) -> Self::SetConfigResponseFut;
43    type ReadResponseFut: std::future::Future<Output = Result<DeviceReadResult, fidl::Error>> + Send;
44    fn r#read(&self) -> Self::ReadResponseFut;
45    type WriteResponseFut: std::future::Future<Output = Result<DeviceWriteResult, fidl::Error>>
46        + Send;
47    fn r#write(&self, data: &[u8]) -> Self::WriteResponseFut;
48}
49#[derive(Debug)]
50#[cfg(target_os = "fuchsia")]
51pub struct DeviceSynchronousProxy {
52    client: fidl::client::sync::Client,
53}
54
55#[cfg(target_os = "fuchsia")]
56impl fidl::endpoints::SynchronousProxy for DeviceSynchronousProxy {
57    type Proxy = DeviceProxy;
58    type Protocol = DeviceMarker;
59
60    fn from_channel(inner: fidl::Channel) -> Self {
61        Self::new(inner)
62    }
63
64    fn into_channel(self) -> fidl::Channel {
65        self.client.into_channel()
66    }
67
68    fn as_channel(&self) -> &fidl::Channel {
69        self.client.as_channel()
70    }
71}
72
73#[cfg(target_os = "fuchsia")]
74impl DeviceSynchronousProxy {
75    pub fn new(channel: fidl::Channel) -> Self {
76        Self { client: fidl::client::sync::Client::new(channel) }
77    }
78
79    pub fn into_channel(self) -> fidl::Channel {
80        self.client.into_channel()
81    }
82
83    /// Waits until an event arrives and returns it. It is safe for other
84    /// threads to make concurrent requests while waiting for an event.
85    pub fn wait_for_event(
86        &self,
87        deadline: zx::MonotonicInstant,
88    ) -> Result<DeviceEvent, fidl::Error> {
89        DeviceEvent::decode(self.client.wait_for_event::<DeviceMarker>(deadline)?)
90    }
91
92    /// Lookup what type of serial device this is.
93    pub fn r#get_class(&self, ___deadline: zx::MonotonicInstant) -> Result<Class, fidl::Error> {
94        let _response = self
95            .client
96            .send_query::<fidl::encoding::EmptyPayload, DeviceGetClassResponse, DeviceMarker>(
97                (),
98                0x3d48bbcee248ab8b,
99                fidl::encoding::DynamicFlags::empty(),
100                ___deadline,
101            )?;
102        Ok(_response.device_class)
103    }
104
105    /// Set the configuration of this serial device.
106    pub fn r#set_config(
107        &self,
108        mut config: &Config,
109        ___deadline: zx::MonotonicInstant,
110    ) -> Result<i32, fidl::Error> {
111        let _response = self
112            .client
113            .send_query::<DeviceSetConfigRequest, DeviceSetConfigResponse, DeviceMarker>(
114                (config,),
115                0x771a0946f6f87173,
116                fidl::encoding::DynamicFlags::empty(),
117                ___deadline,
118            )?;
119        Ok(_response.s)
120    }
121
122    /// Reads data from the serial port.
123    pub fn r#read(
124        &self,
125        ___deadline: zx::MonotonicInstant,
126    ) -> Result<DeviceReadResult, fidl::Error> {
127        let _response = self.client.send_query::<
128            fidl::encoding::EmptyPayload,
129            fidl::encoding::ResultType<DeviceReadResponse, i32>,
130            DeviceMarker,
131        >(
132            (),
133            0x63c41d3c053fadd8,
134            fidl::encoding::DynamicFlags::empty(),
135            ___deadline,
136        )?;
137        Ok(_response.map(|x| x.data))
138    }
139
140    /// Writes data to the serial port.
141    pub fn r#write(
142        &self,
143        mut data: &[u8],
144        ___deadline: zx::MonotonicInstant,
145    ) -> Result<DeviceWriteResult, fidl::Error> {
146        let _response = self.client.send_query::<
147            DeviceWriteRequest,
148            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
149            DeviceMarker,
150        >(
151            (data,),
152            0x6aa7adae6841779c,
153            fidl::encoding::DynamicFlags::empty(),
154            ___deadline,
155        )?;
156        Ok(_response.map(|x| x))
157    }
158}
159
160#[cfg(target_os = "fuchsia")]
161impl From<DeviceSynchronousProxy> for zx::NullableHandle {
162    fn from(value: DeviceSynchronousProxy) -> Self {
163        value.into_channel().into()
164    }
165}
166
167#[cfg(target_os = "fuchsia")]
168impl From<fidl::Channel> for DeviceSynchronousProxy {
169    fn from(value: fidl::Channel) -> Self {
170        Self::new(value)
171    }
172}
173
174#[cfg(target_os = "fuchsia")]
175impl fidl::endpoints::FromClient for DeviceSynchronousProxy {
176    type Protocol = DeviceMarker;
177
178    fn from_client(value: fidl::endpoints::ClientEnd<DeviceMarker>) -> Self {
179        Self::new(value.into_channel())
180    }
181}
182
183#[derive(Debug, Clone)]
184pub struct DeviceProxy {
185    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
186}
187
188impl fidl::endpoints::Proxy for DeviceProxy {
189    type Protocol = DeviceMarker;
190
191    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
192        Self::new(inner)
193    }
194
195    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
196        self.client.into_channel().map_err(|client| Self { client })
197    }
198
199    fn as_channel(&self) -> &::fidl::AsyncChannel {
200        self.client.as_channel()
201    }
202}
203
204impl DeviceProxy {
205    /// Create a new Proxy for fuchsia.hardware.serial/Device.
206    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
207        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
208        Self { client: fidl::client::Client::new(channel, protocol_name) }
209    }
210
211    /// Get a Stream of events from the remote end of the protocol.
212    ///
213    /// # Panics
214    ///
215    /// Panics if the event stream was already taken.
216    pub fn take_event_stream(&self) -> DeviceEventStream {
217        DeviceEventStream { event_receiver: self.client.take_event_receiver() }
218    }
219
220    /// Lookup what type of serial device this is.
221    pub fn r#get_class(
222        &self,
223    ) -> fidl::client::QueryResponseFut<Class, fidl::encoding::DefaultFuchsiaResourceDialect> {
224        DeviceProxyInterface::r#get_class(self)
225    }
226
227    /// Set the configuration of this serial device.
228    pub fn r#set_config(
229        &self,
230        mut config: &Config,
231    ) -> fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect> {
232        DeviceProxyInterface::r#set_config(self, config)
233    }
234
235    /// Reads data from the serial port.
236    pub fn r#read(
237        &self,
238    ) -> fidl::client::QueryResponseFut<
239        DeviceReadResult,
240        fidl::encoding::DefaultFuchsiaResourceDialect,
241    > {
242        DeviceProxyInterface::r#read(self)
243    }
244
245    /// Writes data to the serial port.
246    pub fn r#write(
247        &self,
248        mut data: &[u8],
249    ) -> fidl::client::QueryResponseFut<
250        DeviceWriteResult,
251        fidl::encoding::DefaultFuchsiaResourceDialect,
252    > {
253        DeviceProxyInterface::r#write(self, data)
254    }
255}
256
257impl DeviceProxyInterface for DeviceProxy {
258    type GetClassResponseFut =
259        fidl::client::QueryResponseFut<Class, fidl::encoding::DefaultFuchsiaResourceDialect>;
260    fn r#get_class(&self) -> Self::GetClassResponseFut {
261        fn _decode(
262            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
263        ) -> Result<Class, fidl::Error> {
264            let _response = fidl::client::decode_transaction_body::<
265                DeviceGetClassResponse,
266                fidl::encoding::DefaultFuchsiaResourceDialect,
267                0x3d48bbcee248ab8b,
268            >(_buf?)?;
269            Ok(_response.device_class)
270        }
271        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Class>(
272            (),
273            0x3d48bbcee248ab8b,
274            fidl::encoding::DynamicFlags::empty(),
275            _decode,
276        )
277    }
278
279    type SetConfigResponseFut =
280        fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect>;
281    fn r#set_config(&self, mut config: &Config) -> Self::SetConfigResponseFut {
282        fn _decode(
283            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
284        ) -> Result<i32, fidl::Error> {
285            let _response = fidl::client::decode_transaction_body::<
286                DeviceSetConfigResponse,
287                fidl::encoding::DefaultFuchsiaResourceDialect,
288                0x771a0946f6f87173,
289            >(_buf?)?;
290            Ok(_response.s)
291        }
292        self.client.send_query_and_decode::<DeviceSetConfigRequest, i32>(
293            (config,),
294            0x771a0946f6f87173,
295            fidl::encoding::DynamicFlags::empty(),
296            _decode,
297        )
298    }
299
300    type ReadResponseFut = fidl::client::QueryResponseFut<
301        DeviceReadResult,
302        fidl::encoding::DefaultFuchsiaResourceDialect,
303    >;
304    fn r#read(&self) -> Self::ReadResponseFut {
305        fn _decode(
306            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
307        ) -> Result<DeviceReadResult, fidl::Error> {
308            let _response = fidl::client::decode_transaction_body::<
309                fidl::encoding::ResultType<DeviceReadResponse, i32>,
310                fidl::encoding::DefaultFuchsiaResourceDialect,
311                0x63c41d3c053fadd8,
312            >(_buf?)?;
313            Ok(_response.map(|x| x.data))
314        }
315        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, DeviceReadResult>(
316            (),
317            0x63c41d3c053fadd8,
318            fidl::encoding::DynamicFlags::empty(),
319            _decode,
320        )
321    }
322
323    type WriteResponseFut = fidl::client::QueryResponseFut<
324        DeviceWriteResult,
325        fidl::encoding::DefaultFuchsiaResourceDialect,
326    >;
327    fn r#write(&self, mut data: &[u8]) -> Self::WriteResponseFut {
328        fn _decode(
329            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
330        ) -> Result<DeviceWriteResult, fidl::Error> {
331            let _response = fidl::client::decode_transaction_body::<
332                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
333                fidl::encoding::DefaultFuchsiaResourceDialect,
334                0x6aa7adae6841779c,
335            >(_buf?)?;
336            Ok(_response.map(|x| x))
337        }
338        self.client.send_query_and_decode::<DeviceWriteRequest, DeviceWriteResult>(
339            (data,),
340            0x6aa7adae6841779c,
341            fidl::encoding::DynamicFlags::empty(),
342            _decode,
343        )
344    }
345}
346
347pub struct DeviceEventStream {
348    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
349}
350
351impl std::marker::Unpin for DeviceEventStream {}
352
353impl futures::stream::FusedStream for DeviceEventStream {
354    fn is_terminated(&self) -> bool {
355        self.event_receiver.is_terminated()
356    }
357}
358
359impl futures::Stream for DeviceEventStream {
360    type Item = Result<DeviceEvent, fidl::Error>;
361
362    fn poll_next(
363        mut self: std::pin::Pin<&mut Self>,
364        cx: &mut std::task::Context<'_>,
365    ) -> std::task::Poll<Option<Self::Item>> {
366        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
367            &mut self.event_receiver,
368            cx
369        )?) {
370            Some(buf) => std::task::Poll::Ready(Some(DeviceEvent::decode(buf))),
371            None => std::task::Poll::Ready(None),
372        }
373    }
374}
375
376#[derive(Debug)]
377pub enum DeviceEvent {}
378
379impl DeviceEvent {
380    /// Decodes a message buffer as a [`DeviceEvent`].
381    fn decode(
382        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
383    ) -> Result<DeviceEvent, fidl::Error> {
384        let (bytes, _handles) = buf.split_mut();
385        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
386        debug_assert_eq!(tx_header.tx_id, 0);
387        match tx_header.ordinal {
388            _ => Err(fidl::Error::UnknownOrdinal {
389                ordinal: tx_header.ordinal,
390                protocol_name: <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
391            }),
392        }
393    }
394}
395
396/// A Stream of incoming requests for fuchsia.hardware.serial/Device.
397pub struct DeviceRequestStream {
398    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
399    is_terminated: bool,
400}
401
402impl std::marker::Unpin for DeviceRequestStream {}
403
404impl futures::stream::FusedStream for DeviceRequestStream {
405    fn is_terminated(&self) -> bool {
406        self.is_terminated
407    }
408}
409
410impl fidl::endpoints::RequestStream for DeviceRequestStream {
411    type Protocol = DeviceMarker;
412    type ControlHandle = DeviceControlHandle;
413
414    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
415        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
416    }
417
418    fn control_handle(&self) -> Self::ControlHandle {
419        DeviceControlHandle { inner: self.inner.clone() }
420    }
421
422    fn into_inner(
423        self,
424    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
425    {
426        (self.inner, self.is_terminated)
427    }
428
429    fn from_inner(
430        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
431        is_terminated: bool,
432    ) -> Self {
433        Self { inner, is_terminated }
434    }
435}
436
437impl futures::Stream for DeviceRequestStream {
438    type Item = Result<DeviceRequest, fidl::Error>;
439
440    fn poll_next(
441        mut self: std::pin::Pin<&mut Self>,
442        cx: &mut std::task::Context<'_>,
443    ) -> std::task::Poll<Option<Self::Item>> {
444        let this = &mut *self;
445        if this.inner.check_shutdown(cx) {
446            this.is_terminated = true;
447            return std::task::Poll::Ready(None);
448        }
449        if this.is_terminated {
450            panic!("polled DeviceRequestStream after completion");
451        }
452        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
453            |bytes, handles| {
454                match this.inner.channel().read_etc(cx, bytes, handles) {
455                    std::task::Poll::Ready(Ok(())) => {}
456                    std::task::Poll::Pending => return std::task::Poll::Pending,
457                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
458                        this.is_terminated = true;
459                        return std::task::Poll::Ready(None);
460                    }
461                    std::task::Poll::Ready(Err(e)) => {
462                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
463                            e.into(),
464                        ))));
465                    }
466                }
467
468                // A message has been received from the channel
469                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
470
471                std::task::Poll::Ready(Some(match header.ordinal {
472                    0x3d48bbcee248ab8b => {
473                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
474                        let mut req = fidl::new_empty!(
475                            fidl::encoding::EmptyPayload,
476                            fidl::encoding::DefaultFuchsiaResourceDialect
477                        );
478                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
479                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
480                        Ok(DeviceRequest::GetClass {
481                            responder: DeviceGetClassResponder {
482                                control_handle: std::mem::ManuallyDrop::new(control_handle),
483                                tx_id: header.tx_id,
484                            },
485                        })
486                    }
487                    0x771a0946f6f87173 => {
488                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
489                        let mut req = fidl::new_empty!(
490                            DeviceSetConfigRequest,
491                            fidl::encoding::DefaultFuchsiaResourceDialect
492                        );
493                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceSetConfigRequest>(&header, _body_bytes, handles, &mut req)?;
494                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
495                        Ok(DeviceRequest::SetConfig {
496                            config: req.config,
497
498                            responder: DeviceSetConfigResponder {
499                                control_handle: std::mem::ManuallyDrop::new(control_handle),
500                                tx_id: header.tx_id,
501                            },
502                        })
503                    }
504                    0x63c41d3c053fadd8 => {
505                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
506                        let mut req = fidl::new_empty!(
507                            fidl::encoding::EmptyPayload,
508                            fidl::encoding::DefaultFuchsiaResourceDialect
509                        );
510                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
511                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
512                        Ok(DeviceRequest::Read {
513                            responder: DeviceReadResponder {
514                                control_handle: std::mem::ManuallyDrop::new(control_handle),
515                                tx_id: header.tx_id,
516                            },
517                        })
518                    }
519                    0x6aa7adae6841779c => {
520                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
521                        let mut req = fidl::new_empty!(
522                            DeviceWriteRequest,
523                            fidl::encoding::DefaultFuchsiaResourceDialect
524                        );
525                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceWriteRequest>(&header, _body_bytes, handles, &mut req)?;
526                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
527                        Ok(DeviceRequest::Write {
528                            data: req.data,
529
530                            responder: DeviceWriteResponder {
531                                control_handle: std::mem::ManuallyDrop::new(control_handle),
532                                tx_id: header.tx_id,
533                            },
534                        })
535                    }
536                    _ => Err(fidl::Error::UnknownOrdinal {
537                        ordinal: header.ordinal,
538                        protocol_name:
539                            <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
540                    }),
541                }))
542            },
543        )
544    }
545}
546
547/// A serial device.
548#[derive(Debug)]
549pub enum DeviceRequest {
550    /// Lookup what type of serial device this is.
551    GetClass { responder: DeviceGetClassResponder },
552    /// Set the configuration of this serial device.
553    SetConfig { config: Config, responder: DeviceSetConfigResponder },
554    /// Reads data from the serial port.
555    Read { responder: DeviceReadResponder },
556    /// Writes data to the serial port.
557    Write { data: Vec<u8>, responder: DeviceWriteResponder },
558}
559
560impl DeviceRequest {
561    #[allow(irrefutable_let_patterns)]
562    pub fn into_get_class(self) -> Option<(DeviceGetClassResponder)> {
563        if let DeviceRequest::GetClass { responder } = self { Some((responder)) } else { None }
564    }
565
566    #[allow(irrefutable_let_patterns)]
567    pub fn into_set_config(self) -> Option<(Config, DeviceSetConfigResponder)> {
568        if let DeviceRequest::SetConfig { config, responder } = self {
569            Some((config, responder))
570        } else {
571            None
572        }
573    }
574
575    #[allow(irrefutable_let_patterns)]
576    pub fn into_read(self) -> Option<(DeviceReadResponder)> {
577        if let DeviceRequest::Read { responder } = self { Some((responder)) } else { None }
578    }
579
580    #[allow(irrefutable_let_patterns)]
581    pub fn into_write(self) -> Option<(Vec<u8>, DeviceWriteResponder)> {
582        if let DeviceRequest::Write { data, responder } = self {
583            Some((data, responder))
584        } else {
585            None
586        }
587    }
588
589    /// Name of the method defined in FIDL
590    pub fn method_name(&self) -> &'static str {
591        match *self {
592            DeviceRequest::GetClass { .. } => "get_class",
593            DeviceRequest::SetConfig { .. } => "set_config",
594            DeviceRequest::Read { .. } => "read",
595            DeviceRequest::Write { .. } => "write",
596        }
597    }
598}
599
600#[derive(Debug, Clone)]
601pub struct DeviceControlHandle {
602    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
603}
604
605impl DeviceControlHandle {
606    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
607        self.inner.shutdown_with_epitaph(status.into())
608    }
609}
610
611impl fidl::endpoints::ControlHandle for DeviceControlHandle {
612    fn shutdown(&self) {
613        self.inner.shutdown()
614    }
615
616    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
617        self.inner.shutdown_with_epitaph(status)
618    }
619
620    fn is_closed(&self) -> bool {
621        self.inner.channel().is_closed()
622    }
623    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
624        self.inner.channel().on_closed()
625    }
626
627    #[cfg(target_os = "fuchsia")]
628    fn signal_peer(
629        &self,
630        clear_mask: zx::Signals,
631        set_mask: zx::Signals,
632    ) -> Result<(), zx_status::Status> {
633        use fidl::Peered;
634        self.inner.channel().signal_peer(clear_mask, set_mask)
635    }
636}
637
638impl DeviceControlHandle {}
639
640#[must_use = "FIDL methods require a response to be sent"]
641#[derive(Debug)]
642pub struct DeviceGetClassResponder {
643    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
644    tx_id: u32,
645}
646
647/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
648/// if the responder is dropped without sending a response, so that the client
649/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
650impl std::ops::Drop for DeviceGetClassResponder {
651    fn drop(&mut self) {
652        self.control_handle.shutdown();
653        // Safety: drops once, never accessed again
654        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
655    }
656}
657
658impl fidl::endpoints::Responder for DeviceGetClassResponder {
659    type ControlHandle = DeviceControlHandle;
660
661    fn control_handle(&self) -> &DeviceControlHandle {
662        &self.control_handle
663    }
664
665    fn drop_without_shutdown(mut self) {
666        // Safety: drops once, never accessed again due to mem::forget
667        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
668        // Prevent Drop from running (which would shut down the channel)
669        std::mem::forget(self);
670    }
671}
672
673impl DeviceGetClassResponder {
674    /// Sends a response to the FIDL transaction.
675    ///
676    /// Sets the channel to shutdown if an error occurs.
677    pub fn send(self, mut device_class: Class) -> Result<(), fidl::Error> {
678        let _result = self.send_raw(device_class);
679        if _result.is_err() {
680            self.control_handle.shutdown();
681        }
682        self.drop_without_shutdown();
683        _result
684    }
685
686    /// Similar to "send" but does not shutdown the channel if an error occurs.
687    pub fn send_no_shutdown_on_err(self, mut device_class: Class) -> Result<(), fidl::Error> {
688        let _result = self.send_raw(device_class);
689        self.drop_without_shutdown();
690        _result
691    }
692
693    fn send_raw(&self, mut device_class: Class) -> Result<(), fidl::Error> {
694        self.control_handle.inner.send::<DeviceGetClassResponse>(
695            (device_class,),
696            self.tx_id,
697            0x3d48bbcee248ab8b,
698            fidl::encoding::DynamicFlags::empty(),
699        )
700    }
701}
702
703#[must_use = "FIDL methods require a response to be sent"]
704#[derive(Debug)]
705pub struct DeviceSetConfigResponder {
706    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
707    tx_id: u32,
708}
709
710/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
711/// if the responder is dropped without sending a response, so that the client
712/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
713impl std::ops::Drop for DeviceSetConfigResponder {
714    fn drop(&mut self) {
715        self.control_handle.shutdown();
716        // Safety: drops once, never accessed again
717        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
718    }
719}
720
721impl fidl::endpoints::Responder for DeviceSetConfigResponder {
722    type ControlHandle = DeviceControlHandle;
723
724    fn control_handle(&self) -> &DeviceControlHandle {
725        &self.control_handle
726    }
727
728    fn drop_without_shutdown(mut self) {
729        // Safety: drops once, never accessed again due to mem::forget
730        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
731        // Prevent Drop from running (which would shut down the channel)
732        std::mem::forget(self);
733    }
734}
735
736impl DeviceSetConfigResponder {
737    /// Sends a response to the FIDL transaction.
738    ///
739    /// Sets the channel to shutdown if an error occurs.
740    pub fn send(self, mut s: i32) -> Result<(), fidl::Error> {
741        let _result = self.send_raw(s);
742        if _result.is_err() {
743            self.control_handle.shutdown();
744        }
745        self.drop_without_shutdown();
746        _result
747    }
748
749    /// Similar to "send" but does not shutdown the channel if an error occurs.
750    pub fn send_no_shutdown_on_err(self, mut s: i32) -> Result<(), fidl::Error> {
751        let _result = self.send_raw(s);
752        self.drop_without_shutdown();
753        _result
754    }
755
756    fn send_raw(&self, mut s: i32) -> Result<(), fidl::Error> {
757        self.control_handle.inner.send::<DeviceSetConfigResponse>(
758            (s,),
759            self.tx_id,
760            0x771a0946f6f87173,
761            fidl::encoding::DynamicFlags::empty(),
762        )
763    }
764}
765
766#[must_use = "FIDL methods require a response to be sent"]
767#[derive(Debug)]
768pub struct DeviceReadResponder {
769    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
770    tx_id: u32,
771}
772
773/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
774/// if the responder is dropped without sending a response, so that the client
775/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
776impl std::ops::Drop for DeviceReadResponder {
777    fn drop(&mut self) {
778        self.control_handle.shutdown();
779        // Safety: drops once, never accessed again
780        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
781    }
782}
783
784impl fidl::endpoints::Responder for DeviceReadResponder {
785    type ControlHandle = DeviceControlHandle;
786
787    fn control_handle(&self) -> &DeviceControlHandle {
788        &self.control_handle
789    }
790
791    fn drop_without_shutdown(mut self) {
792        // Safety: drops once, never accessed again due to mem::forget
793        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
794        // Prevent Drop from running (which would shut down the channel)
795        std::mem::forget(self);
796    }
797}
798
799impl DeviceReadResponder {
800    /// Sends a response to the FIDL transaction.
801    ///
802    /// Sets the channel to shutdown if an error occurs.
803    pub fn send(self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
804        let _result = self.send_raw(result);
805        if _result.is_err() {
806            self.control_handle.shutdown();
807        }
808        self.drop_without_shutdown();
809        _result
810    }
811
812    /// Similar to "send" but does not shutdown the channel if an error occurs.
813    pub fn send_no_shutdown_on_err(
814        self,
815        mut result: Result<&[u8], i32>,
816    ) -> Result<(), fidl::Error> {
817        let _result = self.send_raw(result);
818        self.drop_without_shutdown();
819        _result
820    }
821
822    fn send_raw(&self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
823        self.control_handle.inner.send::<fidl::encoding::ResultType<DeviceReadResponse, i32>>(
824            result.map(|data| (data,)),
825            self.tx_id,
826            0x63c41d3c053fadd8,
827            fidl::encoding::DynamicFlags::empty(),
828        )
829    }
830}
831
832#[must_use = "FIDL methods require a response to be sent"]
833#[derive(Debug)]
834pub struct DeviceWriteResponder {
835    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
836    tx_id: u32,
837}
838
839/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
840/// if the responder is dropped without sending a response, so that the client
841/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
842impl std::ops::Drop for DeviceWriteResponder {
843    fn drop(&mut self) {
844        self.control_handle.shutdown();
845        // Safety: drops once, never accessed again
846        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
847    }
848}
849
850impl fidl::endpoints::Responder for DeviceWriteResponder {
851    type ControlHandle = DeviceControlHandle;
852
853    fn control_handle(&self) -> &DeviceControlHandle {
854        &self.control_handle
855    }
856
857    fn drop_without_shutdown(mut self) {
858        // Safety: drops once, never accessed again due to mem::forget
859        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
860        // Prevent Drop from running (which would shut down the channel)
861        std::mem::forget(self);
862    }
863}
864
865impl DeviceWriteResponder {
866    /// Sends a response to the FIDL transaction.
867    ///
868    /// Sets the channel to shutdown if an error occurs.
869    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
870        let _result = self.send_raw(result);
871        if _result.is_err() {
872            self.control_handle.shutdown();
873        }
874        self.drop_without_shutdown();
875        _result
876    }
877
878    /// Similar to "send" but does not shutdown the channel if an error occurs.
879    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
880        let _result = self.send_raw(result);
881        self.drop_without_shutdown();
882        _result
883    }
884
885    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
886        self.control_handle
887            .inner
888            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
889                result,
890                self.tx_id,
891                0x6aa7adae6841779c,
892                fidl::encoding::DynamicFlags::empty(),
893            )
894    }
895}
896
897#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
898pub struct DeviceProxy_Marker;
899
900impl fidl::endpoints::ProtocolMarker for DeviceProxy_Marker {
901    type Proxy = DeviceProxy_Proxy;
902    type RequestStream = DeviceProxy_RequestStream;
903    #[cfg(target_os = "fuchsia")]
904    type SynchronousProxy = DeviceProxy_SynchronousProxy;
905
906    const DEBUG_NAME: &'static str = "fuchsia.hardware.serial.DeviceProxy";
907}
908impl fidl::endpoints::DiscoverableProtocolMarker for DeviceProxy_Marker {}
909
910pub trait DeviceProxy_ProxyInterface: Send + Sync {
911    fn r#get_channel(
912        &self,
913        req: fidl::endpoints::ServerEnd<DeviceMarker>,
914    ) -> Result<(), fidl::Error>;
915}
916#[derive(Debug)]
917#[cfg(target_os = "fuchsia")]
918pub struct DeviceProxy_SynchronousProxy {
919    client: fidl::client::sync::Client,
920}
921
922#[cfg(target_os = "fuchsia")]
923impl fidl::endpoints::SynchronousProxy for DeviceProxy_SynchronousProxy {
924    type Proxy = DeviceProxy_Proxy;
925    type Protocol = DeviceProxy_Marker;
926
927    fn from_channel(inner: fidl::Channel) -> Self {
928        Self::new(inner)
929    }
930
931    fn into_channel(self) -> fidl::Channel {
932        self.client.into_channel()
933    }
934
935    fn as_channel(&self) -> &fidl::Channel {
936        self.client.as_channel()
937    }
938}
939
940#[cfg(target_os = "fuchsia")]
941impl DeviceProxy_SynchronousProxy {
942    pub fn new(channel: fidl::Channel) -> Self {
943        Self { client: fidl::client::sync::Client::new(channel) }
944    }
945
946    pub fn into_channel(self) -> fidl::Channel {
947        self.client.into_channel()
948    }
949
950    /// Waits until an event arrives and returns it. It is safe for other
951    /// threads to make concurrent requests while waiting for an event.
952    pub fn wait_for_event(
953        &self,
954        deadline: zx::MonotonicInstant,
955    ) -> Result<DeviceProxy_Event, fidl::Error> {
956        DeviceProxy_Event::decode(self.client.wait_for_event::<DeviceProxy_Marker>(deadline)?)
957    }
958
959    pub fn r#get_channel(
960        &self,
961        mut req: fidl::endpoints::ServerEnd<DeviceMarker>,
962    ) -> Result<(), fidl::Error> {
963        self.client.send::<DeviceProxyGetChannelRequest>(
964            (req,),
965            0x580f1a3ef6c20fff,
966            fidl::encoding::DynamicFlags::empty(),
967        )
968    }
969}
970
971#[cfg(target_os = "fuchsia")]
972impl From<DeviceProxy_SynchronousProxy> for zx::NullableHandle {
973    fn from(value: DeviceProxy_SynchronousProxy) -> Self {
974        value.into_channel().into()
975    }
976}
977
978#[cfg(target_os = "fuchsia")]
979impl From<fidl::Channel> for DeviceProxy_SynchronousProxy {
980    fn from(value: fidl::Channel) -> Self {
981        Self::new(value)
982    }
983}
984
985#[cfg(target_os = "fuchsia")]
986impl fidl::endpoints::FromClient for DeviceProxy_SynchronousProxy {
987    type Protocol = DeviceProxy_Marker;
988
989    fn from_client(value: fidl::endpoints::ClientEnd<DeviceProxy_Marker>) -> Self {
990        Self::new(value.into_channel())
991    }
992}
993
994#[derive(Debug, Clone)]
995pub struct DeviceProxy_Proxy {
996    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
997}
998
999impl fidl::endpoints::Proxy for DeviceProxy_Proxy {
1000    type Protocol = DeviceProxy_Marker;
1001
1002    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1003        Self::new(inner)
1004    }
1005
1006    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1007        self.client.into_channel().map_err(|client| Self { client })
1008    }
1009
1010    fn as_channel(&self) -> &::fidl::AsyncChannel {
1011        self.client.as_channel()
1012    }
1013}
1014
1015impl DeviceProxy_Proxy {
1016    /// Create a new Proxy for fuchsia.hardware.serial/DeviceProxy.
1017    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1018        let protocol_name = <DeviceProxy_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1019        Self { client: fidl::client::Client::new(channel, protocol_name) }
1020    }
1021
1022    /// Get a Stream of events from the remote end of the protocol.
1023    ///
1024    /// # Panics
1025    ///
1026    /// Panics if the event stream was already taken.
1027    pub fn take_event_stream(&self) -> DeviceProxy_EventStream {
1028        DeviceProxy_EventStream { event_receiver: self.client.take_event_receiver() }
1029    }
1030
1031    pub fn r#get_channel(
1032        &self,
1033        mut req: fidl::endpoints::ServerEnd<DeviceMarker>,
1034    ) -> Result<(), fidl::Error> {
1035        DeviceProxy_ProxyInterface::r#get_channel(self, req)
1036    }
1037}
1038
1039impl DeviceProxy_ProxyInterface for DeviceProxy_Proxy {
1040    fn r#get_channel(
1041        &self,
1042        mut req: fidl::endpoints::ServerEnd<DeviceMarker>,
1043    ) -> Result<(), fidl::Error> {
1044        self.client.send::<DeviceProxyGetChannelRequest>(
1045            (req,),
1046            0x580f1a3ef6c20fff,
1047            fidl::encoding::DynamicFlags::empty(),
1048        )
1049    }
1050}
1051
1052pub struct DeviceProxy_EventStream {
1053    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1054}
1055
1056impl std::marker::Unpin for DeviceProxy_EventStream {}
1057
1058impl futures::stream::FusedStream for DeviceProxy_EventStream {
1059    fn is_terminated(&self) -> bool {
1060        self.event_receiver.is_terminated()
1061    }
1062}
1063
1064impl futures::Stream for DeviceProxy_EventStream {
1065    type Item = Result<DeviceProxy_Event, fidl::Error>;
1066
1067    fn poll_next(
1068        mut self: std::pin::Pin<&mut Self>,
1069        cx: &mut std::task::Context<'_>,
1070    ) -> std::task::Poll<Option<Self::Item>> {
1071        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1072            &mut self.event_receiver,
1073            cx
1074        )?) {
1075            Some(buf) => std::task::Poll::Ready(Some(DeviceProxy_Event::decode(buf))),
1076            None => std::task::Poll::Ready(None),
1077        }
1078    }
1079}
1080
1081#[derive(Debug)]
1082pub enum DeviceProxy_Event {}
1083
1084impl DeviceProxy_Event {
1085    /// Decodes a message buffer as a [`DeviceProxy_Event`].
1086    fn decode(
1087        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1088    ) -> Result<DeviceProxy_Event, fidl::Error> {
1089        let (bytes, _handles) = buf.split_mut();
1090        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1091        debug_assert_eq!(tx_header.tx_id, 0);
1092        match tx_header.ordinal {
1093            _ => Err(fidl::Error::UnknownOrdinal {
1094                ordinal: tx_header.ordinal,
1095                protocol_name: <DeviceProxy_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1096            }),
1097        }
1098    }
1099}
1100
1101/// A Stream of incoming requests for fuchsia.hardware.serial/DeviceProxy.
1102pub struct DeviceProxy_RequestStream {
1103    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1104    is_terminated: bool,
1105}
1106
1107impl std::marker::Unpin for DeviceProxy_RequestStream {}
1108
1109impl futures::stream::FusedStream for DeviceProxy_RequestStream {
1110    fn is_terminated(&self) -> bool {
1111        self.is_terminated
1112    }
1113}
1114
1115impl fidl::endpoints::RequestStream for DeviceProxy_RequestStream {
1116    type Protocol = DeviceProxy_Marker;
1117    type ControlHandle = DeviceProxy_ControlHandle;
1118
1119    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1120        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1121    }
1122
1123    fn control_handle(&self) -> Self::ControlHandle {
1124        DeviceProxy_ControlHandle { inner: self.inner.clone() }
1125    }
1126
1127    fn into_inner(
1128        self,
1129    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1130    {
1131        (self.inner, self.is_terminated)
1132    }
1133
1134    fn from_inner(
1135        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1136        is_terminated: bool,
1137    ) -> Self {
1138        Self { inner, is_terminated }
1139    }
1140}
1141
1142impl futures::Stream for DeviceProxy_RequestStream {
1143    type Item = Result<DeviceProxy_Request, fidl::Error>;
1144
1145    fn poll_next(
1146        mut self: std::pin::Pin<&mut Self>,
1147        cx: &mut std::task::Context<'_>,
1148    ) -> std::task::Poll<Option<Self::Item>> {
1149        let this = &mut *self;
1150        if this.inner.check_shutdown(cx) {
1151            this.is_terminated = true;
1152            return std::task::Poll::Ready(None);
1153        }
1154        if this.is_terminated {
1155            panic!("polled DeviceProxy_RequestStream after completion");
1156        }
1157        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1158            |bytes, handles| {
1159                match this.inner.channel().read_etc(cx, bytes, handles) {
1160                    std::task::Poll::Ready(Ok(())) => {}
1161                    std::task::Poll::Pending => return std::task::Poll::Pending,
1162                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1163                        this.is_terminated = true;
1164                        return std::task::Poll::Ready(None);
1165                    }
1166                    std::task::Poll::Ready(Err(e)) => {
1167                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1168                            e.into(),
1169                        ))));
1170                    }
1171                }
1172
1173                // A message has been received from the channel
1174                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1175
1176                std::task::Poll::Ready(Some(match header.ordinal {
1177                    0x580f1a3ef6c20fff => {
1178                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1179                        let mut req = fidl::new_empty!(
1180                            DeviceProxyGetChannelRequest,
1181                            fidl::encoding::DefaultFuchsiaResourceDialect
1182                        );
1183                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceProxyGetChannelRequest>(&header, _body_bytes, handles, &mut req)?;
1184                        let control_handle =
1185                            DeviceProxy_ControlHandle { inner: this.inner.clone() };
1186                        Ok(DeviceProxy_Request::GetChannel { req: req.req, control_handle })
1187                    }
1188                    _ => Err(fidl::Error::UnknownOrdinal {
1189                        ordinal: header.ordinal,
1190                        protocol_name:
1191                            <DeviceProxy_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1192                    }),
1193                }))
1194            },
1195        )
1196    }
1197}
1198
1199#[derive(Debug)]
1200pub enum DeviceProxy_Request {
1201    GetChannel {
1202        req: fidl::endpoints::ServerEnd<DeviceMarker>,
1203        control_handle: DeviceProxy_ControlHandle,
1204    },
1205}
1206
1207impl DeviceProxy_Request {
1208    #[allow(irrefutable_let_patterns)]
1209    pub fn into_get_channel(
1210        self,
1211    ) -> Option<(fidl::endpoints::ServerEnd<DeviceMarker>, DeviceProxy_ControlHandle)> {
1212        if let DeviceProxy_Request::GetChannel { req, control_handle } = self {
1213            Some((req, control_handle))
1214        } else {
1215            None
1216        }
1217    }
1218
1219    /// Name of the method defined in FIDL
1220    pub fn method_name(&self) -> &'static str {
1221        match *self {
1222            DeviceProxy_Request::GetChannel { .. } => "get_channel",
1223        }
1224    }
1225}
1226
1227#[derive(Debug, Clone)]
1228pub struct DeviceProxy_ControlHandle {
1229    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1230}
1231
1232impl DeviceProxy_ControlHandle {
1233    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1234        self.inner.shutdown_with_epitaph(status.into())
1235    }
1236}
1237
1238impl fidl::endpoints::ControlHandle for DeviceProxy_ControlHandle {
1239    fn shutdown(&self) {
1240        self.inner.shutdown()
1241    }
1242
1243    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1244        self.inner.shutdown_with_epitaph(status)
1245    }
1246
1247    fn is_closed(&self) -> bool {
1248        self.inner.channel().is_closed()
1249    }
1250    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1251        self.inner.channel().on_closed()
1252    }
1253
1254    #[cfg(target_os = "fuchsia")]
1255    fn signal_peer(
1256        &self,
1257        clear_mask: zx::Signals,
1258        set_mask: zx::Signals,
1259    ) -> Result<(), zx_status::Status> {
1260        use fidl::Peered;
1261        self.inner.channel().signal_peer(clear_mask, set_mask)
1262    }
1263}
1264
1265impl DeviceProxy_ControlHandle {}
1266
1267#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1268pub struct ServiceMarker;
1269
1270#[cfg(target_os = "fuchsia")]
1271impl fidl::endpoints::ServiceMarker for ServiceMarker {
1272    type Proxy = ServiceProxy;
1273    type Request = ServiceRequest;
1274    const SERVICE_NAME: &'static str = "fuchsia.hardware.serial.Service";
1275}
1276
1277/// A request for one of the member protocols of Service.
1278///
1279#[cfg(target_os = "fuchsia")]
1280pub enum ServiceRequest {
1281    Device(DeviceRequestStream),
1282}
1283
1284#[cfg(target_os = "fuchsia")]
1285impl fidl::endpoints::ServiceRequest for ServiceRequest {
1286    type Service = ServiceMarker;
1287
1288    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
1289        match name {
1290            "device" => Self::Device(
1291                <DeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
1292            ),
1293            _ => panic!("no such member protocol name for service Service"),
1294        }
1295    }
1296
1297    fn member_names() -> &'static [&'static str] {
1298        &["device"]
1299    }
1300}
1301#[cfg(target_os = "fuchsia")]
1302pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
1303
1304#[cfg(target_os = "fuchsia")]
1305impl fidl::endpoints::ServiceProxy for ServiceProxy {
1306    type Service = ServiceMarker;
1307
1308    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
1309        Self(opener)
1310    }
1311}
1312
1313#[cfg(target_os = "fuchsia")]
1314impl ServiceProxy {
1315    pub fn connect_to_device(&self) -> Result<DeviceProxy, fidl::Error> {
1316        let (proxy, server_end) = fidl::endpoints::create_proxy::<DeviceMarker>();
1317        self.connect_channel_to_device(server_end)?;
1318        Ok(proxy)
1319    }
1320
1321    /// Like `connect_to_device`, but returns a sync proxy.
1322    /// See [`Self::connect_to_device`] for more details.
1323    pub fn connect_to_device_sync(&self) -> Result<DeviceSynchronousProxy, fidl::Error> {
1324        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DeviceMarker>();
1325        self.connect_channel_to_device(server_end)?;
1326        Ok(proxy)
1327    }
1328
1329    /// Like `connect_to_device`, but accepts a server end.
1330    /// See [`Self::connect_to_device`] for more details.
1331    pub fn connect_channel_to_device(
1332        &self,
1333        server_end: fidl::endpoints::ServerEnd<DeviceMarker>,
1334    ) -> Result<(), fidl::Error> {
1335        self.0.open_member("device", server_end.into_channel())
1336    }
1337
1338    pub fn instance_name(&self) -> &str {
1339        self.0.instance_name()
1340    }
1341}
1342
1343mod internal {
1344    use super::*;
1345
1346    impl fidl::encoding::ResourceTypeMarker for DeviceProxyGetChannelRequest {
1347        type Borrowed<'a> = &'a mut Self;
1348        fn take_or_borrow<'a>(
1349            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1350        ) -> Self::Borrowed<'a> {
1351            value
1352        }
1353    }
1354
1355    unsafe impl fidl::encoding::TypeMarker for DeviceProxyGetChannelRequest {
1356        type Owned = Self;
1357
1358        #[inline(always)]
1359        fn inline_align(_context: fidl::encoding::Context) -> usize {
1360            4
1361        }
1362
1363        #[inline(always)]
1364        fn inline_size(_context: fidl::encoding::Context) -> usize {
1365            4
1366        }
1367    }
1368
1369    unsafe impl
1370        fidl::encoding::Encode<
1371            DeviceProxyGetChannelRequest,
1372            fidl::encoding::DefaultFuchsiaResourceDialect,
1373        > for &mut DeviceProxyGetChannelRequest
1374    {
1375        #[inline]
1376        unsafe fn encode(
1377            self,
1378            encoder: &mut fidl::encoding::Encoder<
1379                '_,
1380                fidl::encoding::DefaultFuchsiaResourceDialect,
1381            >,
1382            offset: usize,
1383            _depth: fidl::encoding::Depth,
1384        ) -> fidl::Result<()> {
1385            encoder.debug_check_bounds::<DeviceProxyGetChannelRequest>(offset);
1386            // Delegate to tuple encoding.
1387            fidl::encoding::Encode::<DeviceProxyGetChannelRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1388                (
1389                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.req),
1390                ),
1391                encoder, offset, _depth
1392            )
1393        }
1394    }
1395    unsafe impl<
1396        T0: fidl::encoding::Encode<
1397                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
1398                fidl::encoding::DefaultFuchsiaResourceDialect,
1399            >,
1400    >
1401        fidl::encoding::Encode<
1402            DeviceProxyGetChannelRequest,
1403            fidl::encoding::DefaultFuchsiaResourceDialect,
1404        > for (T0,)
1405    {
1406        #[inline]
1407        unsafe fn encode(
1408            self,
1409            encoder: &mut fidl::encoding::Encoder<
1410                '_,
1411                fidl::encoding::DefaultFuchsiaResourceDialect,
1412            >,
1413            offset: usize,
1414            depth: fidl::encoding::Depth,
1415        ) -> fidl::Result<()> {
1416            encoder.debug_check_bounds::<DeviceProxyGetChannelRequest>(offset);
1417            // Zero out padding regions. There's no need to apply masks
1418            // because the unmasked parts will be overwritten by fields.
1419            // Write the fields.
1420            self.0.encode(encoder, offset + 0, depth)?;
1421            Ok(())
1422        }
1423    }
1424
1425    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1426        for DeviceProxyGetChannelRequest
1427    {
1428        #[inline(always)]
1429        fn new_empty() -> Self {
1430            Self {
1431                req: fidl::new_empty!(
1432                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
1433                    fidl::encoding::DefaultFuchsiaResourceDialect
1434                ),
1435            }
1436        }
1437
1438        #[inline]
1439        unsafe fn decode(
1440            &mut self,
1441            decoder: &mut fidl::encoding::Decoder<
1442                '_,
1443                fidl::encoding::DefaultFuchsiaResourceDialect,
1444            >,
1445            offset: usize,
1446            _depth: fidl::encoding::Depth,
1447        ) -> fidl::Result<()> {
1448            decoder.debug_check_bounds::<Self>(offset);
1449            // Verify that padding bytes are zero.
1450            fidl::decode!(
1451                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
1452                fidl::encoding::DefaultFuchsiaResourceDialect,
1453                &mut self.req,
1454                decoder,
1455                offset + 0,
1456                _depth
1457            )?;
1458            Ok(())
1459        }
1460    }
1461}