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 fidl::endpoints::ControlHandle for DeviceControlHandle {
606    fn shutdown(&self) {
607        self.inner.shutdown()
608    }
609
610    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
611        self.inner.shutdown_with_epitaph(status)
612    }
613
614    fn is_closed(&self) -> bool {
615        self.inner.channel().is_closed()
616    }
617    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
618        self.inner.channel().on_closed()
619    }
620
621    #[cfg(target_os = "fuchsia")]
622    fn signal_peer(
623        &self,
624        clear_mask: zx::Signals,
625        set_mask: zx::Signals,
626    ) -> Result<(), zx_status::Status> {
627        use fidl::Peered;
628        self.inner.channel().signal_peer(clear_mask, set_mask)
629    }
630}
631
632impl DeviceControlHandle {}
633
634#[must_use = "FIDL methods require a response to be sent"]
635#[derive(Debug)]
636pub struct DeviceGetClassResponder {
637    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
638    tx_id: u32,
639}
640
641/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
642/// if the responder is dropped without sending a response, so that the client
643/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
644impl std::ops::Drop for DeviceGetClassResponder {
645    fn drop(&mut self) {
646        self.control_handle.shutdown();
647        // Safety: drops once, never accessed again
648        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
649    }
650}
651
652impl fidl::endpoints::Responder for DeviceGetClassResponder {
653    type ControlHandle = DeviceControlHandle;
654
655    fn control_handle(&self) -> &DeviceControlHandle {
656        &self.control_handle
657    }
658
659    fn drop_without_shutdown(mut self) {
660        // Safety: drops once, never accessed again due to mem::forget
661        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
662        // Prevent Drop from running (which would shut down the channel)
663        std::mem::forget(self);
664    }
665}
666
667impl DeviceGetClassResponder {
668    /// Sends a response to the FIDL transaction.
669    ///
670    /// Sets the channel to shutdown if an error occurs.
671    pub fn send(self, mut device_class: Class) -> Result<(), fidl::Error> {
672        let _result = self.send_raw(device_class);
673        if _result.is_err() {
674            self.control_handle.shutdown();
675        }
676        self.drop_without_shutdown();
677        _result
678    }
679
680    /// Similar to "send" but does not shutdown the channel if an error occurs.
681    pub fn send_no_shutdown_on_err(self, mut device_class: Class) -> Result<(), fidl::Error> {
682        let _result = self.send_raw(device_class);
683        self.drop_without_shutdown();
684        _result
685    }
686
687    fn send_raw(&self, mut device_class: Class) -> Result<(), fidl::Error> {
688        self.control_handle.inner.send::<DeviceGetClassResponse>(
689            (device_class,),
690            self.tx_id,
691            0x3d48bbcee248ab8b,
692            fidl::encoding::DynamicFlags::empty(),
693        )
694    }
695}
696
697#[must_use = "FIDL methods require a response to be sent"]
698#[derive(Debug)]
699pub struct DeviceSetConfigResponder {
700    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
701    tx_id: u32,
702}
703
704/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
705/// if the responder is dropped without sending a response, so that the client
706/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
707impl std::ops::Drop for DeviceSetConfigResponder {
708    fn drop(&mut self) {
709        self.control_handle.shutdown();
710        // Safety: drops once, never accessed again
711        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
712    }
713}
714
715impl fidl::endpoints::Responder for DeviceSetConfigResponder {
716    type ControlHandle = DeviceControlHandle;
717
718    fn control_handle(&self) -> &DeviceControlHandle {
719        &self.control_handle
720    }
721
722    fn drop_without_shutdown(mut self) {
723        // Safety: drops once, never accessed again due to mem::forget
724        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
725        // Prevent Drop from running (which would shut down the channel)
726        std::mem::forget(self);
727    }
728}
729
730impl DeviceSetConfigResponder {
731    /// Sends a response to the FIDL transaction.
732    ///
733    /// Sets the channel to shutdown if an error occurs.
734    pub fn send(self, mut s: i32) -> Result<(), fidl::Error> {
735        let _result = self.send_raw(s);
736        if _result.is_err() {
737            self.control_handle.shutdown();
738        }
739        self.drop_without_shutdown();
740        _result
741    }
742
743    /// Similar to "send" but does not shutdown the channel if an error occurs.
744    pub fn send_no_shutdown_on_err(self, mut s: i32) -> Result<(), fidl::Error> {
745        let _result = self.send_raw(s);
746        self.drop_without_shutdown();
747        _result
748    }
749
750    fn send_raw(&self, mut s: i32) -> Result<(), fidl::Error> {
751        self.control_handle.inner.send::<DeviceSetConfigResponse>(
752            (s,),
753            self.tx_id,
754            0x771a0946f6f87173,
755            fidl::encoding::DynamicFlags::empty(),
756        )
757    }
758}
759
760#[must_use = "FIDL methods require a response to be sent"]
761#[derive(Debug)]
762pub struct DeviceReadResponder {
763    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
764    tx_id: u32,
765}
766
767/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
768/// if the responder is dropped without sending a response, so that the client
769/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
770impl std::ops::Drop for DeviceReadResponder {
771    fn drop(&mut self) {
772        self.control_handle.shutdown();
773        // Safety: drops once, never accessed again
774        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
775    }
776}
777
778impl fidl::endpoints::Responder for DeviceReadResponder {
779    type ControlHandle = DeviceControlHandle;
780
781    fn control_handle(&self) -> &DeviceControlHandle {
782        &self.control_handle
783    }
784
785    fn drop_without_shutdown(mut self) {
786        // Safety: drops once, never accessed again due to mem::forget
787        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
788        // Prevent Drop from running (which would shut down the channel)
789        std::mem::forget(self);
790    }
791}
792
793impl DeviceReadResponder {
794    /// Sends a response to the FIDL transaction.
795    ///
796    /// Sets the channel to shutdown if an error occurs.
797    pub fn send(self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
798        let _result = self.send_raw(result);
799        if _result.is_err() {
800            self.control_handle.shutdown();
801        }
802        self.drop_without_shutdown();
803        _result
804    }
805
806    /// Similar to "send" but does not shutdown the channel if an error occurs.
807    pub fn send_no_shutdown_on_err(
808        self,
809        mut result: Result<&[u8], i32>,
810    ) -> Result<(), fidl::Error> {
811        let _result = self.send_raw(result);
812        self.drop_without_shutdown();
813        _result
814    }
815
816    fn send_raw(&self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
817        self.control_handle.inner.send::<fidl::encoding::ResultType<DeviceReadResponse, i32>>(
818            result.map(|data| (data,)),
819            self.tx_id,
820            0x63c41d3c053fadd8,
821            fidl::encoding::DynamicFlags::empty(),
822        )
823    }
824}
825
826#[must_use = "FIDL methods require a response to be sent"]
827#[derive(Debug)]
828pub struct DeviceWriteResponder {
829    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
830    tx_id: u32,
831}
832
833/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
834/// if the responder is dropped without sending a response, so that the client
835/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
836impl std::ops::Drop for DeviceWriteResponder {
837    fn drop(&mut self) {
838        self.control_handle.shutdown();
839        // Safety: drops once, never accessed again
840        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
841    }
842}
843
844impl fidl::endpoints::Responder for DeviceWriteResponder {
845    type ControlHandle = DeviceControlHandle;
846
847    fn control_handle(&self) -> &DeviceControlHandle {
848        &self.control_handle
849    }
850
851    fn drop_without_shutdown(mut self) {
852        // Safety: drops once, never accessed again due to mem::forget
853        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
854        // Prevent Drop from running (which would shut down the channel)
855        std::mem::forget(self);
856    }
857}
858
859impl DeviceWriteResponder {
860    /// Sends a response to the FIDL transaction.
861    ///
862    /// Sets the channel to shutdown if an error occurs.
863    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
864        let _result = self.send_raw(result);
865        if _result.is_err() {
866            self.control_handle.shutdown();
867        }
868        self.drop_without_shutdown();
869        _result
870    }
871
872    /// Similar to "send" but does not shutdown the channel if an error occurs.
873    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
874        let _result = self.send_raw(result);
875        self.drop_without_shutdown();
876        _result
877    }
878
879    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
880        self.control_handle
881            .inner
882            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
883                result,
884                self.tx_id,
885                0x6aa7adae6841779c,
886                fidl::encoding::DynamicFlags::empty(),
887            )
888    }
889}
890
891#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
892pub struct DeviceProxy_Marker;
893
894impl fidl::endpoints::ProtocolMarker for DeviceProxy_Marker {
895    type Proxy = DeviceProxy_Proxy;
896    type RequestStream = DeviceProxy_RequestStream;
897    #[cfg(target_os = "fuchsia")]
898    type SynchronousProxy = DeviceProxy_SynchronousProxy;
899
900    const DEBUG_NAME: &'static str = "fuchsia.hardware.serial.DeviceProxy";
901}
902impl fidl::endpoints::DiscoverableProtocolMarker for DeviceProxy_Marker {}
903
904pub trait DeviceProxy_ProxyInterface: Send + Sync {
905    fn r#get_channel(
906        &self,
907        req: fidl::endpoints::ServerEnd<DeviceMarker>,
908    ) -> Result<(), fidl::Error>;
909}
910#[derive(Debug)]
911#[cfg(target_os = "fuchsia")]
912pub struct DeviceProxy_SynchronousProxy {
913    client: fidl::client::sync::Client,
914}
915
916#[cfg(target_os = "fuchsia")]
917impl fidl::endpoints::SynchronousProxy for DeviceProxy_SynchronousProxy {
918    type Proxy = DeviceProxy_Proxy;
919    type Protocol = DeviceProxy_Marker;
920
921    fn from_channel(inner: fidl::Channel) -> Self {
922        Self::new(inner)
923    }
924
925    fn into_channel(self) -> fidl::Channel {
926        self.client.into_channel()
927    }
928
929    fn as_channel(&self) -> &fidl::Channel {
930        self.client.as_channel()
931    }
932}
933
934#[cfg(target_os = "fuchsia")]
935impl DeviceProxy_SynchronousProxy {
936    pub fn new(channel: fidl::Channel) -> Self {
937        Self { client: fidl::client::sync::Client::new(channel) }
938    }
939
940    pub fn into_channel(self) -> fidl::Channel {
941        self.client.into_channel()
942    }
943
944    /// Waits until an event arrives and returns it. It is safe for other
945    /// threads to make concurrent requests while waiting for an event.
946    pub fn wait_for_event(
947        &self,
948        deadline: zx::MonotonicInstant,
949    ) -> Result<DeviceProxy_Event, fidl::Error> {
950        DeviceProxy_Event::decode(self.client.wait_for_event::<DeviceProxy_Marker>(deadline)?)
951    }
952
953    pub fn r#get_channel(
954        &self,
955        mut req: fidl::endpoints::ServerEnd<DeviceMarker>,
956    ) -> Result<(), fidl::Error> {
957        self.client.send::<DeviceProxyGetChannelRequest>(
958            (req,),
959            0x580f1a3ef6c20fff,
960            fidl::encoding::DynamicFlags::empty(),
961        )
962    }
963}
964
965#[cfg(target_os = "fuchsia")]
966impl From<DeviceProxy_SynchronousProxy> for zx::NullableHandle {
967    fn from(value: DeviceProxy_SynchronousProxy) -> Self {
968        value.into_channel().into()
969    }
970}
971
972#[cfg(target_os = "fuchsia")]
973impl From<fidl::Channel> for DeviceProxy_SynchronousProxy {
974    fn from(value: fidl::Channel) -> Self {
975        Self::new(value)
976    }
977}
978
979#[cfg(target_os = "fuchsia")]
980impl fidl::endpoints::FromClient for DeviceProxy_SynchronousProxy {
981    type Protocol = DeviceProxy_Marker;
982
983    fn from_client(value: fidl::endpoints::ClientEnd<DeviceProxy_Marker>) -> Self {
984        Self::new(value.into_channel())
985    }
986}
987
988#[derive(Debug, Clone)]
989pub struct DeviceProxy_Proxy {
990    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
991}
992
993impl fidl::endpoints::Proxy for DeviceProxy_Proxy {
994    type Protocol = DeviceProxy_Marker;
995
996    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
997        Self::new(inner)
998    }
999
1000    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1001        self.client.into_channel().map_err(|client| Self { client })
1002    }
1003
1004    fn as_channel(&self) -> &::fidl::AsyncChannel {
1005        self.client.as_channel()
1006    }
1007}
1008
1009impl DeviceProxy_Proxy {
1010    /// Create a new Proxy for fuchsia.hardware.serial/DeviceProxy.
1011    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1012        let protocol_name = <DeviceProxy_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1013        Self { client: fidl::client::Client::new(channel, protocol_name) }
1014    }
1015
1016    /// Get a Stream of events from the remote end of the protocol.
1017    ///
1018    /// # Panics
1019    ///
1020    /// Panics if the event stream was already taken.
1021    pub fn take_event_stream(&self) -> DeviceProxy_EventStream {
1022        DeviceProxy_EventStream { event_receiver: self.client.take_event_receiver() }
1023    }
1024
1025    pub fn r#get_channel(
1026        &self,
1027        mut req: fidl::endpoints::ServerEnd<DeviceMarker>,
1028    ) -> Result<(), fidl::Error> {
1029        DeviceProxy_ProxyInterface::r#get_channel(self, req)
1030    }
1031}
1032
1033impl DeviceProxy_ProxyInterface for DeviceProxy_Proxy {
1034    fn r#get_channel(
1035        &self,
1036        mut req: fidl::endpoints::ServerEnd<DeviceMarker>,
1037    ) -> Result<(), fidl::Error> {
1038        self.client.send::<DeviceProxyGetChannelRequest>(
1039            (req,),
1040            0x580f1a3ef6c20fff,
1041            fidl::encoding::DynamicFlags::empty(),
1042        )
1043    }
1044}
1045
1046pub struct DeviceProxy_EventStream {
1047    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1048}
1049
1050impl std::marker::Unpin for DeviceProxy_EventStream {}
1051
1052impl futures::stream::FusedStream for DeviceProxy_EventStream {
1053    fn is_terminated(&self) -> bool {
1054        self.event_receiver.is_terminated()
1055    }
1056}
1057
1058impl futures::Stream for DeviceProxy_EventStream {
1059    type Item = Result<DeviceProxy_Event, fidl::Error>;
1060
1061    fn poll_next(
1062        mut self: std::pin::Pin<&mut Self>,
1063        cx: &mut std::task::Context<'_>,
1064    ) -> std::task::Poll<Option<Self::Item>> {
1065        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1066            &mut self.event_receiver,
1067            cx
1068        )?) {
1069            Some(buf) => std::task::Poll::Ready(Some(DeviceProxy_Event::decode(buf))),
1070            None => std::task::Poll::Ready(None),
1071        }
1072    }
1073}
1074
1075#[derive(Debug)]
1076pub enum DeviceProxy_Event {}
1077
1078impl DeviceProxy_Event {
1079    /// Decodes a message buffer as a [`DeviceProxy_Event`].
1080    fn decode(
1081        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1082    ) -> Result<DeviceProxy_Event, fidl::Error> {
1083        let (bytes, _handles) = buf.split_mut();
1084        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1085        debug_assert_eq!(tx_header.tx_id, 0);
1086        match tx_header.ordinal {
1087            _ => Err(fidl::Error::UnknownOrdinal {
1088                ordinal: tx_header.ordinal,
1089                protocol_name: <DeviceProxy_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1090            }),
1091        }
1092    }
1093}
1094
1095/// A Stream of incoming requests for fuchsia.hardware.serial/DeviceProxy.
1096pub struct DeviceProxy_RequestStream {
1097    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1098    is_terminated: bool,
1099}
1100
1101impl std::marker::Unpin for DeviceProxy_RequestStream {}
1102
1103impl futures::stream::FusedStream for DeviceProxy_RequestStream {
1104    fn is_terminated(&self) -> bool {
1105        self.is_terminated
1106    }
1107}
1108
1109impl fidl::endpoints::RequestStream for DeviceProxy_RequestStream {
1110    type Protocol = DeviceProxy_Marker;
1111    type ControlHandle = DeviceProxy_ControlHandle;
1112
1113    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1114        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1115    }
1116
1117    fn control_handle(&self) -> Self::ControlHandle {
1118        DeviceProxy_ControlHandle { inner: self.inner.clone() }
1119    }
1120
1121    fn into_inner(
1122        self,
1123    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1124    {
1125        (self.inner, self.is_terminated)
1126    }
1127
1128    fn from_inner(
1129        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1130        is_terminated: bool,
1131    ) -> Self {
1132        Self { inner, is_terminated }
1133    }
1134}
1135
1136impl futures::Stream for DeviceProxy_RequestStream {
1137    type Item = Result<DeviceProxy_Request, fidl::Error>;
1138
1139    fn poll_next(
1140        mut self: std::pin::Pin<&mut Self>,
1141        cx: &mut std::task::Context<'_>,
1142    ) -> std::task::Poll<Option<Self::Item>> {
1143        let this = &mut *self;
1144        if this.inner.check_shutdown(cx) {
1145            this.is_terminated = true;
1146            return std::task::Poll::Ready(None);
1147        }
1148        if this.is_terminated {
1149            panic!("polled DeviceProxy_RequestStream after completion");
1150        }
1151        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1152            |bytes, handles| {
1153                match this.inner.channel().read_etc(cx, bytes, handles) {
1154                    std::task::Poll::Ready(Ok(())) => {}
1155                    std::task::Poll::Pending => return std::task::Poll::Pending,
1156                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1157                        this.is_terminated = true;
1158                        return std::task::Poll::Ready(None);
1159                    }
1160                    std::task::Poll::Ready(Err(e)) => {
1161                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1162                            e.into(),
1163                        ))));
1164                    }
1165                }
1166
1167                // A message has been received from the channel
1168                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1169
1170                std::task::Poll::Ready(Some(match header.ordinal {
1171                    0x580f1a3ef6c20fff => {
1172                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1173                        let mut req = fidl::new_empty!(
1174                            DeviceProxyGetChannelRequest,
1175                            fidl::encoding::DefaultFuchsiaResourceDialect
1176                        );
1177                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceProxyGetChannelRequest>(&header, _body_bytes, handles, &mut req)?;
1178                        let control_handle =
1179                            DeviceProxy_ControlHandle { inner: this.inner.clone() };
1180                        Ok(DeviceProxy_Request::GetChannel { req: req.req, control_handle })
1181                    }
1182                    _ => Err(fidl::Error::UnknownOrdinal {
1183                        ordinal: header.ordinal,
1184                        protocol_name:
1185                            <DeviceProxy_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1186                    }),
1187                }))
1188            },
1189        )
1190    }
1191}
1192
1193#[derive(Debug)]
1194pub enum DeviceProxy_Request {
1195    GetChannel {
1196        req: fidl::endpoints::ServerEnd<DeviceMarker>,
1197        control_handle: DeviceProxy_ControlHandle,
1198    },
1199}
1200
1201impl DeviceProxy_Request {
1202    #[allow(irrefutable_let_patterns)]
1203    pub fn into_get_channel(
1204        self,
1205    ) -> Option<(fidl::endpoints::ServerEnd<DeviceMarker>, DeviceProxy_ControlHandle)> {
1206        if let DeviceProxy_Request::GetChannel { req, control_handle } = self {
1207            Some((req, control_handle))
1208        } else {
1209            None
1210        }
1211    }
1212
1213    /// Name of the method defined in FIDL
1214    pub fn method_name(&self) -> &'static str {
1215        match *self {
1216            DeviceProxy_Request::GetChannel { .. } => "get_channel",
1217        }
1218    }
1219}
1220
1221#[derive(Debug, Clone)]
1222pub struct DeviceProxy_ControlHandle {
1223    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1224}
1225
1226impl fidl::endpoints::ControlHandle for DeviceProxy_ControlHandle {
1227    fn shutdown(&self) {
1228        self.inner.shutdown()
1229    }
1230
1231    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1232        self.inner.shutdown_with_epitaph(status)
1233    }
1234
1235    fn is_closed(&self) -> bool {
1236        self.inner.channel().is_closed()
1237    }
1238    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1239        self.inner.channel().on_closed()
1240    }
1241
1242    #[cfg(target_os = "fuchsia")]
1243    fn signal_peer(
1244        &self,
1245        clear_mask: zx::Signals,
1246        set_mask: zx::Signals,
1247    ) -> Result<(), zx_status::Status> {
1248        use fidl::Peered;
1249        self.inner.channel().signal_peer(clear_mask, set_mask)
1250    }
1251}
1252
1253impl DeviceProxy_ControlHandle {}
1254
1255#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1256pub struct ServiceMarker;
1257
1258#[cfg(target_os = "fuchsia")]
1259impl fidl::endpoints::ServiceMarker for ServiceMarker {
1260    type Proxy = ServiceProxy;
1261    type Request = ServiceRequest;
1262    const SERVICE_NAME: &'static str = "fuchsia.hardware.serial.Service";
1263}
1264
1265/// A request for one of the member protocols of Service.
1266///
1267#[cfg(target_os = "fuchsia")]
1268pub enum ServiceRequest {
1269    Device(DeviceRequestStream),
1270}
1271
1272#[cfg(target_os = "fuchsia")]
1273impl fidl::endpoints::ServiceRequest for ServiceRequest {
1274    type Service = ServiceMarker;
1275
1276    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
1277        match name {
1278            "device" => Self::Device(
1279                <DeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
1280            ),
1281            _ => panic!("no such member protocol name for service Service"),
1282        }
1283    }
1284
1285    fn member_names() -> &'static [&'static str] {
1286        &["device"]
1287    }
1288}
1289#[cfg(target_os = "fuchsia")]
1290pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
1291
1292#[cfg(target_os = "fuchsia")]
1293impl fidl::endpoints::ServiceProxy for ServiceProxy {
1294    type Service = ServiceMarker;
1295
1296    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
1297        Self(opener)
1298    }
1299}
1300
1301#[cfg(target_os = "fuchsia")]
1302impl ServiceProxy {
1303    pub fn connect_to_device(&self) -> Result<DeviceProxy, fidl::Error> {
1304        let (proxy, server_end) = fidl::endpoints::create_proxy::<DeviceMarker>();
1305        self.connect_channel_to_device(server_end)?;
1306        Ok(proxy)
1307    }
1308
1309    /// Like `connect_to_device`, but returns a sync proxy.
1310    /// See [`Self::connect_to_device`] for more details.
1311    pub fn connect_to_device_sync(&self) -> Result<DeviceSynchronousProxy, fidl::Error> {
1312        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DeviceMarker>();
1313        self.connect_channel_to_device(server_end)?;
1314        Ok(proxy)
1315    }
1316
1317    /// Like `connect_to_device`, but accepts a server end.
1318    /// See [`Self::connect_to_device`] for more details.
1319    pub fn connect_channel_to_device(
1320        &self,
1321        server_end: fidl::endpoints::ServerEnd<DeviceMarker>,
1322    ) -> Result<(), fidl::Error> {
1323        self.0.open_member("device", server_end.into_channel())
1324    }
1325
1326    pub fn instance_name(&self) -> &str {
1327        self.0.instance_name()
1328    }
1329}
1330
1331mod internal {
1332    use super::*;
1333
1334    impl fidl::encoding::ResourceTypeMarker for DeviceProxyGetChannelRequest {
1335        type Borrowed<'a> = &'a mut Self;
1336        fn take_or_borrow<'a>(
1337            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1338        ) -> Self::Borrowed<'a> {
1339            value
1340        }
1341    }
1342
1343    unsafe impl fidl::encoding::TypeMarker for DeviceProxyGetChannelRequest {
1344        type Owned = Self;
1345
1346        #[inline(always)]
1347        fn inline_align(_context: fidl::encoding::Context) -> usize {
1348            4
1349        }
1350
1351        #[inline(always)]
1352        fn inline_size(_context: fidl::encoding::Context) -> usize {
1353            4
1354        }
1355    }
1356
1357    unsafe impl
1358        fidl::encoding::Encode<
1359            DeviceProxyGetChannelRequest,
1360            fidl::encoding::DefaultFuchsiaResourceDialect,
1361        > for &mut DeviceProxyGetChannelRequest
1362    {
1363        #[inline]
1364        unsafe fn encode(
1365            self,
1366            encoder: &mut fidl::encoding::Encoder<
1367                '_,
1368                fidl::encoding::DefaultFuchsiaResourceDialect,
1369            >,
1370            offset: usize,
1371            _depth: fidl::encoding::Depth,
1372        ) -> fidl::Result<()> {
1373            encoder.debug_check_bounds::<DeviceProxyGetChannelRequest>(offset);
1374            // Delegate to tuple encoding.
1375            fidl::encoding::Encode::<DeviceProxyGetChannelRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1376                (
1377                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.req),
1378                ),
1379                encoder, offset, _depth
1380            )
1381        }
1382    }
1383    unsafe impl<
1384        T0: fidl::encoding::Encode<
1385                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
1386                fidl::encoding::DefaultFuchsiaResourceDialect,
1387            >,
1388    >
1389        fidl::encoding::Encode<
1390            DeviceProxyGetChannelRequest,
1391            fidl::encoding::DefaultFuchsiaResourceDialect,
1392        > for (T0,)
1393    {
1394        #[inline]
1395        unsafe fn encode(
1396            self,
1397            encoder: &mut fidl::encoding::Encoder<
1398                '_,
1399                fidl::encoding::DefaultFuchsiaResourceDialect,
1400            >,
1401            offset: usize,
1402            depth: fidl::encoding::Depth,
1403        ) -> fidl::Result<()> {
1404            encoder.debug_check_bounds::<DeviceProxyGetChannelRequest>(offset);
1405            // Zero out padding regions. There's no need to apply masks
1406            // because the unmasked parts will be overwritten by fields.
1407            // Write the fields.
1408            self.0.encode(encoder, offset + 0, depth)?;
1409            Ok(())
1410        }
1411    }
1412
1413    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1414        for DeviceProxyGetChannelRequest
1415    {
1416        #[inline(always)]
1417        fn new_empty() -> Self {
1418            Self {
1419                req: fidl::new_empty!(
1420                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
1421                    fidl::encoding::DefaultFuchsiaResourceDialect
1422                ),
1423            }
1424        }
1425
1426        #[inline]
1427        unsafe fn decode(
1428            &mut self,
1429            decoder: &mut fidl::encoding::Decoder<
1430                '_,
1431                fidl::encoding::DefaultFuchsiaResourceDialect,
1432            >,
1433            offset: usize,
1434            _depth: fidl::encoding::Depth,
1435        ) -> fidl::Result<()> {
1436            decoder.debug_check_bounds::<Self>(offset);
1437            // Verify that padding bytes are zero.
1438            fidl::decode!(
1439                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
1440                fidl::encoding::DefaultFuchsiaResourceDialect,
1441                &mut self.req,
1442                decoder,
1443                offset + 0,
1444                _depth
1445            )?;
1446            Ok(())
1447        }
1448    }
1449}