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 _};
10use futures::future::{self, MaybeDone, TryFutureExt};
11use zx_status;
12
13#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
14pub enum ServiceError {
15    /// The requested component was already running.
16    AlreadyRunning,
17    /// The provided IP address could not be parsed.
18    InvalidIp,
19    /// A connection could not be established to the provided address.
20    ConnectionFailed,
21    /// The request failed internally.
22    Failed,
23    #[doc(hidden)]
24    __SourceBreaking { unknown_ordinal: u32 },
25}
26
27/// Pattern that matches an unknown `ServiceError` member.
28#[macro_export]
29macro_rules! ServiceErrorUnknown {
30    () => {
31        _
32    };
33}
34
35impl ServiceError {
36    #[inline]
37    pub fn from_primitive(prim: u32) -> Option<Self> {
38        match prim {
39            1 => Some(Self::AlreadyRunning),
40            2 => Some(Self::InvalidIp),
41            3 => Some(Self::ConnectionFailed),
42            4 => Some(Self::Failed),
43            _ => None,
44        }
45    }
46
47    #[inline]
48    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
49        match prim {
50            1 => Self::AlreadyRunning,
51            2 => Self::InvalidIp,
52            3 => Self::ConnectionFailed,
53            4 => Self::Failed,
54            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
55        }
56    }
57
58    #[inline]
59    pub fn unknown() -> Self {
60        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
61    }
62
63    #[inline]
64    pub const fn into_primitive(self) -> u32 {
65        match self {
66            Self::AlreadyRunning => 1,
67            Self::InvalidIp => 2,
68            Self::ConnectionFailed => 3,
69            Self::Failed => 4,
70            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
71        }
72    }
73
74    #[inline]
75    pub fn is_unknown(&self) -> bool {
76        match self {
77            Self::__SourceBreaking { unknown_ordinal: _ } => true,
78            _ => false,
79        }
80    }
81}
82
83#[derive(Clone, Debug, Default, PartialEq)]
84pub struct GrpcServerControllerStartRequest {
85    pub port: Option<u16>,
86    #[doc(hidden)]
87    pub __source_breaking: fidl::marker::SourceBreaking,
88}
89
90impl fidl::Persistable for GrpcServerControllerStartRequest {}
91
92#[derive(Clone, Debug, Default, PartialEq)]
93pub struct RootcanalClientControllerStartRequest {
94    pub ip: Option<String>,
95    pub port: Option<u16>,
96    #[doc(hidden)]
97    pub __source_breaking: fidl::marker::SourceBreaking,
98}
99
100impl fidl::Persistable for RootcanalClientControllerStartRequest {}
101
102#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
103pub struct GrpcServerControllerMarker;
104
105impl fidl::endpoints::ProtocolMarker for GrpcServerControllerMarker {
106    type Proxy = GrpcServerControllerProxy;
107    type RequestStream = GrpcServerControllerRequestStream;
108    #[cfg(target_os = "fuchsia")]
109    type SynchronousProxy = GrpcServerControllerSynchronousProxy;
110
111    const DEBUG_NAME: &'static str = "fuchsia.bluetooth.pandora.GrpcServerController";
112}
113impl fidl::endpoints::DiscoverableProtocolMarker for GrpcServerControllerMarker {}
114pub type GrpcServerControllerStartResult = Result<(), ServiceError>;
115
116pub trait GrpcServerControllerProxyInterface: Send + Sync {
117    type StartResponseFut: std::future::Future<Output = Result<GrpcServerControllerStartResult, fidl::Error>>
118        + Send;
119    fn r#start(&self, payload: &GrpcServerControllerStartRequest) -> Self::StartResponseFut;
120    type StopResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
121    fn r#stop(&self) -> Self::StopResponseFut;
122}
123#[derive(Debug)]
124#[cfg(target_os = "fuchsia")]
125pub struct GrpcServerControllerSynchronousProxy {
126    client: fidl::client::sync::Client,
127}
128
129#[cfg(target_os = "fuchsia")]
130impl fidl::endpoints::SynchronousProxy for GrpcServerControllerSynchronousProxy {
131    type Proxy = GrpcServerControllerProxy;
132    type Protocol = GrpcServerControllerMarker;
133
134    fn from_channel(inner: fidl::Channel) -> Self {
135        Self::new(inner)
136    }
137
138    fn into_channel(self) -> fidl::Channel {
139        self.client.into_channel()
140    }
141
142    fn as_channel(&self) -> &fidl::Channel {
143        self.client.as_channel()
144    }
145}
146
147#[cfg(target_os = "fuchsia")]
148impl GrpcServerControllerSynchronousProxy {
149    pub fn new(channel: fidl::Channel) -> Self {
150        let protocol_name =
151            <GrpcServerControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
152        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
153    }
154
155    pub fn into_channel(self) -> fidl::Channel {
156        self.client.into_channel()
157    }
158
159    /// Waits until an event arrives and returns it. It is safe for other
160    /// threads to make concurrent requests while waiting for an event.
161    pub fn wait_for_event(
162        &self,
163        deadline: zx::MonotonicInstant,
164    ) -> Result<GrpcServerControllerEvent, fidl::Error> {
165        GrpcServerControllerEvent::decode(self.client.wait_for_event(deadline)?)
166    }
167
168    /// Start Pandora interface gRPC server.
169    ///
170    /// + request `port` is the Fuchsia port on which the gRPC server will listen.
171    ///
172    /// * error Returns `ALREADY_RUNNING` if a gRPC server is already running.
173    /// * error Returns `FAILED` if there was an internal error starting the server.
174    pub fn r#start(
175        &self,
176        mut payload: &GrpcServerControllerStartRequest,
177        ___deadline: zx::MonotonicInstant,
178    ) -> Result<GrpcServerControllerStartResult, fidl::Error> {
179        let _response = self.client.send_query::<
180            GrpcServerControllerStartRequest,
181            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, ServiceError>,
182        >(
183            payload,
184            0x39b64f9031375c29,
185            fidl::encoding::DynamicFlags::FLEXIBLE,
186            ___deadline,
187        )?
188        .into_result::<GrpcServerControllerMarker>("start")?;
189        Ok(_response.map(|x| x))
190    }
191
192    /// Stop gRPC server if running.
193    pub fn r#stop(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
194        let _response = self.client.send_query::<
195            fidl::encoding::EmptyPayload,
196            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
197        >(
198            (),
199            0x4e8601feb5d930b9,
200            fidl::encoding::DynamicFlags::FLEXIBLE,
201            ___deadline,
202        )?
203        .into_result::<GrpcServerControllerMarker>("stop")?;
204        Ok(_response)
205    }
206}
207
208#[derive(Debug, Clone)]
209pub struct GrpcServerControllerProxy {
210    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
211}
212
213impl fidl::endpoints::Proxy for GrpcServerControllerProxy {
214    type Protocol = GrpcServerControllerMarker;
215
216    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
217        Self::new(inner)
218    }
219
220    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
221        self.client.into_channel().map_err(|client| Self { client })
222    }
223
224    fn as_channel(&self) -> &::fidl::AsyncChannel {
225        self.client.as_channel()
226    }
227}
228
229impl GrpcServerControllerProxy {
230    /// Create a new Proxy for fuchsia.bluetooth.pandora/GrpcServerController.
231    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
232        let protocol_name =
233            <GrpcServerControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
234        Self { client: fidl::client::Client::new(channel, protocol_name) }
235    }
236
237    /// Get a Stream of events from the remote end of the protocol.
238    ///
239    /// # Panics
240    ///
241    /// Panics if the event stream was already taken.
242    pub fn take_event_stream(&self) -> GrpcServerControllerEventStream {
243        GrpcServerControllerEventStream { event_receiver: self.client.take_event_receiver() }
244    }
245
246    /// Start Pandora interface gRPC server.
247    ///
248    /// + request `port` is the Fuchsia port on which the gRPC server will listen.
249    ///
250    /// * error Returns `ALREADY_RUNNING` if a gRPC server is already running.
251    /// * error Returns `FAILED` if there was an internal error starting the server.
252    pub fn r#start(
253        &self,
254        mut payload: &GrpcServerControllerStartRequest,
255    ) -> fidl::client::QueryResponseFut<
256        GrpcServerControllerStartResult,
257        fidl::encoding::DefaultFuchsiaResourceDialect,
258    > {
259        GrpcServerControllerProxyInterface::r#start(self, payload)
260    }
261
262    /// Stop gRPC server if running.
263    pub fn r#stop(
264        &self,
265    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
266        GrpcServerControllerProxyInterface::r#stop(self)
267    }
268}
269
270impl GrpcServerControllerProxyInterface for GrpcServerControllerProxy {
271    type StartResponseFut = fidl::client::QueryResponseFut<
272        GrpcServerControllerStartResult,
273        fidl::encoding::DefaultFuchsiaResourceDialect,
274    >;
275    fn r#start(&self, mut payload: &GrpcServerControllerStartRequest) -> Self::StartResponseFut {
276        fn _decode(
277            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
278        ) -> Result<GrpcServerControllerStartResult, fidl::Error> {
279            let _response = fidl::client::decode_transaction_body::<
280                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, ServiceError>,
281                fidl::encoding::DefaultFuchsiaResourceDialect,
282                0x39b64f9031375c29,
283            >(_buf?)?
284            .into_result::<GrpcServerControllerMarker>("start")?;
285            Ok(_response.map(|x| x))
286        }
287        self.client.send_query_and_decode::<
288            GrpcServerControllerStartRequest,
289            GrpcServerControllerStartResult,
290        >(
291            payload,
292            0x39b64f9031375c29,
293            fidl::encoding::DynamicFlags::FLEXIBLE,
294            _decode,
295        )
296    }
297
298    type StopResponseFut =
299        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
300    fn r#stop(&self) -> Self::StopResponseFut {
301        fn _decode(
302            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
303        ) -> Result<(), fidl::Error> {
304            let _response = fidl::client::decode_transaction_body::<
305                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
306                fidl::encoding::DefaultFuchsiaResourceDialect,
307                0x4e8601feb5d930b9,
308            >(_buf?)?
309            .into_result::<GrpcServerControllerMarker>("stop")?;
310            Ok(_response)
311        }
312        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
313            (),
314            0x4e8601feb5d930b9,
315            fidl::encoding::DynamicFlags::FLEXIBLE,
316            _decode,
317        )
318    }
319}
320
321pub struct GrpcServerControllerEventStream {
322    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
323}
324
325impl std::marker::Unpin for GrpcServerControllerEventStream {}
326
327impl futures::stream::FusedStream for GrpcServerControllerEventStream {
328    fn is_terminated(&self) -> bool {
329        self.event_receiver.is_terminated()
330    }
331}
332
333impl futures::Stream for GrpcServerControllerEventStream {
334    type Item = Result<GrpcServerControllerEvent, fidl::Error>;
335
336    fn poll_next(
337        mut self: std::pin::Pin<&mut Self>,
338        cx: &mut std::task::Context<'_>,
339    ) -> std::task::Poll<Option<Self::Item>> {
340        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
341            &mut self.event_receiver,
342            cx
343        )?) {
344            Some(buf) => std::task::Poll::Ready(Some(GrpcServerControllerEvent::decode(buf))),
345            None => std::task::Poll::Ready(None),
346        }
347    }
348}
349
350#[derive(Debug)]
351pub enum GrpcServerControllerEvent {
352    #[non_exhaustive]
353    _UnknownEvent {
354        /// Ordinal of the event that was sent.
355        ordinal: u64,
356    },
357}
358
359impl GrpcServerControllerEvent {
360    /// Decodes a message buffer as a [`GrpcServerControllerEvent`].
361    fn decode(
362        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
363    ) -> Result<GrpcServerControllerEvent, fidl::Error> {
364        let (bytes, _handles) = buf.split_mut();
365        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
366        debug_assert_eq!(tx_header.tx_id, 0);
367        match tx_header.ordinal {
368            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
369                Ok(GrpcServerControllerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
370            }
371            _ => Err(fidl::Error::UnknownOrdinal {
372                ordinal: tx_header.ordinal,
373                protocol_name:
374                    <GrpcServerControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
375            }),
376        }
377    }
378}
379
380/// A Stream of incoming requests for fuchsia.bluetooth.pandora/GrpcServerController.
381pub struct GrpcServerControllerRequestStream {
382    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
383    is_terminated: bool,
384}
385
386impl std::marker::Unpin for GrpcServerControllerRequestStream {}
387
388impl futures::stream::FusedStream for GrpcServerControllerRequestStream {
389    fn is_terminated(&self) -> bool {
390        self.is_terminated
391    }
392}
393
394impl fidl::endpoints::RequestStream for GrpcServerControllerRequestStream {
395    type Protocol = GrpcServerControllerMarker;
396    type ControlHandle = GrpcServerControllerControlHandle;
397
398    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
399        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
400    }
401
402    fn control_handle(&self) -> Self::ControlHandle {
403        GrpcServerControllerControlHandle { inner: self.inner.clone() }
404    }
405
406    fn into_inner(
407        self,
408    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
409    {
410        (self.inner, self.is_terminated)
411    }
412
413    fn from_inner(
414        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
415        is_terminated: bool,
416    ) -> Self {
417        Self { inner, is_terminated }
418    }
419}
420
421impl futures::Stream for GrpcServerControllerRequestStream {
422    type Item = Result<GrpcServerControllerRequest, fidl::Error>;
423
424    fn poll_next(
425        mut self: std::pin::Pin<&mut Self>,
426        cx: &mut std::task::Context<'_>,
427    ) -> std::task::Poll<Option<Self::Item>> {
428        let this = &mut *self;
429        if this.inner.check_shutdown(cx) {
430            this.is_terminated = true;
431            return std::task::Poll::Ready(None);
432        }
433        if this.is_terminated {
434            panic!("polled GrpcServerControllerRequestStream after completion");
435        }
436        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
437            |bytes, handles| {
438                match this.inner.channel().read_etc(cx, bytes, handles) {
439                    std::task::Poll::Ready(Ok(())) => {}
440                    std::task::Poll::Pending => return std::task::Poll::Pending,
441                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
442                        this.is_terminated = true;
443                        return std::task::Poll::Ready(None);
444                    }
445                    std::task::Poll::Ready(Err(e)) => {
446                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
447                            e.into(),
448                        ))))
449                    }
450                }
451
452                // A message has been received from the channel
453                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
454
455                std::task::Poll::Ready(Some(match header.ordinal {
456                0x39b64f9031375c29 => {
457                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
458                    let mut req = fidl::new_empty!(GrpcServerControllerStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
459                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GrpcServerControllerStartRequest>(&header, _body_bytes, handles, &mut req)?;
460                    let control_handle = GrpcServerControllerControlHandle {
461                        inner: this.inner.clone(),
462                    };
463                    Ok(GrpcServerControllerRequest::Start {payload: req,
464                        responder: GrpcServerControllerStartResponder {
465                            control_handle: std::mem::ManuallyDrop::new(control_handle),
466                            tx_id: header.tx_id,
467                        },
468                    })
469                }
470                0x4e8601feb5d930b9 => {
471                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
472                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
473                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
474                    let control_handle = GrpcServerControllerControlHandle {
475                        inner: this.inner.clone(),
476                    };
477                    Ok(GrpcServerControllerRequest::Stop {
478                        responder: GrpcServerControllerStopResponder {
479                            control_handle: std::mem::ManuallyDrop::new(control_handle),
480                            tx_id: header.tx_id,
481                        },
482                    })
483                }
484                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
485                    Ok(GrpcServerControllerRequest::_UnknownMethod {
486                        ordinal: header.ordinal,
487                        control_handle: GrpcServerControllerControlHandle { inner: this.inner.clone() },
488                        method_type: fidl::MethodType::OneWay,
489                    })
490                }
491                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
492                    this.inner.send_framework_err(
493                        fidl::encoding::FrameworkErr::UnknownMethod,
494                        header.tx_id,
495                        header.ordinal,
496                        header.dynamic_flags(),
497                        (bytes, handles),
498                    )?;
499                    Ok(GrpcServerControllerRequest::_UnknownMethod {
500                        ordinal: header.ordinal,
501                        control_handle: GrpcServerControllerControlHandle { inner: this.inner.clone() },
502                        method_type: fidl::MethodType::TwoWay,
503                    })
504                }
505                _ => Err(fidl::Error::UnknownOrdinal {
506                    ordinal: header.ordinal,
507                    protocol_name: <GrpcServerControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
508                }),
509            }))
510            },
511        )
512    }
513}
514
515/// Controls the lifecycle of a gRPC server that implements the [Pandora Bluetooth testing
516/// interfaces](https://github.com/google/bt-test-interfaces).
517#[derive(Debug)]
518pub enum GrpcServerControllerRequest {
519    /// Start Pandora interface gRPC server.
520    ///
521    /// + request `port` is the Fuchsia port on which the gRPC server will listen.
522    ///
523    /// * error Returns `ALREADY_RUNNING` if a gRPC server is already running.
524    /// * error Returns `FAILED` if there was an internal error starting the server.
525    Start {
526        payload: GrpcServerControllerStartRequest,
527        responder: GrpcServerControllerStartResponder,
528    },
529    /// Stop gRPC server if running.
530    Stop { responder: GrpcServerControllerStopResponder },
531    /// An interaction was received which does not match any known method.
532    #[non_exhaustive]
533    _UnknownMethod {
534        /// Ordinal of the method that was called.
535        ordinal: u64,
536        control_handle: GrpcServerControllerControlHandle,
537        method_type: fidl::MethodType,
538    },
539}
540
541impl GrpcServerControllerRequest {
542    #[allow(irrefutable_let_patterns)]
543    pub fn into_start(
544        self,
545    ) -> Option<(GrpcServerControllerStartRequest, GrpcServerControllerStartResponder)> {
546        if let GrpcServerControllerRequest::Start { payload, responder } = self {
547            Some((payload, responder))
548        } else {
549            None
550        }
551    }
552
553    #[allow(irrefutable_let_patterns)]
554    pub fn into_stop(self) -> Option<(GrpcServerControllerStopResponder)> {
555        if let GrpcServerControllerRequest::Stop { responder } = self {
556            Some((responder))
557        } else {
558            None
559        }
560    }
561
562    /// Name of the method defined in FIDL
563    pub fn method_name(&self) -> &'static str {
564        match *self {
565            GrpcServerControllerRequest::Start { .. } => "start",
566            GrpcServerControllerRequest::Stop { .. } => "stop",
567            GrpcServerControllerRequest::_UnknownMethod {
568                method_type: fidl::MethodType::OneWay,
569                ..
570            } => "unknown one-way method",
571            GrpcServerControllerRequest::_UnknownMethod {
572                method_type: fidl::MethodType::TwoWay,
573                ..
574            } => "unknown two-way method",
575        }
576    }
577}
578
579#[derive(Debug, Clone)]
580pub struct GrpcServerControllerControlHandle {
581    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
582}
583
584impl fidl::endpoints::ControlHandle for GrpcServerControllerControlHandle {
585    fn shutdown(&self) {
586        self.inner.shutdown()
587    }
588    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
589        self.inner.shutdown_with_epitaph(status)
590    }
591
592    fn is_closed(&self) -> bool {
593        self.inner.channel().is_closed()
594    }
595    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
596        self.inner.channel().on_closed()
597    }
598
599    #[cfg(target_os = "fuchsia")]
600    fn signal_peer(
601        &self,
602        clear_mask: zx::Signals,
603        set_mask: zx::Signals,
604    ) -> Result<(), zx_status::Status> {
605        use fidl::Peered;
606        self.inner.channel().signal_peer(clear_mask, set_mask)
607    }
608}
609
610impl GrpcServerControllerControlHandle {}
611
612#[must_use = "FIDL methods require a response to be sent"]
613#[derive(Debug)]
614pub struct GrpcServerControllerStartResponder {
615    control_handle: std::mem::ManuallyDrop<GrpcServerControllerControlHandle>,
616    tx_id: u32,
617}
618
619/// Set the the channel to be shutdown (see [`GrpcServerControllerControlHandle::shutdown`])
620/// if the responder is dropped without sending a response, so that the client
621/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
622impl std::ops::Drop for GrpcServerControllerStartResponder {
623    fn drop(&mut self) {
624        self.control_handle.shutdown();
625        // Safety: drops once, never accessed again
626        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
627    }
628}
629
630impl fidl::endpoints::Responder for GrpcServerControllerStartResponder {
631    type ControlHandle = GrpcServerControllerControlHandle;
632
633    fn control_handle(&self) -> &GrpcServerControllerControlHandle {
634        &self.control_handle
635    }
636
637    fn drop_without_shutdown(mut self) {
638        // Safety: drops once, never accessed again due to mem::forget
639        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
640        // Prevent Drop from running (which would shut down the channel)
641        std::mem::forget(self);
642    }
643}
644
645impl GrpcServerControllerStartResponder {
646    /// Sends a response to the FIDL transaction.
647    ///
648    /// Sets the channel to shutdown if an error occurs.
649    pub fn send(self, mut result: Result<(), ServiceError>) -> Result<(), fidl::Error> {
650        let _result = self.send_raw(result);
651        if _result.is_err() {
652            self.control_handle.shutdown();
653        }
654        self.drop_without_shutdown();
655        _result
656    }
657
658    /// Similar to "send" but does not shutdown the channel if an error occurs.
659    pub fn send_no_shutdown_on_err(
660        self,
661        mut result: Result<(), ServiceError>,
662    ) -> Result<(), fidl::Error> {
663        let _result = self.send_raw(result);
664        self.drop_without_shutdown();
665        _result
666    }
667
668    fn send_raw(&self, mut result: Result<(), ServiceError>) -> Result<(), fidl::Error> {
669        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
670            fidl::encoding::EmptyStruct,
671            ServiceError,
672        >>(
673            fidl::encoding::FlexibleResult::new(result),
674            self.tx_id,
675            0x39b64f9031375c29,
676            fidl::encoding::DynamicFlags::FLEXIBLE,
677        )
678    }
679}
680
681#[must_use = "FIDL methods require a response to be sent"]
682#[derive(Debug)]
683pub struct GrpcServerControllerStopResponder {
684    control_handle: std::mem::ManuallyDrop<GrpcServerControllerControlHandle>,
685    tx_id: u32,
686}
687
688/// Set the the channel to be shutdown (see [`GrpcServerControllerControlHandle::shutdown`])
689/// if the responder is dropped without sending a response, so that the client
690/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
691impl std::ops::Drop for GrpcServerControllerStopResponder {
692    fn drop(&mut self) {
693        self.control_handle.shutdown();
694        // Safety: drops once, never accessed again
695        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
696    }
697}
698
699impl fidl::endpoints::Responder for GrpcServerControllerStopResponder {
700    type ControlHandle = GrpcServerControllerControlHandle;
701
702    fn control_handle(&self) -> &GrpcServerControllerControlHandle {
703        &self.control_handle
704    }
705
706    fn drop_without_shutdown(mut self) {
707        // Safety: drops once, never accessed again due to mem::forget
708        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
709        // Prevent Drop from running (which would shut down the channel)
710        std::mem::forget(self);
711    }
712}
713
714impl GrpcServerControllerStopResponder {
715    /// Sends a response to the FIDL transaction.
716    ///
717    /// Sets the channel to shutdown if an error occurs.
718    pub fn send(self) -> Result<(), fidl::Error> {
719        let _result = self.send_raw();
720        if _result.is_err() {
721            self.control_handle.shutdown();
722        }
723        self.drop_without_shutdown();
724        _result
725    }
726
727    /// Similar to "send" but does not shutdown the channel if an error occurs.
728    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
729        let _result = self.send_raw();
730        self.drop_without_shutdown();
731        _result
732    }
733
734    fn send_raw(&self) -> Result<(), fidl::Error> {
735        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
736            fidl::encoding::Flexible::new(()),
737            self.tx_id,
738            0x4e8601feb5d930b9,
739            fidl::encoding::DynamicFlags::FLEXIBLE,
740        )
741    }
742}
743
744#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
745pub struct RootcanalClientControllerMarker;
746
747impl fidl::endpoints::ProtocolMarker for RootcanalClientControllerMarker {
748    type Proxy = RootcanalClientControllerProxy;
749    type RequestStream = RootcanalClientControllerRequestStream;
750    #[cfg(target_os = "fuchsia")]
751    type SynchronousProxy = RootcanalClientControllerSynchronousProxy;
752
753    const DEBUG_NAME: &'static str = "fuchsia.bluetooth.pandora.RootcanalClientController";
754}
755impl fidl::endpoints::DiscoverableProtocolMarker for RootcanalClientControllerMarker {}
756pub type RootcanalClientControllerStartResult = Result<(), ServiceError>;
757
758pub trait RootcanalClientControllerProxyInterface: Send + Sync {
759    type StartResponseFut: std::future::Future<Output = Result<RootcanalClientControllerStartResult, fidl::Error>>
760        + Send;
761    fn r#start(&self, payload: &RootcanalClientControllerStartRequest) -> Self::StartResponseFut;
762    type StopResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
763    fn r#stop(&self) -> Self::StopResponseFut;
764}
765#[derive(Debug)]
766#[cfg(target_os = "fuchsia")]
767pub struct RootcanalClientControllerSynchronousProxy {
768    client: fidl::client::sync::Client,
769}
770
771#[cfg(target_os = "fuchsia")]
772impl fidl::endpoints::SynchronousProxy for RootcanalClientControllerSynchronousProxy {
773    type Proxy = RootcanalClientControllerProxy;
774    type Protocol = RootcanalClientControllerMarker;
775
776    fn from_channel(inner: fidl::Channel) -> Self {
777        Self::new(inner)
778    }
779
780    fn into_channel(self) -> fidl::Channel {
781        self.client.into_channel()
782    }
783
784    fn as_channel(&self) -> &fidl::Channel {
785        self.client.as_channel()
786    }
787}
788
789#[cfg(target_os = "fuchsia")]
790impl RootcanalClientControllerSynchronousProxy {
791    pub fn new(channel: fidl::Channel) -> Self {
792        let protocol_name =
793            <RootcanalClientControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
794        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
795    }
796
797    pub fn into_channel(self) -> fidl::Channel {
798        self.client.into_channel()
799    }
800
801    /// Waits until an event arrives and returns it. It is safe for other
802    /// threads to make concurrent requests while waiting for an event.
803    pub fn wait_for_event(
804        &self,
805        deadline: zx::MonotonicInstant,
806    ) -> Result<RootcanalClientControllerEvent, fidl::Error> {
807        RootcanalClientControllerEvent::decode(self.client.wait_for_event(deadline)?)
808    }
809
810    /// Start bt-rootcanal if it is not already running.
811    ///
812    /// + request `ip` is the IP address of the host running the Rootcanal server.
813    /// + request `port` is the port on the host on which the Rootcanal server is listening.
814    ///
815    /// * error Returns `ALREADY_RUNNING` if bt-rootcanal is already running.
816    /// * error Returns `INVALID_IP` if the IP address could not be parsed.
817    /// * error Returns `CONNECTION_FAILED` if a connection to the Rootcanal server could not be
818    ///         established.
819    /// * error Returns `FAILED` if there was an internal error starting bt-rootcanal.
820    pub fn r#start(
821        &self,
822        mut payload: &RootcanalClientControllerStartRequest,
823        ___deadline: zx::MonotonicInstant,
824    ) -> Result<RootcanalClientControllerStartResult, fidl::Error> {
825        let _response = self.client.send_query::<
826            RootcanalClientControllerStartRequest,
827            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, ServiceError>,
828        >(
829            payload,
830            0xde429b8e402832c,
831            fidl::encoding::DynamicFlags::FLEXIBLE,
832            ___deadline,
833        )?
834        .into_result::<RootcanalClientControllerMarker>("start")?;
835        Ok(_response.map(|x| x))
836    }
837
838    /// Stop bt-rootcanal if running.
839    pub fn r#stop(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
840        let _response = self.client.send_query::<
841            fidl::encoding::EmptyPayload,
842            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
843        >(
844            (),
845            0x30419bba3f039d1d,
846            fidl::encoding::DynamicFlags::FLEXIBLE,
847            ___deadline,
848        )?
849        .into_result::<RootcanalClientControllerMarker>("stop")?;
850        Ok(_response)
851    }
852}
853
854#[derive(Debug, Clone)]
855pub struct RootcanalClientControllerProxy {
856    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
857}
858
859impl fidl::endpoints::Proxy for RootcanalClientControllerProxy {
860    type Protocol = RootcanalClientControllerMarker;
861
862    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
863        Self::new(inner)
864    }
865
866    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
867        self.client.into_channel().map_err(|client| Self { client })
868    }
869
870    fn as_channel(&self) -> &::fidl::AsyncChannel {
871        self.client.as_channel()
872    }
873}
874
875impl RootcanalClientControllerProxy {
876    /// Create a new Proxy for fuchsia.bluetooth.pandora/RootcanalClientController.
877    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
878        let protocol_name =
879            <RootcanalClientControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
880        Self { client: fidl::client::Client::new(channel, protocol_name) }
881    }
882
883    /// Get a Stream of events from the remote end of the protocol.
884    ///
885    /// # Panics
886    ///
887    /// Panics if the event stream was already taken.
888    pub fn take_event_stream(&self) -> RootcanalClientControllerEventStream {
889        RootcanalClientControllerEventStream { event_receiver: self.client.take_event_receiver() }
890    }
891
892    /// Start bt-rootcanal if it is not already running.
893    ///
894    /// + request `ip` is the IP address of the host running the Rootcanal server.
895    /// + request `port` is the port on the host on which the Rootcanal server is listening.
896    ///
897    /// * error Returns `ALREADY_RUNNING` if bt-rootcanal is already running.
898    /// * error Returns `INVALID_IP` if the IP address could not be parsed.
899    /// * error Returns `CONNECTION_FAILED` if a connection to the Rootcanal server could not be
900    ///         established.
901    /// * error Returns `FAILED` if there was an internal error starting bt-rootcanal.
902    pub fn r#start(
903        &self,
904        mut payload: &RootcanalClientControllerStartRequest,
905    ) -> fidl::client::QueryResponseFut<
906        RootcanalClientControllerStartResult,
907        fidl::encoding::DefaultFuchsiaResourceDialect,
908    > {
909        RootcanalClientControllerProxyInterface::r#start(self, payload)
910    }
911
912    /// Stop bt-rootcanal if running.
913    pub fn r#stop(
914        &self,
915    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
916        RootcanalClientControllerProxyInterface::r#stop(self)
917    }
918}
919
920impl RootcanalClientControllerProxyInterface for RootcanalClientControllerProxy {
921    type StartResponseFut = fidl::client::QueryResponseFut<
922        RootcanalClientControllerStartResult,
923        fidl::encoding::DefaultFuchsiaResourceDialect,
924    >;
925    fn r#start(
926        &self,
927        mut payload: &RootcanalClientControllerStartRequest,
928    ) -> Self::StartResponseFut {
929        fn _decode(
930            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
931        ) -> Result<RootcanalClientControllerStartResult, fidl::Error> {
932            let _response = fidl::client::decode_transaction_body::<
933                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, ServiceError>,
934                fidl::encoding::DefaultFuchsiaResourceDialect,
935                0xde429b8e402832c,
936            >(_buf?)?
937            .into_result::<RootcanalClientControllerMarker>("start")?;
938            Ok(_response.map(|x| x))
939        }
940        self.client.send_query_and_decode::<
941            RootcanalClientControllerStartRequest,
942            RootcanalClientControllerStartResult,
943        >(
944            payload,
945            0xde429b8e402832c,
946            fidl::encoding::DynamicFlags::FLEXIBLE,
947            _decode,
948        )
949    }
950
951    type StopResponseFut =
952        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
953    fn r#stop(&self) -> Self::StopResponseFut {
954        fn _decode(
955            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
956        ) -> Result<(), fidl::Error> {
957            let _response = fidl::client::decode_transaction_body::<
958                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
959                fidl::encoding::DefaultFuchsiaResourceDialect,
960                0x30419bba3f039d1d,
961            >(_buf?)?
962            .into_result::<RootcanalClientControllerMarker>("stop")?;
963            Ok(_response)
964        }
965        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
966            (),
967            0x30419bba3f039d1d,
968            fidl::encoding::DynamicFlags::FLEXIBLE,
969            _decode,
970        )
971    }
972}
973
974pub struct RootcanalClientControllerEventStream {
975    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
976}
977
978impl std::marker::Unpin for RootcanalClientControllerEventStream {}
979
980impl futures::stream::FusedStream for RootcanalClientControllerEventStream {
981    fn is_terminated(&self) -> bool {
982        self.event_receiver.is_terminated()
983    }
984}
985
986impl futures::Stream for RootcanalClientControllerEventStream {
987    type Item = Result<RootcanalClientControllerEvent, fidl::Error>;
988
989    fn poll_next(
990        mut self: std::pin::Pin<&mut Self>,
991        cx: &mut std::task::Context<'_>,
992    ) -> std::task::Poll<Option<Self::Item>> {
993        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
994            &mut self.event_receiver,
995            cx
996        )?) {
997            Some(buf) => std::task::Poll::Ready(Some(RootcanalClientControllerEvent::decode(buf))),
998            None => std::task::Poll::Ready(None),
999        }
1000    }
1001}
1002
1003#[derive(Debug)]
1004pub enum RootcanalClientControllerEvent {
1005    #[non_exhaustive]
1006    _UnknownEvent {
1007        /// Ordinal of the event that was sent.
1008        ordinal: u64,
1009    },
1010}
1011
1012impl RootcanalClientControllerEvent {
1013    /// Decodes a message buffer as a [`RootcanalClientControllerEvent`].
1014    fn decode(
1015        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1016    ) -> Result<RootcanalClientControllerEvent, fidl::Error> {
1017        let (bytes, _handles) = buf.split_mut();
1018        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1019        debug_assert_eq!(tx_header.tx_id, 0);
1020        match tx_header.ordinal {
1021            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1022                Ok(RootcanalClientControllerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1023            }
1024            _ => Err(fidl::Error::UnknownOrdinal {
1025                ordinal: tx_header.ordinal,
1026                protocol_name:
1027                    <RootcanalClientControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1028            }),
1029        }
1030    }
1031}
1032
1033/// A Stream of incoming requests for fuchsia.bluetooth.pandora/RootcanalClientController.
1034pub struct RootcanalClientControllerRequestStream {
1035    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1036    is_terminated: bool,
1037}
1038
1039impl std::marker::Unpin for RootcanalClientControllerRequestStream {}
1040
1041impl futures::stream::FusedStream for RootcanalClientControllerRequestStream {
1042    fn is_terminated(&self) -> bool {
1043        self.is_terminated
1044    }
1045}
1046
1047impl fidl::endpoints::RequestStream for RootcanalClientControllerRequestStream {
1048    type Protocol = RootcanalClientControllerMarker;
1049    type ControlHandle = RootcanalClientControllerControlHandle;
1050
1051    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1052        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1053    }
1054
1055    fn control_handle(&self) -> Self::ControlHandle {
1056        RootcanalClientControllerControlHandle { inner: self.inner.clone() }
1057    }
1058
1059    fn into_inner(
1060        self,
1061    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1062    {
1063        (self.inner, self.is_terminated)
1064    }
1065
1066    fn from_inner(
1067        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1068        is_terminated: bool,
1069    ) -> Self {
1070        Self { inner, is_terminated }
1071    }
1072}
1073
1074impl futures::Stream for RootcanalClientControllerRequestStream {
1075    type Item = Result<RootcanalClientControllerRequest, fidl::Error>;
1076
1077    fn poll_next(
1078        mut self: std::pin::Pin<&mut Self>,
1079        cx: &mut std::task::Context<'_>,
1080    ) -> std::task::Poll<Option<Self::Item>> {
1081        let this = &mut *self;
1082        if this.inner.check_shutdown(cx) {
1083            this.is_terminated = true;
1084            return std::task::Poll::Ready(None);
1085        }
1086        if this.is_terminated {
1087            panic!("polled RootcanalClientControllerRequestStream after completion");
1088        }
1089        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1090            |bytes, handles| {
1091                match this.inner.channel().read_etc(cx, bytes, handles) {
1092                    std::task::Poll::Ready(Ok(())) => {}
1093                    std::task::Poll::Pending => return std::task::Poll::Pending,
1094                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1095                        this.is_terminated = true;
1096                        return std::task::Poll::Ready(None);
1097                    }
1098                    std::task::Poll::Ready(Err(e)) => {
1099                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1100                            e.into(),
1101                        ))))
1102                    }
1103                }
1104
1105                // A message has been received from the channel
1106                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1107
1108                std::task::Poll::Ready(Some(match header.ordinal {
1109                0xde429b8e402832c => {
1110                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1111                    let mut req = fidl::new_empty!(RootcanalClientControllerStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1112                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RootcanalClientControllerStartRequest>(&header, _body_bytes, handles, &mut req)?;
1113                    let control_handle = RootcanalClientControllerControlHandle {
1114                        inner: this.inner.clone(),
1115                    };
1116                    Ok(RootcanalClientControllerRequest::Start {payload: req,
1117                        responder: RootcanalClientControllerStartResponder {
1118                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1119                            tx_id: header.tx_id,
1120                        },
1121                    })
1122                }
1123                0x30419bba3f039d1d => {
1124                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1125                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
1126                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1127                    let control_handle = RootcanalClientControllerControlHandle {
1128                        inner: this.inner.clone(),
1129                    };
1130                    Ok(RootcanalClientControllerRequest::Stop {
1131                        responder: RootcanalClientControllerStopResponder {
1132                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1133                            tx_id: header.tx_id,
1134                        },
1135                    })
1136                }
1137                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1138                    Ok(RootcanalClientControllerRequest::_UnknownMethod {
1139                        ordinal: header.ordinal,
1140                        control_handle: RootcanalClientControllerControlHandle { inner: this.inner.clone() },
1141                        method_type: fidl::MethodType::OneWay,
1142                    })
1143                }
1144                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1145                    this.inner.send_framework_err(
1146                        fidl::encoding::FrameworkErr::UnknownMethod,
1147                        header.tx_id,
1148                        header.ordinal,
1149                        header.dynamic_flags(),
1150                        (bytes, handles),
1151                    )?;
1152                    Ok(RootcanalClientControllerRequest::_UnknownMethod {
1153                        ordinal: header.ordinal,
1154                        control_handle: RootcanalClientControllerControlHandle { inner: this.inner.clone() },
1155                        method_type: fidl::MethodType::TwoWay,
1156                    })
1157                }
1158                _ => Err(fidl::Error::UnknownOrdinal {
1159                    ordinal: header.ordinal,
1160                    protocol_name: <RootcanalClientControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1161                }),
1162            }))
1163            },
1164        )
1165    }
1166}
1167
1168/// Controls instances of bt-rootcanal, a tool that proxies HCI traffic between Fuchsia Bluetooth
1169/// and a [Rootcanal](https://github.com/google/rootcanal) server.
1170#[derive(Debug)]
1171pub enum RootcanalClientControllerRequest {
1172    /// Start bt-rootcanal if it is not already running.
1173    ///
1174    /// + request `ip` is the IP address of the host running the Rootcanal server.
1175    /// + request `port` is the port on the host on which the Rootcanal server is listening.
1176    ///
1177    /// * error Returns `ALREADY_RUNNING` if bt-rootcanal is already running.
1178    /// * error Returns `INVALID_IP` if the IP address could not be parsed.
1179    /// * error Returns `CONNECTION_FAILED` if a connection to the Rootcanal server could not be
1180    ///         established.
1181    /// * error Returns `FAILED` if there was an internal error starting bt-rootcanal.
1182    Start {
1183        payload: RootcanalClientControllerStartRequest,
1184        responder: RootcanalClientControllerStartResponder,
1185    },
1186    /// Stop bt-rootcanal if running.
1187    Stop { responder: RootcanalClientControllerStopResponder },
1188    /// An interaction was received which does not match any known method.
1189    #[non_exhaustive]
1190    _UnknownMethod {
1191        /// Ordinal of the method that was called.
1192        ordinal: u64,
1193        control_handle: RootcanalClientControllerControlHandle,
1194        method_type: fidl::MethodType,
1195    },
1196}
1197
1198impl RootcanalClientControllerRequest {
1199    #[allow(irrefutable_let_patterns)]
1200    pub fn into_start(
1201        self,
1202    ) -> Option<(RootcanalClientControllerStartRequest, RootcanalClientControllerStartResponder)>
1203    {
1204        if let RootcanalClientControllerRequest::Start { payload, responder } = self {
1205            Some((payload, responder))
1206        } else {
1207            None
1208        }
1209    }
1210
1211    #[allow(irrefutable_let_patterns)]
1212    pub fn into_stop(self) -> Option<(RootcanalClientControllerStopResponder)> {
1213        if let RootcanalClientControllerRequest::Stop { responder } = self {
1214            Some((responder))
1215        } else {
1216            None
1217        }
1218    }
1219
1220    /// Name of the method defined in FIDL
1221    pub fn method_name(&self) -> &'static str {
1222        match *self {
1223            RootcanalClientControllerRequest::Start { .. } => "start",
1224            RootcanalClientControllerRequest::Stop { .. } => "stop",
1225            RootcanalClientControllerRequest::_UnknownMethod {
1226                method_type: fidl::MethodType::OneWay,
1227                ..
1228            } => "unknown one-way method",
1229            RootcanalClientControllerRequest::_UnknownMethod {
1230                method_type: fidl::MethodType::TwoWay,
1231                ..
1232            } => "unknown two-way method",
1233        }
1234    }
1235}
1236
1237#[derive(Debug, Clone)]
1238pub struct RootcanalClientControllerControlHandle {
1239    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1240}
1241
1242impl fidl::endpoints::ControlHandle for RootcanalClientControllerControlHandle {
1243    fn shutdown(&self) {
1244        self.inner.shutdown()
1245    }
1246    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1247        self.inner.shutdown_with_epitaph(status)
1248    }
1249
1250    fn is_closed(&self) -> bool {
1251        self.inner.channel().is_closed()
1252    }
1253    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1254        self.inner.channel().on_closed()
1255    }
1256
1257    #[cfg(target_os = "fuchsia")]
1258    fn signal_peer(
1259        &self,
1260        clear_mask: zx::Signals,
1261        set_mask: zx::Signals,
1262    ) -> Result<(), zx_status::Status> {
1263        use fidl::Peered;
1264        self.inner.channel().signal_peer(clear_mask, set_mask)
1265    }
1266}
1267
1268impl RootcanalClientControllerControlHandle {}
1269
1270#[must_use = "FIDL methods require a response to be sent"]
1271#[derive(Debug)]
1272pub struct RootcanalClientControllerStartResponder {
1273    control_handle: std::mem::ManuallyDrop<RootcanalClientControllerControlHandle>,
1274    tx_id: u32,
1275}
1276
1277/// Set the the channel to be shutdown (see [`RootcanalClientControllerControlHandle::shutdown`])
1278/// if the responder is dropped without sending a response, so that the client
1279/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1280impl std::ops::Drop for RootcanalClientControllerStartResponder {
1281    fn drop(&mut self) {
1282        self.control_handle.shutdown();
1283        // Safety: drops once, never accessed again
1284        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1285    }
1286}
1287
1288impl fidl::endpoints::Responder for RootcanalClientControllerStartResponder {
1289    type ControlHandle = RootcanalClientControllerControlHandle;
1290
1291    fn control_handle(&self) -> &RootcanalClientControllerControlHandle {
1292        &self.control_handle
1293    }
1294
1295    fn drop_without_shutdown(mut self) {
1296        // Safety: drops once, never accessed again due to mem::forget
1297        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1298        // Prevent Drop from running (which would shut down the channel)
1299        std::mem::forget(self);
1300    }
1301}
1302
1303impl RootcanalClientControllerStartResponder {
1304    /// Sends a response to the FIDL transaction.
1305    ///
1306    /// Sets the channel to shutdown if an error occurs.
1307    pub fn send(self, mut result: Result<(), ServiceError>) -> Result<(), fidl::Error> {
1308        let _result = self.send_raw(result);
1309        if _result.is_err() {
1310            self.control_handle.shutdown();
1311        }
1312        self.drop_without_shutdown();
1313        _result
1314    }
1315
1316    /// Similar to "send" but does not shutdown the channel if an error occurs.
1317    pub fn send_no_shutdown_on_err(
1318        self,
1319        mut result: Result<(), ServiceError>,
1320    ) -> Result<(), fidl::Error> {
1321        let _result = self.send_raw(result);
1322        self.drop_without_shutdown();
1323        _result
1324    }
1325
1326    fn send_raw(&self, mut result: Result<(), ServiceError>) -> Result<(), fidl::Error> {
1327        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1328            fidl::encoding::EmptyStruct,
1329            ServiceError,
1330        >>(
1331            fidl::encoding::FlexibleResult::new(result),
1332            self.tx_id,
1333            0xde429b8e402832c,
1334            fidl::encoding::DynamicFlags::FLEXIBLE,
1335        )
1336    }
1337}
1338
1339#[must_use = "FIDL methods require a response to be sent"]
1340#[derive(Debug)]
1341pub struct RootcanalClientControllerStopResponder {
1342    control_handle: std::mem::ManuallyDrop<RootcanalClientControllerControlHandle>,
1343    tx_id: u32,
1344}
1345
1346/// Set the the channel to be shutdown (see [`RootcanalClientControllerControlHandle::shutdown`])
1347/// if the responder is dropped without sending a response, so that the client
1348/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1349impl std::ops::Drop for RootcanalClientControllerStopResponder {
1350    fn drop(&mut self) {
1351        self.control_handle.shutdown();
1352        // Safety: drops once, never accessed again
1353        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1354    }
1355}
1356
1357impl fidl::endpoints::Responder for RootcanalClientControllerStopResponder {
1358    type ControlHandle = RootcanalClientControllerControlHandle;
1359
1360    fn control_handle(&self) -> &RootcanalClientControllerControlHandle {
1361        &self.control_handle
1362    }
1363
1364    fn drop_without_shutdown(mut self) {
1365        // Safety: drops once, never accessed again due to mem::forget
1366        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1367        // Prevent Drop from running (which would shut down the channel)
1368        std::mem::forget(self);
1369    }
1370}
1371
1372impl RootcanalClientControllerStopResponder {
1373    /// Sends a response to the FIDL transaction.
1374    ///
1375    /// Sets the channel to shutdown if an error occurs.
1376    pub fn send(self) -> Result<(), fidl::Error> {
1377        let _result = self.send_raw();
1378        if _result.is_err() {
1379            self.control_handle.shutdown();
1380        }
1381        self.drop_without_shutdown();
1382        _result
1383    }
1384
1385    /// Similar to "send" but does not shutdown the channel if an error occurs.
1386    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1387        let _result = self.send_raw();
1388        self.drop_without_shutdown();
1389        _result
1390    }
1391
1392    fn send_raw(&self) -> Result<(), fidl::Error> {
1393        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
1394            fidl::encoding::Flexible::new(()),
1395            self.tx_id,
1396            0x30419bba3f039d1d,
1397            fidl::encoding::DynamicFlags::FLEXIBLE,
1398        )
1399    }
1400}
1401
1402mod internal {
1403    use super::*;
1404    unsafe impl fidl::encoding::TypeMarker for ServiceError {
1405        type Owned = Self;
1406
1407        #[inline(always)]
1408        fn inline_align(_context: fidl::encoding::Context) -> usize {
1409            std::mem::align_of::<u32>()
1410        }
1411
1412        #[inline(always)]
1413        fn inline_size(_context: fidl::encoding::Context) -> usize {
1414            std::mem::size_of::<u32>()
1415        }
1416
1417        #[inline(always)]
1418        fn encode_is_copy() -> bool {
1419            false
1420        }
1421
1422        #[inline(always)]
1423        fn decode_is_copy() -> bool {
1424            false
1425        }
1426    }
1427
1428    impl fidl::encoding::ValueTypeMarker for ServiceError {
1429        type Borrowed<'a> = Self;
1430        #[inline(always)]
1431        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1432            *value
1433        }
1434    }
1435
1436    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for ServiceError {
1437        #[inline]
1438        unsafe fn encode(
1439            self,
1440            encoder: &mut fidl::encoding::Encoder<'_, D>,
1441            offset: usize,
1442            _depth: fidl::encoding::Depth,
1443        ) -> fidl::Result<()> {
1444            encoder.debug_check_bounds::<Self>(offset);
1445            encoder.write_num(self.into_primitive(), offset);
1446            Ok(())
1447        }
1448    }
1449
1450    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ServiceError {
1451        #[inline(always)]
1452        fn new_empty() -> Self {
1453            Self::unknown()
1454        }
1455
1456        #[inline]
1457        unsafe fn decode(
1458            &mut self,
1459            decoder: &mut fidl::encoding::Decoder<'_, D>,
1460            offset: usize,
1461            _depth: fidl::encoding::Depth,
1462        ) -> fidl::Result<()> {
1463            decoder.debug_check_bounds::<Self>(offset);
1464            let prim = decoder.read_num::<u32>(offset);
1465
1466            *self = Self::from_primitive_allow_unknown(prim);
1467            Ok(())
1468        }
1469    }
1470
1471    impl GrpcServerControllerStartRequest {
1472        #[inline(always)]
1473        fn max_ordinal_present(&self) -> u64 {
1474            if let Some(_) = self.port {
1475                return 1;
1476            }
1477            0
1478        }
1479    }
1480
1481    impl fidl::encoding::ValueTypeMarker for GrpcServerControllerStartRequest {
1482        type Borrowed<'a> = &'a Self;
1483        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1484            value
1485        }
1486    }
1487
1488    unsafe impl fidl::encoding::TypeMarker for GrpcServerControllerStartRequest {
1489        type Owned = Self;
1490
1491        #[inline(always)]
1492        fn inline_align(_context: fidl::encoding::Context) -> usize {
1493            8
1494        }
1495
1496        #[inline(always)]
1497        fn inline_size(_context: fidl::encoding::Context) -> usize {
1498            16
1499        }
1500    }
1501
1502    unsafe impl<D: fidl::encoding::ResourceDialect>
1503        fidl::encoding::Encode<GrpcServerControllerStartRequest, D>
1504        for &GrpcServerControllerStartRequest
1505    {
1506        unsafe fn encode(
1507            self,
1508            encoder: &mut fidl::encoding::Encoder<'_, D>,
1509            offset: usize,
1510            mut depth: fidl::encoding::Depth,
1511        ) -> fidl::Result<()> {
1512            encoder.debug_check_bounds::<GrpcServerControllerStartRequest>(offset);
1513            // Vector header
1514            let max_ordinal: u64 = self.max_ordinal_present();
1515            encoder.write_num(max_ordinal, offset);
1516            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1517            // Calling encoder.out_of_line_offset(0) is not allowed.
1518            if max_ordinal == 0 {
1519                return Ok(());
1520            }
1521            depth.increment()?;
1522            let envelope_size = 8;
1523            let bytes_len = max_ordinal as usize * envelope_size;
1524            #[allow(unused_variables)]
1525            let offset = encoder.out_of_line_offset(bytes_len);
1526            let mut _prev_end_offset: usize = 0;
1527            if 1 > max_ordinal {
1528                return Ok(());
1529            }
1530
1531            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1532            // are envelope_size bytes.
1533            let cur_offset: usize = (1 - 1) * envelope_size;
1534
1535            // Zero reserved fields.
1536            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1537
1538            // Safety:
1539            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1540            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1541            //   envelope_size bytes, there is always sufficient room.
1542            fidl::encoding::encode_in_envelope_optional::<u16, D>(
1543                self.port.as_ref().map(<u16 as fidl::encoding::ValueTypeMarker>::borrow),
1544                encoder,
1545                offset + cur_offset,
1546                depth,
1547            )?;
1548
1549            _prev_end_offset = cur_offset + envelope_size;
1550
1551            Ok(())
1552        }
1553    }
1554
1555    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1556        for GrpcServerControllerStartRequest
1557    {
1558        #[inline(always)]
1559        fn new_empty() -> Self {
1560            Self::default()
1561        }
1562
1563        unsafe fn decode(
1564            &mut self,
1565            decoder: &mut fidl::encoding::Decoder<'_, D>,
1566            offset: usize,
1567            mut depth: fidl::encoding::Depth,
1568        ) -> fidl::Result<()> {
1569            decoder.debug_check_bounds::<Self>(offset);
1570            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1571                None => return Err(fidl::Error::NotNullable),
1572                Some(len) => len,
1573            };
1574            // Calling decoder.out_of_line_offset(0) is not allowed.
1575            if len == 0 {
1576                return Ok(());
1577            };
1578            depth.increment()?;
1579            let envelope_size = 8;
1580            let bytes_len = len * envelope_size;
1581            let offset = decoder.out_of_line_offset(bytes_len)?;
1582            // Decode the envelope for each type.
1583            let mut _next_ordinal_to_read = 0;
1584            let mut next_offset = offset;
1585            let end_offset = offset + bytes_len;
1586            _next_ordinal_to_read += 1;
1587            if next_offset >= end_offset {
1588                return Ok(());
1589            }
1590
1591            // Decode unknown envelopes for gaps in ordinals.
1592            while _next_ordinal_to_read < 1 {
1593                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1594                _next_ordinal_to_read += 1;
1595                next_offset += envelope_size;
1596            }
1597
1598            let next_out_of_line = decoder.next_out_of_line();
1599            let handles_before = decoder.remaining_handles();
1600            if let Some((inlined, num_bytes, num_handles)) =
1601                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1602            {
1603                let member_inline_size =
1604                    <u16 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1605                if inlined != (member_inline_size <= 4) {
1606                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1607                }
1608                let inner_offset;
1609                let mut inner_depth = depth.clone();
1610                if inlined {
1611                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1612                    inner_offset = next_offset;
1613                } else {
1614                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1615                    inner_depth.increment()?;
1616                }
1617                let val_ref = self.port.get_or_insert_with(|| fidl::new_empty!(u16, D));
1618                fidl::decode!(u16, D, val_ref, decoder, inner_offset, inner_depth)?;
1619                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1620                {
1621                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1622                }
1623                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1624                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1625                }
1626            }
1627
1628            next_offset += envelope_size;
1629
1630            // Decode the remaining unknown envelopes.
1631            while next_offset < end_offset {
1632                _next_ordinal_to_read += 1;
1633                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1634                next_offset += envelope_size;
1635            }
1636
1637            Ok(())
1638        }
1639    }
1640
1641    impl RootcanalClientControllerStartRequest {
1642        #[inline(always)]
1643        fn max_ordinal_present(&self) -> u64 {
1644            if let Some(_) = self.port {
1645                return 2;
1646            }
1647            if let Some(_) = self.ip {
1648                return 1;
1649            }
1650            0
1651        }
1652    }
1653
1654    impl fidl::encoding::ValueTypeMarker for RootcanalClientControllerStartRequest {
1655        type Borrowed<'a> = &'a Self;
1656        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1657            value
1658        }
1659    }
1660
1661    unsafe impl fidl::encoding::TypeMarker for RootcanalClientControllerStartRequest {
1662        type Owned = Self;
1663
1664        #[inline(always)]
1665        fn inline_align(_context: fidl::encoding::Context) -> usize {
1666            8
1667        }
1668
1669        #[inline(always)]
1670        fn inline_size(_context: fidl::encoding::Context) -> usize {
1671            16
1672        }
1673    }
1674
1675    unsafe impl<D: fidl::encoding::ResourceDialect>
1676        fidl::encoding::Encode<RootcanalClientControllerStartRequest, D>
1677        for &RootcanalClientControllerStartRequest
1678    {
1679        unsafe fn encode(
1680            self,
1681            encoder: &mut fidl::encoding::Encoder<'_, D>,
1682            offset: usize,
1683            mut depth: fidl::encoding::Depth,
1684        ) -> fidl::Result<()> {
1685            encoder.debug_check_bounds::<RootcanalClientControllerStartRequest>(offset);
1686            // Vector header
1687            let max_ordinal: u64 = self.max_ordinal_present();
1688            encoder.write_num(max_ordinal, offset);
1689            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1690            // Calling encoder.out_of_line_offset(0) is not allowed.
1691            if max_ordinal == 0 {
1692                return Ok(());
1693            }
1694            depth.increment()?;
1695            let envelope_size = 8;
1696            let bytes_len = max_ordinal as usize * envelope_size;
1697            #[allow(unused_variables)]
1698            let offset = encoder.out_of_line_offset(bytes_len);
1699            let mut _prev_end_offset: usize = 0;
1700            if 1 > max_ordinal {
1701                return Ok(());
1702            }
1703
1704            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1705            // are envelope_size bytes.
1706            let cur_offset: usize = (1 - 1) * envelope_size;
1707
1708            // Zero reserved fields.
1709            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1710
1711            // Safety:
1712            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1713            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1714            //   envelope_size bytes, there is always sufficient room.
1715            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<32>, D>(
1716                self.ip.as_ref().map(
1717                    <fidl::encoding::BoundedString<32> as fidl::encoding::ValueTypeMarker>::borrow,
1718                ),
1719                encoder,
1720                offset + cur_offset,
1721                depth,
1722            )?;
1723
1724            _prev_end_offset = cur_offset + envelope_size;
1725            if 2 > max_ordinal {
1726                return Ok(());
1727            }
1728
1729            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1730            // are envelope_size bytes.
1731            let cur_offset: usize = (2 - 1) * envelope_size;
1732
1733            // Zero reserved fields.
1734            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1735
1736            // Safety:
1737            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1738            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1739            //   envelope_size bytes, there is always sufficient room.
1740            fidl::encoding::encode_in_envelope_optional::<u16, D>(
1741                self.port.as_ref().map(<u16 as fidl::encoding::ValueTypeMarker>::borrow),
1742                encoder,
1743                offset + cur_offset,
1744                depth,
1745            )?;
1746
1747            _prev_end_offset = cur_offset + envelope_size;
1748
1749            Ok(())
1750        }
1751    }
1752
1753    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1754        for RootcanalClientControllerStartRequest
1755    {
1756        #[inline(always)]
1757        fn new_empty() -> Self {
1758            Self::default()
1759        }
1760
1761        unsafe fn decode(
1762            &mut self,
1763            decoder: &mut fidl::encoding::Decoder<'_, D>,
1764            offset: usize,
1765            mut depth: fidl::encoding::Depth,
1766        ) -> fidl::Result<()> {
1767            decoder.debug_check_bounds::<Self>(offset);
1768            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1769                None => return Err(fidl::Error::NotNullable),
1770                Some(len) => len,
1771            };
1772            // Calling decoder.out_of_line_offset(0) is not allowed.
1773            if len == 0 {
1774                return Ok(());
1775            };
1776            depth.increment()?;
1777            let envelope_size = 8;
1778            let bytes_len = len * envelope_size;
1779            let offset = decoder.out_of_line_offset(bytes_len)?;
1780            // Decode the envelope for each type.
1781            let mut _next_ordinal_to_read = 0;
1782            let mut next_offset = offset;
1783            let end_offset = offset + bytes_len;
1784            _next_ordinal_to_read += 1;
1785            if next_offset >= end_offset {
1786                return Ok(());
1787            }
1788
1789            // Decode unknown envelopes for gaps in ordinals.
1790            while _next_ordinal_to_read < 1 {
1791                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1792                _next_ordinal_to_read += 1;
1793                next_offset += envelope_size;
1794            }
1795
1796            let next_out_of_line = decoder.next_out_of_line();
1797            let handles_before = decoder.remaining_handles();
1798            if let Some((inlined, num_bytes, num_handles)) =
1799                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1800            {
1801                let member_inline_size =
1802                    <fidl::encoding::BoundedString<32> as fidl::encoding::TypeMarker>::inline_size(
1803                        decoder.context,
1804                    );
1805                if inlined != (member_inline_size <= 4) {
1806                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1807                }
1808                let inner_offset;
1809                let mut inner_depth = depth.clone();
1810                if inlined {
1811                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1812                    inner_offset = next_offset;
1813                } else {
1814                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1815                    inner_depth.increment()?;
1816                }
1817                let val_ref = self
1818                    .ip
1819                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::BoundedString<32>, D));
1820                fidl::decode!(
1821                    fidl::encoding::BoundedString<32>,
1822                    D,
1823                    val_ref,
1824                    decoder,
1825                    inner_offset,
1826                    inner_depth
1827                )?;
1828                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1829                {
1830                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1831                }
1832                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1833                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1834                }
1835            }
1836
1837            next_offset += envelope_size;
1838            _next_ordinal_to_read += 1;
1839            if next_offset >= end_offset {
1840                return Ok(());
1841            }
1842
1843            // Decode unknown envelopes for gaps in ordinals.
1844            while _next_ordinal_to_read < 2 {
1845                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1846                _next_ordinal_to_read += 1;
1847                next_offset += envelope_size;
1848            }
1849
1850            let next_out_of_line = decoder.next_out_of_line();
1851            let handles_before = decoder.remaining_handles();
1852            if let Some((inlined, num_bytes, num_handles)) =
1853                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1854            {
1855                let member_inline_size =
1856                    <u16 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1857                if inlined != (member_inline_size <= 4) {
1858                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1859                }
1860                let inner_offset;
1861                let mut inner_depth = depth.clone();
1862                if inlined {
1863                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1864                    inner_offset = next_offset;
1865                } else {
1866                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1867                    inner_depth.increment()?;
1868                }
1869                let val_ref = self.port.get_or_insert_with(|| fidl::new_empty!(u16, D));
1870                fidl::decode!(u16, D, val_ref, decoder, inner_offset, inner_depth)?;
1871                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1872                {
1873                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1874                }
1875                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1876                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1877                }
1878            }
1879
1880            next_offset += envelope_size;
1881
1882            // Decode the remaining unknown envelopes.
1883            while next_offset < end_offset {
1884                _next_ordinal_to_read += 1;
1885                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1886                next_offset += envelope_size;
1887            }
1888
1889            Ok(())
1890        }
1891    }
1892}