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