Skip to main content

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