fidl_fuchsia_bluetooth/
fidl_fuchsia_bluetooth.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_bluetooth_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct ChannelMarker;
16
17impl fidl::endpoints::ProtocolMarker for ChannelMarker {
18    type Proxy = ChannelProxy;
19    type RequestStream = ChannelRequestStream;
20    #[cfg(target_os = "fuchsia")]
21    type SynchronousProxy = ChannelSynchronousProxy;
22
23    const DEBUG_NAME: &'static str = "(anonymous) Channel";
24}
25
26pub trait ChannelProxyInterface: Send + Sync {
27    type Send_ResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
28    fn r#send_(&self, packets: &[Packet]) -> Self::Send_ResponseFut;
29    type ReceiveResponseFut: std::future::Future<Output = Result<Vec<Packet>, fidl::Error>> + Send;
30    fn r#receive(&self) -> Self::ReceiveResponseFut;
31    type WatchChannelParametersResponseFut: std::future::Future<Output = Result<ChannelParameters, fidl::Error>>
32        + Send;
33    fn r#watch_channel_parameters(&self) -> Self::WatchChannelParametersResponseFut;
34}
35#[derive(Debug)]
36#[cfg(target_os = "fuchsia")]
37pub struct ChannelSynchronousProxy {
38    client: fidl::client::sync::Client,
39}
40
41#[cfg(target_os = "fuchsia")]
42impl fidl::endpoints::SynchronousProxy for ChannelSynchronousProxy {
43    type Proxy = ChannelProxy;
44    type Protocol = ChannelMarker;
45
46    fn from_channel(inner: fidl::Channel) -> Self {
47        Self::new(inner)
48    }
49
50    fn into_channel(self) -> fidl::Channel {
51        self.client.into_channel()
52    }
53
54    fn as_channel(&self) -> &fidl::Channel {
55        self.client.as_channel()
56    }
57}
58
59#[cfg(target_os = "fuchsia")]
60impl ChannelSynchronousProxy {
61    pub fn new(channel: fidl::Channel) -> Self {
62        let protocol_name = <ChannelMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
63        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
64    }
65
66    pub fn into_channel(self) -> fidl::Channel {
67        self.client.into_channel()
68    }
69
70    /// Waits until an event arrives and returns it. It is safe for other
71    /// threads to make concurrent requests while waiting for an event.
72    pub fn wait_for_event(
73        &self,
74        deadline: zx::MonotonicInstant,
75    ) -> Result<ChannelEvent, fidl::Error> {
76        ChannelEvent::decode(self.client.wait_for_event(deadline)?)
77    }
78
79    /// Send multiple packets of data over the channel. Only one `Send`
80    /// may be pending at a time.
81    pub fn r#send_(
82        &self,
83        mut packets: &[Packet],
84        ___deadline: zx::MonotonicInstant,
85    ) -> Result<(), fidl::Error> {
86        let _response = self.client.send_query::<
87            ChannelSendRequest,
88            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
89        >(
90            (packets,),
91            0x6fc4419c2e763324,
92            fidl::encoding::DynamicFlags::FLEXIBLE,
93            ___deadline,
94        )?
95        .into_result::<ChannelMarker>("send_")?;
96        Ok(_response)
97    }
98
99    /// Hanging get that waits for inbound packets. Only one `Receive`
100    /// may be pending at a time.
101    pub fn r#receive(&self, ___deadline: zx::MonotonicInstant) -> Result<Vec<Packet>, fidl::Error> {
102        let _response = self.client.send_query::<
103            fidl::encoding::EmptyPayload,
104            fidl::encoding::FlexibleType<ChannelReceiveResponse>,
105        >(
106            (),
107            0x3498d7bdb7cdbfd4,
108            fidl::encoding::DynamicFlags::FLEXIBLE,
109            ___deadline,
110        )?
111        .into_result::<ChannelMarker>("receive")?;
112        Ok(_response.packets)
113    }
114
115    /// For RFCOMM channels, this will not return and calls will hang
116    /// indefinitely.
117    ///
118    /// For BR/EDR L2CAP connection-oriented channels this will currently not
119    /// return and calls will hang indefinitely. The initial channel parameters
120    /// are provided in [`fuchsia.bluetooth.bredr/Channel`].
121    ///
122    /// For LE L2CAP connection-oriented channels, the first call will
123    /// immediately return the parameters of the remote side of the channel.
124    /// Subsequent calls will hang until the [`ChannelParameters`] change, at
125    /// which point it will return the new parameters, including those that have
126    /// not changed.
127    pub fn r#watch_channel_parameters(
128        &self,
129        ___deadline: zx::MonotonicInstant,
130    ) -> Result<ChannelParameters, fidl::Error> {
131        let _response = self.client.send_query::<
132            fidl::encoding::EmptyPayload,
133            fidl::encoding::FlexibleType<ChannelParameters>,
134        >(
135            (),
136            0x5a0cec81d5076c12,
137            fidl::encoding::DynamicFlags::FLEXIBLE,
138            ___deadline,
139        )?
140        .into_result::<ChannelMarker>("watch_channel_parameters")?;
141        Ok(_response)
142    }
143}
144
145#[cfg(target_os = "fuchsia")]
146impl From<ChannelSynchronousProxy> for zx::Handle {
147    fn from(value: ChannelSynchronousProxy) -> Self {
148        value.into_channel().into()
149    }
150}
151
152#[cfg(target_os = "fuchsia")]
153impl From<fidl::Channel> for ChannelSynchronousProxy {
154    fn from(value: fidl::Channel) -> Self {
155        Self::new(value)
156    }
157}
158
159#[derive(Debug, Clone)]
160pub struct ChannelProxy {
161    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
162}
163
164impl fidl::endpoints::Proxy for ChannelProxy {
165    type Protocol = ChannelMarker;
166
167    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
168        Self::new(inner)
169    }
170
171    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
172        self.client.into_channel().map_err(|client| Self { client })
173    }
174
175    fn as_channel(&self) -> &::fidl::AsyncChannel {
176        self.client.as_channel()
177    }
178}
179
180impl ChannelProxy {
181    /// Create a new Proxy for fuchsia.bluetooth/Channel.
182    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
183        let protocol_name = <ChannelMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
184        Self { client: fidl::client::Client::new(channel, protocol_name) }
185    }
186
187    /// Get a Stream of events from the remote end of the protocol.
188    ///
189    /// # Panics
190    ///
191    /// Panics if the event stream was already taken.
192    pub fn take_event_stream(&self) -> ChannelEventStream {
193        ChannelEventStream { event_receiver: self.client.take_event_receiver() }
194    }
195
196    /// Send multiple packets of data over the channel. Only one `Send`
197    /// may be pending at a time.
198    pub fn r#send_(
199        &self,
200        mut packets: &[Packet],
201    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
202        ChannelProxyInterface::r#send_(self, packets)
203    }
204
205    /// Hanging get that waits for inbound packets. Only one `Receive`
206    /// may be pending at a time.
207    pub fn r#receive(
208        &self,
209    ) -> fidl::client::QueryResponseFut<Vec<Packet>, fidl::encoding::DefaultFuchsiaResourceDialect>
210    {
211        ChannelProxyInterface::r#receive(self)
212    }
213
214    /// For RFCOMM channels, this will not return and calls will hang
215    /// indefinitely.
216    ///
217    /// For BR/EDR L2CAP connection-oriented channels this will currently not
218    /// return and calls will hang indefinitely. The initial channel parameters
219    /// are provided in [`fuchsia.bluetooth.bredr/Channel`].
220    ///
221    /// For LE L2CAP connection-oriented channels, the first call will
222    /// immediately return the parameters of the remote side of the channel.
223    /// Subsequent calls will hang until the [`ChannelParameters`] change, at
224    /// which point it will return the new parameters, including those that have
225    /// not changed.
226    pub fn r#watch_channel_parameters(
227        &self,
228    ) -> fidl::client::QueryResponseFut<
229        ChannelParameters,
230        fidl::encoding::DefaultFuchsiaResourceDialect,
231    > {
232        ChannelProxyInterface::r#watch_channel_parameters(self)
233    }
234}
235
236impl ChannelProxyInterface for ChannelProxy {
237    type Send_ResponseFut =
238        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
239    fn r#send_(&self, mut packets: &[Packet]) -> Self::Send_ResponseFut {
240        fn _decode(
241            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
242        ) -> Result<(), fidl::Error> {
243            let _response = fidl::client::decode_transaction_body::<
244                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
245                fidl::encoding::DefaultFuchsiaResourceDialect,
246                0x6fc4419c2e763324,
247            >(_buf?)?
248            .into_result::<ChannelMarker>("send_")?;
249            Ok(_response)
250        }
251        self.client.send_query_and_decode::<ChannelSendRequest, ()>(
252            (packets,),
253            0x6fc4419c2e763324,
254            fidl::encoding::DynamicFlags::FLEXIBLE,
255            _decode,
256        )
257    }
258
259    type ReceiveResponseFut =
260        fidl::client::QueryResponseFut<Vec<Packet>, fidl::encoding::DefaultFuchsiaResourceDialect>;
261    fn r#receive(&self) -> Self::ReceiveResponseFut {
262        fn _decode(
263            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
264        ) -> Result<Vec<Packet>, fidl::Error> {
265            let _response = fidl::client::decode_transaction_body::<
266                fidl::encoding::FlexibleType<ChannelReceiveResponse>,
267                fidl::encoding::DefaultFuchsiaResourceDialect,
268                0x3498d7bdb7cdbfd4,
269            >(_buf?)?
270            .into_result::<ChannelMarker>("receive")?;
271            Ok(_response.packets)
272        }
273        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<Packet>>(
274            (),
275            0x3498d7bdb7cdbfd4,
276            fidl::encoding::DynamicFlags::FLEXIBLE,
277            _decode,
278        )
279    }
280
281    type WatchChannelParametersResponseFut = fidl::client::QueryResponseFut<
282        ChannelParameters,
283        fidl::encoding::DefaultFuchsiaResourceDialect,
284    >;
285    fn r#watch_channel_parameters(&self) -> Self::WatchChannelParametersResponseFut {
286        fn _decode(
287            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
288        ) -> Result<ChannelParameters, fidl::Error> {
289            let _response = fidl::client::decode_transaction_body::<
290                fidl::encoding::FlexibleType<ChannelParameters>,
291                fidl::encoding::DefaultFuchsiaResourceDialect,
292                0x5a0cec81d5076c12,
293            >(_buf?)?
294            .into_result::<ChannelMarker>("watch_channel_parameters")?;
295            Ok(_response)
296        }
297        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ChannelParameters>(
298            (),
299            0x5a0cec81d5076c12,
300            fidl::encoding::DynamicFlags::FLEXIBLE,
301            _decode,
302        )
303    }
304}
305
306pub struct ChannelEventStream {
307    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
308}
309
310impl std::marker::Unpin for ChannelEventStream {}
311
312impl futures::stream::FusedStream for ChannelEventStream {
313    fn is_terminated(&self) -> bool {
314        self.event_receiver.is_terminated()
315    }
316}
317
318impl futures::Stream for ChannelEventStream {
319    type Item = Result<ChannelEvent, fidl::Error>;
320
321    fn poll_next(
322        mut self: std::pin::Pin<&mut Self>,
323        cx: &mut std::task::Context<'_>,
324    ) -> std::task::Poll<Option<Self::Item>> {
325        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
326            &mut self.event_receiver,
327            cx
328        )?) {
329            Some(buf) => std::task::Poll::Ready(Some(ChannelEvent::decode(buf))),
330            None => std::task::Poll::Ready(None),
331        }
332    }
333}
334
335#[derive(Debug)]
336pub enum ChannelEvent {
337    #[non_exhaustive]
338    _UnknownEvent {
339        /// Ordinal of the event that was sent.
340        ordinal: u64,
341    },
342}
343
344impl ChannelEvent {
345    /// Decodes a message buffer as a [`ChannelEvent`].
346    fn decode(
347        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
348    ) -> Result<ChannelEvent, fidl::Error> {
349        let (bytes, _handles) = buf.split_mut();
350        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
351        debug_assert_eq!(tx_header.tx_id, 0);
352        match tx_header.ordinal {
353            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
354                Ok(ChannelEvent::_UnknownEvent { ordinal: tx_header.ordinal })
355            }
356            _ => Err(fidl::Error::UnknownOrdinal {
357                ordinal: tx_header.ordinal,
358                protocol_name: <ChannelMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
359            }),
360        }
361    }
362}
363
364/// A Stream of incoming requests for fuchsia.bluetooth/Channel.
365pub struct ChannelRequestStream {
366    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
367    is_terminated: bool,
368}
369
370impl std::marker::Unpin for ChannelRequestStream {}
371
372impl futures::stream::FusedStream for ChannelRequestStream {
373    fn is_terminated(&self) -> bool {
374        self.is_terminated
375    }
376}
377
378impl fidl::endpoints::RequestStream for ChannelRequestStream {
379    type Protocol = ChannelMarker;
380    type ControlHandle = ChannelControlHandle;
381
382    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
383        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
384    }
385
386    fn control_handle(&self) -> Self::ControlHandle {
387        ChannelControlHandle { inner: self.inner.clone() }
388    }
389
390    fn into_inner(
391        self,
392    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
393    {
394        (self.inner, self.is_terminated)
395    }
396
397    fn from_inner(
398        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
399        is_terminated: bool,
400    ) -> Self {
401        Self { inner, is_terminated }
402    }
403}
404
405impl futures::Stream for ChannelRequestStream {
406    type Item = Result<ChannelRequest, fidl::Error>;
407
408    fn poll_next(
409        mut self: std::pin::Pin<&mut Self>,
410        cx: &mut std::task::Context<'_>,
411    ) -> std::task::Poll<Option<Self::Item>> {
412        let this = &mut *self;
413        if this.inner.check_shutdown(cx) {
414            this.is_terminated = true;
415            return std::task::Poll::Ready(None);
416        }
417        if this.is_terminated {
418            panic!("polled ChannelRequestStream after completion");
419        }
420        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
421            |bytes, handles| {
422                match this.inner.channel().read_etc(cx, bytes, handles) {
423                    std::task::Poll::Ready(Ok(())) => {}
424                    std::task::Poll::Pending => return std::task::Poll::Pending,
425                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
426                        this.is_terminated = true;
427                        return std::task::Poll::Ready(None);
428                    }
429                    std::task::Poll::Ready(Err(e)) => {
430                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
431                            e.into(),
432                        ))))
433                    }
434                }
435
436                // A message has been received from the channel
437                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
438
439                std::task::Poll::Ready(Some(match header.ordinal {
440                    0x6fc4419c2e763324 => {
441                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
442                        let mut req = fidl::new_empty!(
443                            ChannelSendRequest,
444                            fidl::encoding::DefaultFuchsiaResourceDialect
445                        );
446                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChannelSendRequest>(&header, _body_bytes, handles, &mut req)?;
447                        let control_handle = ChannelControlHandle { inner: this.inner.clone() };
448                        Ok(ChannelRequest::Send_ {
449                            packets: req.packets,
450
451                            responder: ChannelSend_Responder {
452                                control_handle: std::mem::ManuallyDrop::new(control_handle),
453                                tx_id: header.tx_id,
454                            },
455                        })
456                    }
457                    0x3498d7bdb7cdbfd4 => {
458                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
459                        let mut req = fidl::new_empty!(
460                            fidl::encoding::EmptyPayload,
461                            fidl::encoding::DefaultFuchsiaResourceDialect
462                        );
463                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
464                        let control_handle = ChannelControlHandle { inner: this.inner.clone() };
465                        Ok(ChannelRequest::Receive {
466                            responder: ChannelReceiveResponder {
467                                control_handle: std::mem::ManuallyDrop::new(control_handle),
468                                tx_id: header.tx_id,
469                            },
470                        })
471                    }
472                    0x5a0cec81d5076c12 => {
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 = ChannelControlHandle { inner: this.inner.clone() };
480                        Ok(ChannelRequest::WatchChannelParameters {
481                            responder: ChannelWatchChannelParametersResponder {
482                                control_handle: std::mem::ManuallyDrop::new(control_handle),
483                                tx_id: header.tx_id,
484                            },
485                        })
486                    }
487                    _ if header.tx_id == 0
488                        && header
489                            .dynamic_flags()
490                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
491                    {
492                        Ok(ChannelRequest::_UnknownMethod {
493                            ordinal: header.ordinal,
494                            control_handle: ChannelControlHandle { inner: this.inner.clone() },
495                            method_type: fidl::MethodType::OneWay,
496                        })
497                    }
498                    _ if header
499                        .dynamic_flags()
500                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
501                    {
502                        this.inner.send_framework_err(
503                            fidl::encoding::FrameworkErr::UnknownMethod,
504                            header.tx_id,
505                            header.ordinal,
506                            header.dynamic_flags(),
507                            (bytes, handles),
508                        )?;
509                        Ok(ChannelRequest::_UnknownMethod {
510                            ordinal: header.ordinal,
511                            control_handle: ChannelControlHandle { inner: this.inner.clone() },
512                            method_type: fidl::MethodType::TwoWay,
513                        })
514                    }
515                    _ => Err(fidl::Error::UnknownOrdinal {
516                        ordinal: header.ordinal,
517                        protocol_name:
518                            <ChannelMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
519                    }),
520                }))
521            },
522        )
523    }
524}
525
526/// A duplex channel for sending/recieving [`Packet`]s. This protocol also
527/// serves as a token to keeping the `Channel` open. Closing this protocol (and
528/// the associated `socket` for BR/EDR channels) will close the underlying
529/// channel.
530#[derive(Debug)]
531pub enum ChannelRequest {
532    /// Send multiple packets of data over the channel. Only one `Send`
533    /// may be pending at a time.
534    Send_ { packets: Vec<Packet>, responder: ChannelSend_Responder },
535    /// Hanging get that waits for inbound packets. Only one `Receive`
536    /// may be pending at a time.
537    Receive { responder: ChannelReceiveResponder },
538    /// For RFCOMM channels, this will not return and calls will hang
539    /// indefinitely.
540    ///
541    /// For BR/EDR L2CAP connection-oriented channels this will currently not
542    /// return and calls will hang indefinitely. The initial channel parameters
543    /// are provided in [`fuchsia.bluetooth.bredr/Channel`].
544    ///
545    /// For LE L2CAP connection-oriented channels, the first call will
546    /// immediately return the parameters of the remote side of the channel.
547    /// Subsequent calls will hang until the [`ChannelParameters`] change, at
548    /// which point it will return the new parameters, including those that have
549    /// not changed.
550    WatchChannelParameters { responder: ChannelWatchChannelParametersResponder },
551    /// An interaction was received which does not match any known method.
552    #[non_exhaustive]
553    _UnknownMethod {
554        /// Ordinal of the method that was called.
555        ordinal: u64,
556        control_handle: ChannelControlHandle,
557        method_type: fidl::MethodType,
558    },
559}
560
561impl ChannelRequest {
562    #[allow(irrefutable_let_patterns)]
563    pub fn into_send_(self) -> Option<(Vec<Packet>, ChannelSend_Responder)> {
564        if let ChannelRequest::Send_ { packets, responder } = self {
565            Some((packets, responder))
566        } else {
567            None
568        }
569    }
570
571    #[allow(irrefutable_let_patterns)]
572    pub fn into_receive(self) -> Option<(ChannelReceiveResponder)> {
573        if let ChannelRequest::Receive { responder } = self {
574            Some((responder))
575        } else {
576            None
577        }
578    }
579
580    #[allow(irrefutable_let_patterns)]
581    pub fn into_watch_channel_parameters(self) -> Option<(ChannelWatchChannelParametersResponder)> {
582        if let ChannelRequest::WatchChannelParameters { responder } = self {
583            Some((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            ChannelRequest::Send_ { .. } => "send_",
593            ChannelRequest::Receive { .. } => "receive",
594            ChannelRequest::WatchChannelParameters { .. } => "watch_channel_parameters",
595            ChannelRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
596                "unknown one-way method"
597            }
598            ChannelRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
599                "unknown two-way method"
600            }
601        }
602    }
603}
604
605#[derive(Debug, Clone)]
606pub struct ChannelControlHandle {
607    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
608}
609
610impl fidl::endpoints::ControlHandle for ChannelControlHandle {
611    fn shutdown(&self) {
612        self.inner.shutdown()
613    }
614    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
615        self.inner.shutdown_with_epitaph(status)
616    }
617
618    fn is_closed(&self) -> bool {
619        self.inner.channel().is_closed()
620    }
621    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
622        self.inner.channel().on_closed()
623    }
624
625    #[cfg(target_os = "fuchsia")]
626    fn signal_peer(
627        &self,
628        clear_mask: zx::Signals,
629        set_mask: zx::Signals,
630    ) -> Result<(), zx_status::Status> {
631        use fidl::Peered;
632        self.inner.channel().signal_peer(clear_mask, set_mask)
633    }
634}
635
636impl ChannelControlHandle {}
637
638#[must_use = "FIDL methods require a response to be sent"]
639#[derive(Debug)]
640pub struct ChannelSend_Responder {
641    control_handle: std::mem::ManuallyDrop<ChannelControlHandle>,
642    tx_id: u32,
643}
644
645/// Set the the channel to be shutdown (see [`ChannelControlHandle::shutdown`])
646/// if the responder is dropped without sending a response, so that the client
647/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
648impl std::ops::Drop for ChannelSend_Responder {
649    fn drop(&mut self) {
650        self.control_handle.shutdown();
651        // Safety: drops once, never accessed again
652        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
653    }
654}
655
656impl fidl::endpoints::Responder for ChannelSend_Responder {
657    type ControlHandle = ChannelControlHandle;
658
659    fn control_handle(&self) -> &ChannelControlHandle {
660        &self.control_handle
661    }
662
663    fn drop_without_shutdown(mut self) {
664        // Safety: drops once, never accessed again due to mem::forget
665        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
666        // Prevent Drop from running (which would shut down the channel)
667        std::mem::forget(self);
668    }
669}
670
671impl ChannelSend_Responder {
672    /// Sends a response to the FIDL transaction.
673    ///
674    /// Sets the channel to shutdown if an error occurs.
675    pub fn send(self) -> Result<(), fidl::Error> {
676        let _result = self.send_raw();
677        if _result.is_err() {
678            self.control_handle.shutdown();
679        }
680        self.drop_without_shutdown();
681        _result
682    }
683
684    /// Similar to "send" but does not shutdown the channel if an error occurs.
685    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
686        let _result = self.send_raw();
687        self.drop_without_shutdown();
688        _result
689    }
690
691    fn send_raw(&self) -> Result<(), fidl::Error> {
692        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
693            fidl::encoding::Flexible::new(()),
694            self.tx_id,
695            0x6fc4419c2e763324,
696            fidl::encoding::DynamicFlags::FLEXIBLE,
697        )
698    }
699}
700
701#[must_use = "FIDL methods require a response to be sent"]
702#[derive(Debug)]
703pub struct ChannelReceiveResponder {
704    control_handle: std::mem::ManuallyDrop<ChannelControlHandle>,
705    tx_id: u32,
706}
707
708/// Set the the channel to be shutdown (see [`ChannelControlHandle::shutdown`])
709/// if the responder is dropped without sending a response, so that the client
710/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
711impl std::ops::Drop for ChannelReceiveResponder {
712    fn drop(&mut self) {
713        self.control_handle.shutdown();
714        // Safety: drops once, never accessed again
715        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
716    }
717}
718
719impl fidl::endpoints::Responder for ChannelReceiveResponder {
720    type ControlHandle = ChannelControlHandle;
721
722    fn control_handle(&self) -> &ChannelControlHandle {
723        &self.control_handle
724    }
725
726    fn drop_without_shutdown(mut self) {
727        // Safety: drops once, never accessed again due to mem::forget
728        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
729        // Prevent Drop from running (which would shut down the channel)
730        std::mem::forget(self);
731    }
732}
733
734impl ChannelReceiveResponder {
735    /// Sends a response to the FIDL transaction.
736    ///
737    /// Sets the channel to shutdown if an error occurs.
738    pub fn send(self, mut packets: &[Packet]) -> Result<(), fidl::Error> {
739        let _result = self.send_raw(packets);
740        if _result.is_err() {
741            self.control_handle.shutdown();
742        }
743        self.drop_without_shutdown();
744        _result
745    }
746
747    /// Similar to "send" but does not shutdown the channel if an error occurs.
748    pub fn send_no_shutdown_on_err(self, mut packets: &[Packet]) -> Result<(), fidl::Error> {
749        let _result = self.send_raw(packets);
750        self.drop_without_shutdown();
751        _result
752    }
753
754    fn send_raw(&self, mut packets: &[Packet]) -> Result<(), fidl::Error> {
755        self.control_handle.inner.send::<fidl::encoding::FlexibleType<ChannelReceiveResponse>>(
756            fidl::encoding::Flexible::new((packets,)),
757            self.tx_id,
758            0x3498d7bdb7cdbfd4,
759            fidl::encoding::DynamicFlags::FLEXIBLE,
760        )
761    }
762}
763
764#[must_use = "FIDL methods require a response to be sent"]
765#[derive(Debug)]
766pub struct ChannelWatchChannelParametersResponder {
767    control_handle: std::mem::ManuallyDrop<ChannelControlHandle>,
768    tx_id: u32,
769}
770
771/// Set the the channel to be shutdown (see [`ChannelControlHandle::shutdown`])
772/// if the responder is dropped without sending a response, so that the client
773/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
774impl std::ops::Drop for ChannelWatchChannelParametersResponder {
775    fn drop(&mut self) {
776        self.control_handle.shutdown();
777        // Safety: drops once, never accessed again
778        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
779    }
780}
781
782impl fidl::endpoints::Responder for ChannelWatchChannelParametersResponder {
783    type ControlHandle = ChannelControlHandle;
784
785    fn control_handle(&self) -> &ChannelControlHandle {
786        &self.control_handle
787    }
788
789    fn drop_without_shutdown(mut self) {
790        // Safety: drops once, never accessed again due to mem::forget
791        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
792        // Prevent Drop from running (which would shut down the channel)
793        std::mem::forget(self);
794    }
795}
796
797impl ChannelWatchChannelParametersResponder {
798    /// Sends a response to the FIDL transaction.
799    ///
800    /// Sets the channel to shutdown if an error occurs.
801    pub fn send(self, mut payload: &ChannelParameters) -> Result<(), fidl::Error> {
802        let _result = self.send_raw(payload);
803        if _result.is_err() {
804            self.control_handle.shutdown();
805        }
806        self.drop_without_shutdown();
807        _result
808    }
809
810    /// Similar to "send" but does not shutdown the channel if an error occurs.
811    pub fn send_no_shutdown_on_err(
812        self,
813        mut payload: &ChannelParameters,
814    ) -> Result<(), fidl::Error> {
815        let _result = self.send_raw(payload);
816        self.drop_without_shutdown();
817        _result
818    }
819
820    fn send_raw(&self, mut payload: &ChannelParameters) -> Result<(), fidl::Error> {
821        self.control_handle.inner.send::<fidl::encoding::FlexibleType<ChannelParameters>>(
822            fidl::encoding::Flexible::new(payload),
823            self.tx_id,
824            0x5a0cec81d5076c12,
825            fidl::encoding::DynamicFlags::FLEXIBLE,
826        )
827    }
828}
829
830mod internal {
831    use super::*;
832}