Skip to main content

fidl_fuchsia_bluetooth_map/
fidl_fuchsia_bluetooth_map.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_map_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Default, PartialEq)]
15pub struct AccessorSetNotificationRegistrationRequest {
16    pub mas_instance_ids: Option<Vec<u8>>,
17    pub server: Option<fidl::endpoints::ClientEnd<NotificationRegistrationMarker>>,
18    #[doc(hidden)]
19    pub __source_breaking: fidl::marker::SourceBreaking,
20}
21
22impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
23    for AccessorSetNotificationRegistrationRequest
24{
25}
26
27#[derive(Debug, Default, PartialEq)]
28pub struct MessagingClientWatchAccessorResponse {
29    pub peer_id: Option<fidl_fuchsia_bluetooth::PeerId>,
30    pub accessor: Option<fidl::endpoints::ClientEnd<AccessorMarker>>,
31    #[doc(hidden)]
32    pub __source_breaking: fidl::marker::SourceBreaking,
33}
34
35impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
36    for MessagingClientWatchAccessorResponse
37{
38}
39
40#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
41pub struct AccessorMarker;
42
43impl fidl::endpoints::ProtocolMarker for AccessorMarker {
44    type Proxy = AccessorProxy;
45    type RequestStream = AccessorRequestStream;
46    #[cfg(target_os = "fuchsia")]
47    type SynchronousProxy = AccessorSynchronousProxy;
48
49    const DEBUG_NAME: &'static str = "(anonymous) Accessor";
50}
51pub type AccessorListAllMasInstancesResult = Result<Vec<MasInstance>, Error>;
52pub type AccessorSetNotificationRegistrationResult = Result<(), Error>;
53
54pub trait AccessorProxyInterface: Send + Sync {
55    type GetDetailsResponseFut: std::future::Future<Output = Result<MessageControllerGetDetailsResult, fidl::Error>>
56        + Send;
57    fn r#get_details(&self, handle: u64, include_attachment: bool) -> Self::GetDetailsResponseFut;
58    type ListAllMasInstancesResponseFut: std::future::Future<Output = Result<AccessorListAllMasInstancesResult, fidl::Error>>
59        + Send;
60    fn r#list_all_mas_instances(&self) -> Self::ListAllMasInstancesResponseFut;
61    type SetNotificationRegistrationResponseFut: std::future::Future<Output = Result<AccessorSetNotificationRegistrationResult, fidl::Error>>
62        + Send;
63    fn r#set_notification_registration(
64        &self,
65        payload: AccessorSetNotificationRegistrationRequest,
66    ) -> Self::SetNotificationRegistrationResponseFut;
67}
68#[derive(Debug)]
69#[cfg(target_os = "fuchsia")]
70pub struct AccessorSynchronousProxy {
71    client: fidl::client::sync::Client,
72}
73
74#[cfg(target_os = "fuchsia")]
75impl fidl::endpoints::SynchronousProxy for AccessorSynchronousProxy {
76    type Proxy = AccessorProxy;
77    type Protocol = AccessorMarker;
78
79    fn from_channel(inner: fidl::Channel) -> Self {
80        Self::new(inner)
81    }
82
83    fn into_channel(self) -> fidl::Channel {
84        self.client.into_channel()
85    }
86
87    fn as_channel(&self) -> &fidl::Channel {
88        self.client.as_channel()
89    }
90}
91
92#[cfg(target_os = "fuchsia")]
93impl AccessorSynchronousProxy {
94    pub fn new(channel: fidl::Channel) -> Self {
95        Self { client: fidl::client::sync::Client::new(channel) }
96    }
97
98    pub fn into_channel(self) -> fidl::Channel {
99        self.client.into_channel()
100    }
101
102    /// Waits until an event arrives and returns it. It is safe for other
103    /// threads to make concurrent requests while waiting for an event.
104    pub fn wait_for_event(
105        &self,
106        deadline: zx::MonotonicInstant,
107    ) -> Result<AccessorEvent, fidl::Error> {
108        AccessorEvent::decode(self.client.wait_for_event::<AccessorMarker>(deadline)?)
109    }
110
111    /// Retrieve all available message details.
112    /// + request `handle` Unique identifier for a Messsage.
113    /// + request `include_attachment` Whether or not attachment should be included as
114    ///                                part of Message content if it's available.
115    /// - response NOT_FOUND error is returned if the message with the given handle does not exist.
116    pub fn r#get_details(
117        &self,
118        mut handle: u64,
119        mut include_attachment: bool,
120        ___deadline: zx::MonotonicInstant,
121    ) -> Result<MessageControllerGetDetailsResult, fidl::Error> {
122        let _response = self.client.send_query::<
123            MessageControllerGetDetailsRequest,
124            fidl::encoding::FlexibleResultType<Message, Error>,
125            AccessorMarker,
126        >(
127            (handle, include_attachment,),
128            0x7c3667b69d66691e,
129            fidl::encoding::DynamicFlags::FLEXIBLE,
130            ___deadline,
131        )?
132        .into_result::<AccessorMarker>("get_details")?;
133        Ok(_response.map(|x| x))
134    }
135
136    pub fn r#list_all_mas_instances(
137        &self,
138        ___deadline: zx::MonotonicInstant,
139    ) -> Result<AccessorListAllMasInstancesResult, fidl::Error> {
140        let _response = self.client.send_query::<
141            fidl::encoding::EmptyPayload,
142            fidl::encoding::FlexibleResultType<AccessorListAllMasInstancesResponse, Error>,
143            AccessorMarker,
144        >(
145            (),
146            0x6c78ebf9ba9780bd,
147            fidl::encoding::DynamicFlags::FLEXIBLE,
148            ___deadline,
149        )?
150        .into_result::<AccessorMarker>("list_all_mas_instances")?;
151        Ok(_response.map(|x| x.instances))
152    }
153
154    /// Registers for notifications from the specified MAS instances.
155    /// Note that notification registration may only be open one at a time.
156    /// If the NotificationRegistration protocol is active when a new
157    /// request is made, the request will fail with an Unavailable error
158    /// until the existing channel is closed.
159    /// Hangs until registration process is completed.
160    /// + request `mas_instance_ids` If empty, registration for notifications
161    ///                               is done for all known MAS instances.
162    /// + request `server` Client end of the repository notifier protocol
163    ///                    that needs to be passed to the Accessor server.
164    ///                    Caller should hold onto the server end to
165    ///                    receive incoming notifications. Should not be empty.
166    pub fn r#set_notification_registration(
167        &self,
168        mut payload: AccessorSetNotificationRegistrationRequest,
169        ___deadline: zx::MonotonicInstant,
170    ) -> Result<AccessorSetNotificationRegistrationResult, fidl::Error> {
171        let _response = self.client.send_query::<
172            AccessorSetNotificationRegistrationRequest,
173            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
174            AccessorMarker,
175        >(
176            &mut payload,
177            0x3d764e196f83bd7c,
178            fidl::encoding::DynamicFlags::FLEXIBLE,
179            ___deadline,
180        )?
181        .into_result::<AccessorMarker>("set_notification_registration")?;
182        Ok(_response.map(|x| x))
183    }
184}
185
186#[cfg(target_os = "fuchsia")]
187impl From<AccessorSynchronousProxy> for zx::NullableHandle {
188    fn from(value: AccessorSynchronousProxy) -> Self {
189        value.into_channel().into()
190    }
191}
192
193#[cfg(target_os = "fuchsia")]
194impl From<fidl::Channel> for AccessorSynchronousProxy {
195    fn from(value: fidl::Channel) -> Self {
196        Self::new(value)
197    }
198}
199
200#[cfg(target_os = "fuchsia")]
201impl fidl::endpoints::FromClient for AccessorSynchronousProxy {
202    type Protocol = AccessorMarker;
203
204    fn from_client(value: fidl::endpoints::ClientEnd<AccessorMarker>) -> Self {
205        Self::new(value.into_channel())
206    }
207}
208
209#[derive(Debug, Clone)]
210pub struct AccessorProxy {
211    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
212}
213
214impl fidl::endpoints::Proxy for AccessorProxy {
215    type Protocol = AccessorMarker;
216
217    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
218        Self::new(inner)
219    }
220
221    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
222        self.client.into_channel().map_err(|client| Self { client })
223    }
224
225    fn as_channel(&self) -> &::fidl::AsyncChannel {
226        self.client.as_channel()
227    }
228}
229
230impl AccessorProxy {
231    /// Create a new Proxy for fuchsia.bluetooth.map/Accessor.
232    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
233        let protocol_name = <AccessorMarker 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) -> AccessorEventStream {
243        AccessorEventStream { event_receiver: self.client.take_event_receiver() }
244    }
245
246    /// Retrieve all available message details.
247    /// + request `handle` Unique identifier for a Messsage.
248    /// + request `include_attachment` Whether or not attachment should be included as
249    ///                                part of Message content if it's available.
250    /// - response NOT_FOUND error is returned if the message with the given handle does not exist.
251    pub fn r#get_details(
252        &self,
253        mut handle: u64,
254        mut include_attachment: bool,
255    ) -> fidl::client::QueryResponseFut<
256        MessageControllerGetDetailsResult,
257        fidl::encoding::DefaultFuchsiaResourceDialect,
258    > {
259        AccessorProxyInterface::r#get_details(self, handle, include_attachment)
260    }
261
262    pub fn r#list_all_mas_instances(
263        &self,
264    ) -> fidl::client::QueryResponseFut<
265        AccessorListAllMasInstancesResult,
266        fidl::encoding::DefaultFuchsiaResourceDialect,
267    > {
268        AccessorProxyInterface::r#list_all_mas_instances(self)
269    }
270
271    /// Registers for notifications from the specified MAS instances.
272    /// Note that notification registration may only be open one at a time.
273    /// If the NotificationRegistration protocol is active when a new
274    /// request is made, the request will fail with an Unavailable error
275    /// until the existing channel is closed.
276    /// Hangs until registration process is completed.
277    /// + request `mas_instance_ids` If empty, registration for notifications
278    ///                               is done for all known MAS instances.
279    /// + request `server` Client end of the repository notifier protocol
280    ///                    that needs to be passed to the Accessor server.
281    ///                    Caller should hold onto the server end to
282    ///                    receive incoming notifications. Should not be empty.
283    pub fn r#set_notification_registration(
284        &self,
285        mut payload: AccessorSetNotificationRegistrationRequest,
286    ) -> fidl::client::QueryResponseFut<
287        AccessorSetNotificationRegistrationResult,
288        fidl::encoding::DefaultFuchsiaResourceDialect,
289    > {
290        AccessorProxyInterface::r#set_notification_registration(self, payload)
291    }
292}
293
294impl AccessorProxyInterface for AccessorProxy {
295    type GetDetailsResponseFut = fidl::client::QueryResponseFut<
296        MessageControllerGetDetailsResult,
297        fidl::encoding::DefaultFuchsiaResourceDialect,
298    >;
299    fn r#get_details(
300        &self,
301        mut handle: u64,
302        mut include_attachment: bool,
303    ) -> Self::GetDetailsResponseFut {
304        fn _decode(
305            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
306        ) -> Result<MessageControllerGetDetailsResult, fidl::Error> {
307            let _response = fidl::client::decode_transaction_body::<
308                fidl::encoding::FlexibleResultType<Message, Error>,
309                fidl::encoding::DefaultFuchsiaResourceDialect,
310                0x7c3667b69d66691e,
311            >(_buf?)?
312            .into_result::<AccessorMarker>("get_details")?;
313            Ok(_response.map(|x| x))
314        }
315        self.client.send_query_and_decode::<
316            MessageControllerGetDetailsRequest,
317            MessageControllerGetDetailsResult,
318        >(
319            (handle, include_attachment,),
320            0x7c3667b69d66691e,
321            fidl::encoding::DynamicFlags::FLEXIBLE,
322            _decode,
323        )
324    }
325
326    type ListAllMasInstancesResponseFut = fidl::client::QueryResponseFut<
327        AccessorListAllMasInstancesResult,
328        fidl::encoding::DefaultFuchsiaResourceDialect,
329    >;
330    fn r#list_all_mas_instances(&self) -> Self::ListAllMasInstancesResponseFut {
331        fn _decode(
332            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
333        ) -> Result<AccessorListAllMasInstancesResult, fidl::Error> {
334            let _response = fidl::client::decode_transaction_body::<
335                fidl::encoding::FlexibleResultType<AccessorListAllMasInstancesResponse, Error>,
336                fidl::encoding::DefaultFuchsiaResourceDialect,
337                0x6c78ebf9ba9780bd,
338            >(_buf?)?
339            .into_result::<AccessorMarker>("list_all_mas_instances")?;
340            Ok(_response.map(|x| x.instances))
341        }
342        self.client.send_query_and_decode::<
343            fidl::encoding::EmptyPayload,
344            AccessorListAllMasInstancesResult,
345        >(
346            (),
347            0x6c78ebf9ba9780bd,
348            fidl::encoding::DynamicFlags::FLEXIBLE,
349            _decode,
350        )
351    }
352
353    type SetNotificationRegistrationResponseFut = fidl::client::QueryResponseFut<
354        AccessorSetNotificationRegistrationResult,
355        fidl::encoding::DefaultFuchsiaResourceDialect,
356    >;
357    fn r#set_notification_registration(
358        &self,
359        mut payload: AccessorSetNotificationRegistrationRequest,
360    ) -> Self::SetNotificationRegistrationResponseFut {
361        fn _decode(
362            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
363        ) -> Result<AccessorSetNotificationRegistrationResult, fidl::Error> {
364            let _response = fidl::client::decode_transaction_body::<
365                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
366                fidl::encoding::DefaultFuchsiaResourceDialect,
367                0x3d764e196f83bd7c,
368            >(_buf?)?
369            .into_result::<AccessorMarker>("set_notification_registration")?;
370            Ok(_response.map(|x| x))
371        }
372        self.client.send_query_and_decode::<
373            AccessorSetNotificationRegistrationRequest,
374            AccessorSetNotificationRegistrationResult,
375        >(
376            &mut payload,
377            0x3d764e196f83bd7c,
378            fidl::encoding::DynamicFlags::FLEXIBLE,
379            _decode,
380        )
381    }
382}
383
384pub struct AccessorEventStream {
385    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
386}
387
388impl std::marker::Unpin for AccessorEventStream {}
389
390impl futures::stream::FusedStream for AccessorEventStream {
391    fn is_terminated(&self) -> bool {
392        self.event_receiver.is_terminated()
393    }
394}
395
396impl futures::Stream for AccessorEventStream {
397    type Item = Result<AccessorEvent, fidl::Error>;
398
399    fn poll_next(
400        mut self: std::pin::Pin<&mut Self>,
401        cx: &mut std::task::Context<'_>,
402    ) -> std::task::Poll<Option<Self::Item>> {
403        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
404            &mut self.event_receiver,
405            cx
406        )?) {
407            Some(buf) => std::task::Poll::Ready(Some(AccessorEvent::decode(buf))),
408            None => std::task::Poll::Ready(None),
409        }
410    }
411}
412
413#[derive(Debug)]
414pub enum AccessorEvent {
415    #[non_exhaustive]
416    _UnknownEvent {
417        /// Ordinal of the event that was sent.
418        ordinal: u64,
419    },
420}
421
422impl AccessorEvent {
423    /// Decodes a message buffer as a [`AccessorEvent`].
424    fn decode(
425        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
426    ) -> Result<AccessorEvent, fidl::Error> {
427        let (bytes, _handles) = buf.split_mut();
428        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
429        debug_assert_eq!(tx_header.tx_id, 0);
430        match tx_header.ordinal {
431            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
432                Ok(AccessorEvent::_UnknownEvent { ordinal: tx_header.ordinal })
433            }
434            _ => Err(fidl::Error::UnknownOrdinal {
435                ordinal: tx_header.ordinal,
436                protocol_name: <AccessorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
437            }),
438        }
439    }
440}
441
442/// A Stream of incoming requests for fuchsia.bluetooth.map/Accessor.
443pub struct AccessorRequestStream {
444    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
445    is_terminated: bool,
446}
447
448impl std::marker::Unpin for AccessorRequestStream {}
449
450impl futures::stream::FusedStream for AccessorRequestStream {
451    fn is_terminated(&self) -> bool {
452        self.is_terminated
453    }
454}
455
456impl fidl::endpoints::RequestStream for AccessorRequestStream {
457    type Protocol = AccessorMarker;
458    type ControlHandle = AccessorControlHandle;
459
460    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
461        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
462    }
463
464    fn control_handle(&self) -> Self::ControlHandle {
465        AccessorControlHandle { inner: self.inner.clone() }
466    }
467
468    fn into_inner(
469        self,
470    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
471    {
472        (self.inner, self.is_terminated)
473    }
474
475    fn from_inner(
476        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
477        is_terminated: bool,
478    ) -> Self {
479        Self { inner, is_terminated }
480    }
481}
482
483impl futures::Stream for AccessorRequestStream {
484    type Item = Result<AccessorRequest, fidl::Error>;
485
486    fn poll_next(
487        mut self: std::pin::Pin<&mut Self>,
488        cx: &mut std::task::Context<'_>,
489    ) -> std::task::Poll<Option<Self::Item>> {
490        let this = &mut *self;
491        if this.inner.check_shutdown(cx) {
492            this.is_terminated = true;
493            return std::task::Poll::Ready(None);
494        }
495        if this.is_terminated {
496            panic!("polled AccessorRequestStream after completion");
497        }
498        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
499            |bytes, handles| {
500                match this.inner.channel().read_etc(cx, bytes, handles) {
501                    std::task::Poll::Ready(Ok(())) => {}
502                    std::task::Poll::Pending => return std::task::Poll::Pending,
503                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
504                        this.is_terminated = true;
505                        return std::task::Poll::Ready(None);
506                    }
507                    std::task::Poll::Ready(Err(e)) => {
508                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
509                            e.into(),
510                        ))));
511                    }
512                }
513
514                // A message has been received from the channel
515                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
516
517                std::task::Poll::Ready(Some(match header.ordinal {
518                    0x7c3667b69d66691e => {
519                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
520                        let mut req = fidl::new_empty!(
521                            MessageControllerGetDetailsRequest,
522                            fidl::encoding::DefaultFuchsiaResourceDialect
523                        );
524                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<MessageControllerGetDetailsRequest>(&header, _body_bytes, handles, &mut req)?;
525                        let control_handle = AccessorControlHandle { inner: this.inner.clone() };
526                        Ok(AccessorRequest::GetDetails {
527                            handle: req.handle,
528                            include_attachment: req.include_attachment,
529
530                            responder: AccessorGetDetailsResponder {
531                                control_handle: std::mem::ManuallyDrop::new(control_handle),
532                                tx_id: header.tx_id,
533                            },
534                        })
535                    }
536                    0x6c78ebf9ba9780bd => {
537                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
538                        let mut req = fidl::new_empty!(
539                            fidl::encoding::EmptyPayload,
540                            fidl::encoding::DefaultFuchsiaResourceDialect
541                        );
542                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
543                        let control_handle = AccessorControlHandle { inner: this.inner.clone() };
544                        Ok(AccessorRequest::ListAllMasInstances {
545                            responder: AccessorListAllMasInstancesResponder {
546                                control_handle: std::mem::ManuallyDrop::new(control_handle),
547                                tx_id: header.tx_id,
548                            },
549                        })
550                    }
551                    0x3d764e196f83bd7c => {
552                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
553                        let mut req = fidl::new_empty!(
554                            AccessorSetNotificationRegistrationRequest,
555                            fidl::encoding::DefaultFuchsiaResourceDialect
556                        );
557                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AccessorSetNotificationRegistrationRequest>(&header, _body_bytes, handles, &mut req)?;
558                        let control_handle = AccessorControlHandle { inner: this.inner.clone() };
559                        Ok(AccessorRequest::SetNotificationRegistration {
560                            payload: req,
561                            responder: AccessorSetNotificationRegistrationResponder {
562                                control_handle: std::mem::ManuallyDrop::new(control_handle),
563                                tx_id: header.tx_id,
564                            },
565                        })
566                    }
567                    _ if header.tx_id == 0
568                        && header
569                            .dynamic_flags()
570                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
571                    {
572                        Ok(AccessorRequest::_UnknownMethod {
573                            ordinal: header.ordinal,
574                            control_handle: AccessorControlHandle { inner: this.inner.clone() },
575                            method_type: fidl::MethodType::OneWay,
576                        })
577                    }
578                    _ if header
579                        .dynamic_flags()
580                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
581                    {
582                        this.inner.send_framework_err(
583                            fidl::encoding::FrameworkErr::UnknownMethod,
584                            header.tx_id,
585                            header.ordinal,
586                            header.dynamic_flags(),
587                            (bytes, handles),
588                        )?;
589                        Ok(AccessorRequest::_UnknownMethod {
590                            ordinal: header.ordinal,
591                            control_handle: AccessorControlHandle { inner: this.inner.clone() },
592                            method_type: fidl::MethodType::TwoWay,
593                        })
594                    }
595                    _ => Err(fidl::Error::UnknownOrdinal {
596                        ordinal: header.ordinal,
597                        protocol_name:
598                            <AccessorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
599                    }),
600                }))
601            },
602        )
603    }
604}
605
606/// Protocol used for accessing messages and notifications for a connected Bluetooth peer.
607#[derive(Debug)]
608pub enum AccessorRequest {
609    /// Retrieve all available message details.
610    /// + request `handle` Unique identifier for a Messsage.
611    /// + request `include_attachment` Whether or not attachment should be included as
612    ///                                part of Message content if it's available.
613    /// - response NOT_FOUND error is returned if the message with the given handle does not exist.
614    GetDetails {
615        handle: u64,
616        include_attachment: bool,
617        responder: AccessorGetDetailsResponder,
618    },
619    ListAllMasInstances {
620        responder: AccessorListAllMasInstancesResponder,
621    },
622    /// Registers for notifications from the specified MAS instances.
623    /// Note that notification registration may only be open one at a time.
624    /// If the NotificationRegistration protocol is active when a new
625    /// request is made, the request will fail with an Unavailable error
626    /// until the existing channel is closed.
627    /// Hangs until registration process is completed.
628    /// + request `mas_instance_ids` If empty, registration for notifications
629    ///                               is done for all known MAS instances.
630    /// + request `server` Client end of the repository notifier protocol
631    ///                    that needs to be passed to the Accessor server.
632    ///                    Caller should hold onto the server end to
633    ///                    receive incoming notifications. Should not be empty.
634    SetNotificationRegistration {
635        payload: AccessorSetNotificationRegistrationRequest,
636        responder: AccessorSetNotificationRegistrationResponder,
637    },
638    /// An interaction was received which does not match any known method.
639    #[non_exhaustive]
640    _UnknownMethod {
641        /// Ordinal of the method that was called.
642        ordinal: u64,
643        control_handle: AccessorControlHandle,
644        method_type: fidl::MethodType,
645    },
646}
647
648impl AccessorRequest {
649    #[allow(irrefutable_let_patterns)]
650    pub fn into_get_details(self) -> Option<(u64, bool, AccessorGetDetailsResponder)> {
651        if let AccessorRequest::GetDetails { handle, include_attachment, responder } = self {
652            Some((handle, include_attachment, responder))
653        } else {
654            None
655        }
656    }
657
658    #[allow(irrefutable_let_patterns)]
659    pub fn into_list_all_mas_instances(self) -> Option<(AccessorListAllMasInstancesResponder)> {
660        if let AccessorRequest::ListAllMasInstances { responder } = self {
661            Some((responder))
662        } else {
663            None
664        }
665    }
666
667    #[allow(irrefutable_let_patterns)]
668    pub fn into_set_notification_registration(
669        self,
670    ) -> Option<(
671        AccessorSetNotificationRegistrationRequest,
672        AccessorSetNotificationRegistrationResponder,
673    )> {
674        if let AccessorRequest::SetNotificationRegistration { payload, responder } = self {
675            Some((payload, responder))
676        } else {
677            None
678        }
679    }
680
681    /// Name of the method defined in FIDL
682    pub fn method_name(&self) -> &'static str {
683        match *self {
684            AccessorRequest::GetDetails { .. } => "get_details",
685            AccessorRequest::ListAllMasInstances { .. } => "list_all_mas_instances",
686            AccessorRequest::SetNotificationRegistration { .. } => "set_notification_registration",
687            AccessorRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
688                "unknown one-way method"
689            }
690            AccessorRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
691                "unknown two-way method"
692            }
693        }
694    }
695}
696
697#[derive(Debug, Clone)]
698pub struct AccessorControlHandle {
699    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
700}
701
702impl AccessorControlHandle {
703    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
704        self.inner.shutdown_with_epitaph(status.into())
705    }
706}
707
708impl fidl::endpoints::ControlHandle for AccessorControlHandle {
709    fn shutdown(&self) {
710        self.inner.shutdown()
711    }
712
713    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
714        self.inner.shutdown_with_epitaph(status)
715    }
716
717    fn is_closed(&self) -> bool {
718        self.inner.channel().is_closed()
719    }
720    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
721        self.inner.channel().on_closed()
722    }
723
724    #[cfg(target_os = "fuchsia")]
725    fn signal_peer(
726        &self,
727        clear_mask: zx::Signals,
728        set_mask: zx::Signals,
729    ) -> Result<(), zx_status::Status> {
730        use fidl::Peered;
731        self.inner.channel().signal_peer(clear_mask, set_mask)
732    }
733}
734
735impl AccessorControlHandle {}
736
737#[must_use = "FIDL methods require a response to be sent"]
738#[derive(Debug)]
739pub struct AccessorGetDetailsResponder {
740    control_handle: std::mem::ManuallyDrop<AccessorControlHandle>,
741    tx_id: u32,
742}
743
744/// Set the the channel to be shutdown (see [`AccessorControlHandle::shutdown`])
745/// if the responder is dropped without sending a response, so that the client
746/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
747impl std::ops::Drop for AccessorGetDetailsResponder {
748    fn drop(&mut self) {
749        self.control_handle.shutdown();
750        // Safety: drops once, never accessed again
751        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
752    }
753}
754
755impl fidl::endpoints::Responder for AccessorGetDetailsResponder {
756    type ControlHandle = AccessorControlHandle;
757
758    fn control_handle(&self) -> &AccessorControlHandle {
759        &self.control_handle
760    }
761
762    fn drop_without_shutdown(mut self) {
763        // Safety: drops once, never accessed again due to mem::forget
764        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
765        // Prevent Drop from running (which would shut down the channel)
766        std::mem::forget(self);
767    }
768}
769
770impl AccessorGetDetailsResponder {
771    /// Sends a response to the FIDL transaction.
772    ///
773    /// Sets the channel to shutdown if an error occurs.
774    pub fn send(self, mut result: Result<&Message, Error>) -> Result<(), fidl::Error> {
775        let _result = self.send_raw(result);
776        if _result.is_err() {
777            self.control_handle.shutdown();
778        }
779        self.drop_without_shutdown();
780        _result
781    }
782
783    /// Similar to "send" but does not shutdown the channel if an error occurs.
784    pub fn send_no_shutdown_on_err(
785        self,
786        mut result: Result<&Message, Error>,
787    ) -> Result<(), fidl::Error> {
788        let _result = self.send_raw(result);
789        self.drop_without_shutdown();
790        _result
791    }
792
793    fn send_raw(&self, mut result: Result<&Message, Error>) -> Result<(), fidl::Error> {
794        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<Message, Error>>(
795            fidl::encoding::FlexibleResult::new(result),
796            self.tx_id,
797            0x7c3667b69d66691e,
798            fidl::encoding::DynamicFlags::FLEXIBLE,
799        )
800    }
801}
802
803#[must_use = "FIDL methods require a response to be sent"]
804#[derive(Debug)]
805pub struct AccessorListAllMasInstancesResponder {
806    control_handle: std::mem::ManuallyDrop<AccessorControlHandle>,
807    tx_id: u32,
808}
809
810/// Set the the channel to be shutdown (see [`AccessorControlHandle::shutdown`])
811/// if the responder is dropped without sending a response, so that the client
812/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
813impl std::ops::Drop for AccessorListAllMasInstancesResponder {
814    fn drop(&mut self) {
815        self.control_handle.shutdown();
816        // Safety: drops once, never accessed again
817        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
818    }
819}
820
821impl fidl::endpoints::Responder for AccessorListAllMasInstancesResponder {
822    type ControlHandle = AccessorControlHandle;
823
824    fn control_handle(&self) -> &AccessorControlHandle {
825        &self.control_handle
826    }
827
828    fn drop_without_shutdown(mut self) {
829        // Safety: drops once, never accessed again due to mem::forget
830        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
831        // Prevent Drop from running (which would shut down the channel)
832        std::mem::forget(self);
833    }
834}
835
836impl AccessorListAllMasInstancesResponder {
837    /// Sends a response to the FIDL transaction.
838    ///
839    /// Sets the channel to shutdown if an error occurs.
840    pub fn send(self, mut result: Result<&[MasInstance], Error>) -> Result<(), fidl::Error> {
841        let _result = self.send_raw(result);
842        if _result.is_err() {
843            self.control_handle.shutdown();
844        }
845        self.drop_without_shutdown();
846        _result
847    }
848
849    /// Similar to "send" but does not shutdown the channel if an error occurs.
850    pub fn send_no_shutdown_on_err(
851        self,
852        mut result: Result<&[MasInstance], Error>,
853    ) -> Result<(), fidl::Error> {
854        let _result = self.send_raw(result);
855        self.drop_without_shutdown();
856        _result
857    }
858
859    fn send_raw(&self, mut result: Result<&[MasInstance], Error>) -> Result<(), fidl::Error> {
860        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
861            AccessorListAllMasInstancesResponse,
862            Error,
863        >>(
864            fidl::encoding::FlexibleResult::new(result.map(|instances| (instances,))),
865            self.tx_id,
866            0x6c78ebf9ba9780bd,
867            fidl::encoding::DynamicFlags::FLEXIBLE,
868        )
869    }
870}
871
872#[must_use = "FIDL methods require a response to be sent"]
873#[derive(Debug)]
874pub struct AccessorSetNotificationRegistrationResponder {
875    control_handle: std::mem::ManuallyDrop<AccessorControlHandle>,
876    tx_id: u32,
877}
878
879/// Set the the channel to be shutdown (see [`AccessorControlHandle::shutdown`])
880/// if the responder is dropped without sending a response, so that the client
881/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
882impl std::ops::Drop for AccessorSetNotificationRegistrationResponder {
883    fn drop(&mut self) {
884        self.control_handle.shutdown();
885        // Safety: drops once, never accessed again
886        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
887    }
888}
889
890impl fidl::endpoints::Responder for AccessorSetNotificationRegistrationResponder {
891    type ControlHandle = AccessorControlHandle;
892
893    fn control_handle(&self) -> &AccessorControlHandle {
894        &self.control_handle
895    }
896
897    fn drop_without_shutdown(mut self) {
898        // Safety: drops once, never accessed again due to mem::forget
899        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
900        // Prevent Drop from running (which would shut down the channel)
901        std::mem::forget(self);
902    }
903}
904
905impl AccessorSetNotificationRegistrationResponder {
906    /// Sends a response to the FIDL transaction.
907    ///
908    /// Sets the channel to shutdown if an error occurs.
909    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
910        let _result = self.send_raw(result);
911        if _result.is_err() {
912            self.control_handle.shutdown();
913        }
914        self.drop_without_shutdown();
915        _result
916    }
917
918    /// Similar to "send" but does not shutdown the channel if an error occurs.
919    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
920        let _result = self.send_raw(result);
921        self.drop_without_shutdown();
922        _result
923    }
924
925    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
926        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
927            fidl::encoding::EmptyStruct,
928            Error,
929        >>(
930            fidl::encoding::FlexibleResult::new(result),
931            self.tx_id,
932            0x3d764e196f83bd7c,
933            fidl::encoding::DynamicFlags::FLEXIBLE,
934        )
935    }
936}
937
938#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
939pub struct MessageControllerMarker;
940
941impl fidl::endpoints::ProtocolMarker for MessageControllerMarker {
942    type Proxy = MessageControllerProxy;
943    type RequestStream = MessageControllerRequestStream;
944    #[cfg(target_os = "fuchsia")]
945    type SynchronousProxy = MessageControllerSynchronousProxy;
946
947    const DEBUG_NAME: &'static str = "(anonymous) MessageController";
948}
949pub type MessageControllerGetDetailsResult = Result<Message, Error>;
950
951pub trait MessageControllerProxyInterface: Send + Sync {
952    type GetDetailsResponseFut: std::future::Future<Output = Result<MessageControllerGetDetailsResult, fidl::Error>>
953        + Send;
954    fn r#get_details(&self, handle: u64, include_attachment: bool) -> Self::GetDetailsResponseFut;
955}
956#[derive(Debug)]
957#[cfg(target_os = "fuchsia")]
958pub struct MessageControllerSynchronousProxy {
959    client: fidl::client::sync::Client,
960}
961
962#[cfg(target_os = "fuchsia")]
963impl fidl::endpoints::SynchronousProxy for MessageControllerSynchronousProxy {
964    type Proxy = MessageControllerProxy;
965    type Protocol = MessageControllerMarker;
966
967    fn from_channel(inner: fidl::Channel) -> Self {
968        Self::new(inner)
969    }
970
971    fn into_channel(self) -> fidl::Channel {
972        self.client.into_channel()
973    }
974
975    fn as_channel(&self) -> &fidl::Channel {
976        self.client.as_channel()
977    }
978}
979
980#[cfg(target_os = "fuchsia")]
981impl MessageControllerSynchronousProxy {
982    pub fn new(channel: fidl::Channel) -> Self {
983        Self { client: fidl::client::sync::Client::new(channel) }
984    }
985
986    pub fn into_channel(self) -> fidl::Channel {
987        self.client.into_channel()
988    }
989
990    /// Waits until an event arrives and returns it. It is safe for other
991    /// threads to make concurrent requests while waiting for an event.
992    pub fn wait_for_event(
993        &self,
994        deadline: zx::MonotonicInstant,
995    ) -> Result<MessageControllerEvent, fidl::Error> {
996        MessageControllerEvent::decode(
997            self.client.wait_for_event::<MessageControllerMarker>(deadline)?,
998        )
999    }
1000
1001    /// Retrieve all available message details.
1002    /// + request `handle` Unique identifier for a Messsage.
1003    /// + request `include_attachment` Whether or not attachment should be included as
1004    ///                                part of Message content if it's available.
1005    /// - response NOT_FOUND error is returned if the message with the given handle does not exist.
1006    pub fn r#get_details(
1007        &self,
1008        mut handle: u64,
1009        mut include_attachment: bool,
1010        ___deadline: zx::MonotonicInstant,
1011    ) -> Result<MessageControllerGetDetailsResult, fidl::Error> {
1012        let _response = self.client.send_query::<
1013            MessageControllerGetDetailsRequest,
1014            fidl::encoding::FlexibleResultType<Message, Error>,
1015            MessageControllerMarker,
1016        >(
1017            (handle, include_attachment,),
1018            0x7c3667b69d66691e,
1019            fidl::encoding::DynamicFlags::FLEXIBLE,
1020            ___deadline,
1021        )?
1022        .into_result::<MessageControllerMarker>("get_details")?;
1023        Ok(_response.map(|x| x))
1024    }
1025}
1026
1027#[cfg(target_os = "fuchsia")]
1028impl From<MessageControllerSynchronousProxy> for zx::NullableHandle {
1029    fn from(value: MessageControllerSynchronousProxy) -> Self {
1030        value.into_channel().into()
1031    }
1032}
1033
1034#[cfg(target_os = "fuchsia")]
1035impl From<fidl::Channel> for MessageControllerSynchronousProxy {
1036    fn from(value: fidl::Channel) -> Self {
1037        Self::new(value)
1038    }
1039}
1040
1041#[cfg(target_os = "fuchsia")]
1042impl fidl::endpoints::FromClient for MessageControllerSynchronousProxy {
1043    type Protocol = MessageControllerMarker;
1044
1045    fn from_client(value: fidl::endpoints::ClientEnd<MessageControllerMarker>) -> Self {
1046        Self::new(value.into_channel())
1047    }
1048}
1049
1050#[derive(Debug, Clone)]
1051pub struct MessageControllerProxy {
1052    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1053}
1054
1055impl fidl::endpoints::Proxy for MessageControllerProxy {
1056    type Protocol = MessageControllerMarker;
1057
1058    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1059        Self::new(inner)
1060    }
1061
1062    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1063        self.client.into_channel().map_err(|client| Self { client })
1064    }
1065
1066    fn as_channel(&self) -> &::fidl::AsyncChannel {
1067        self.client.as_channel()
1068    }
1069}
1070
1071impl MessageControllerProxy {
1072    /// Create a new Proxy for fuchsia.bluetooth.map/MessageController.
1073    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1074        let protocol_name =
1075            <MessageControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1076        Self { client: fidl::client::Client::new(channel, protocol_name) }
1077    }
1078
1079    /// Get a Stream of events from the remote end of the protocol.
1080    ///
1081    /// # Panics
1082    ///
1083    /// Panics if the event stream was already taken.
1084    pub fn take_event_stream(&self) -> MessageControllerEventStream {
1085        MessageControllerEventStream { event_receiver: self.client.take_event_receiver() }
1086    }
1087
1088    /// Retrieve all available message details.
1089    /// + request `handle` Unique identifier for a Messsage.
1090    /// + request `include_attachment` Whether or not attachment should be included as
1091    ///                                part of Message content if it's available.
1092    /// - response NOT_FOUND error is returned if the message with the given handle does not exist.
1093    pub fn r#get_details(
1094        &self,
1095        mut handle: u64,
1096        mut include_attachment: bool,
1097    ) -> fidl::client::QueryResponseFut<
1098        MessageControllerGetDetailsResult,
1099        fidl::encoding::DefaultFuchsiaResourceDialect,
1100    > {
1101        MessageControllerProxyInterface::r#get_details(self, handle, include_attachment)
1102    }
1103}
1104
1105impl MessageControllerProxyInterface for MessageControllerProxy {
1106    type GetDetailsResponseFut = fidl::client::QueryResponseFut<
1107        MessageControllerGetDetailsResult,
1108        fidl::encoding::DefaultFuchsiaResourceDialect,
1109    >;
1110    fn r#get_details(
1111        &self,
1112        mut handle: u64,
1113        mut include_attachment: bool,
1114    ) -> Self::GetDetailsResponseFut {
1115        fn _decode(
1116            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1117        ) -> Result<MessageControllerGetDetailsResult, fidl::Error> {
1118            let _response = fidl::client::decode_transaction_body::<
1119                fidl::encoding::FlexibleResultType<Message, Error>,
1120                fidl::encoding::DefaultFuchsiaResourceDialect,
1121                0x7c3667b69d66691e,
1122            >(_buf?)?
1123            .into_result::<MessageControllerMarker>("get_details")?;
1124            Ok(_response.map(|x| x))
1125        }
1126        self.client.send_query_and_decode::<
1127            MessageControllerGetDetailsRequest,
1128            MessageControllerGetDetailsResult,
1129        >(
1130            (handle, include_attachment,),
1131            0x7c3667b69d66691e,
1132            fidl::encoding::DynamicFlags::FLEXIBLE,
1133            _decode,
1134        )
1135    }
1136}
1137
1138pub struct MessageControllerEventStream {
1139    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1140}
1141
1142impl std::marker::Unpin for MessageControllerEventStream {}
1143
1144impl futures::stream::FusedStream for MessageControllerEventStream {
1145    fn is_terminated(&self) -> bool {
1146        self.event_receiver.is_terminated()
1147    }
1148}
1149
1150impl futures::Stream for MessageControllerEventStream {
1151    type Item = Result<MessageControllerEvent, fidl::Error>;
1152
1153    fn poll_next(
1154        mut self: std::pin::Pin<&mut Self>,
1155        cx: &mut std::task::Context<'_>,
1156    ) -> std::task::Poll<Option<Self::Item>> {
1157        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1158            &mut self.event_receiver,
1159            cx
1160        )?) {
1161            Some(buf) => std::task::Poll::Ready(Some(MessageControllerEvent::decode(buf))),
1162            None => std::task::Poll::Ready(None),
1163        }
1164    }
1165}
1166
1167#[derive(Debug)]
1168pub enum MessageControllerEvent {
1169    #[non_exhaustive]
1170    _UnknownEvent {
1171        /// Ordinal of the event that was sent.
1172        ordinal: u64,
1173    },
1174}
1175
1176impl MessageControllerEvent {
1177    /// Decodes a message buffer as a [`MessageControllerEvent`].
1178    fn decode(
1179        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1180    ) -> Result<MessageControllerEvent, fidl::Error> {
1181        let (bytes, _handles) = buf.split_mut();
1182        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1183        debug_assert_eq!(tx_header.tx_id, 0);
1184        match tx_header.ordinal {
1185            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1186                Ok(MessageControllerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1187            }
1188            _ => Err(fidl::Error::UnknownOrdinal {
1189                ordinal: tx_header.ordinal,
1190                protocol_name:
1191                    <MessageControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1192            }),
1193        }
1194    }
1195}
1196
1197/// A Stream of incoming requests for fuchsia.bluetooth.map/MessageController.
1198pub struct MessageControllerRequestStream {
1199    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1200    is_terminated: bool,
1201}
1202
1203impl std::marker::Unpin for MessageControllerRequestStream {}
1204
1205impl futures::stream::FusedStream for MessageControllerRequestStream {
1206    fn is_terminated(&self) -> bool {
1207        self.is_terminated
1208    }
1209}
1210
1211impl fidl::endpoints::RequestStream for MessageControllerRequestStream {
1212    type Protocol = MessageControllerMarker;
1213    type ControlHandle = MessageControllerControlHandle;
1214
1215    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1216        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1217    }
1218
1219    fn control_handle(&self) -> Self::ControlHandle {
1220        MessageControllerControlHandle { inner: self.inner.clone() }
1221    }
1222
1223    fn into_inner(
1224        self,
1225    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1226    {
1227        (self.inner, self.is_terminated)
1228    }
1229
1230    fn from_inner(
1231        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1232        is_terminated: bool,
1233    ) -> Self {
1234        Self { inner, is_terminated }
1235    }
1236}
1237
1238impl futures::Stream for MessageControllerRequestStream {
1239    type Item = Result<MessageControllerRequest, fidl::Error>;
1240
1241    fn poll_next(
1242        mut self: std::pin::Pin<&mut Self>,
1243        cx: &mut std::task::Context<'_>,
1244    ) -> std::task::Poll<Option<Self::Item>> {
1245        let this = &mut *self;
1246        if this.inner.check_shutdown(cx) {
1247            this.is_terminated = true;
1248            return std::task::Poll::Ready(None);
1249        }
1250        if this.is_terminated {
1251            panic!("polled MessageControllerRequestStream after completion");
1252        }
1253        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1254            |bytes, handles| {
1255                match this.inner.channel().read_etc(cx, bytes, handles) {
1256                    std::task::Poll::Ready(Ok(())) => {}
1257                    std::task::Poll::Pending => return std::task::Poll::Pending,
1258                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1259                        this.is_terminated = true;
1260                        return std::task::Poll::Ready(None);
1261                    }
1262                    std::task::Poll::Ready(Err(e)) => {
1263                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1264                            e.into(),
1265                        ))));
1266                    }
1267                }
1268
1269                // A message has been received from the channel
1270                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1271
1272                std::task::Poll::Ready(Some(match header.ordinal {
1273                    0x7c3667b69d66691e => {
1274                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1275                        let mut req = fidl::new_empty!(
1276                            MessageControllerGetDetailsRequest,
1277                            fidl::encoding::DefaultFuchsiaResourceDialect
1278                        );
1279                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<MessageControllerGetDetailsRequest>(&header, _body_bytes, handles, &mut req)?;
1280                        let control_handle =
1281                            MessageControllerControlHandle { inner: this.inner.clone() };
1282                        Ok(MessageControllerRequest::GetDetails {
1283                            handle: req.handle,
1284                            include_attachment: req.include_attachment,
1285
1286                            responder: MessageControllerGetDetailsResponder {
1287                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1288                                tx_id: header.tx_id,
1289                            },
1290                        })
1291                    }
1292                    _ if header.tx_id == 0
1293                        && header
1294                            .dynamic_flags()
1295                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1296                    {
1297                        Ok(MessageControllerRequest::_UnknownMethod {
1298                            ordinal: header.ordinal,
1299                            control_handle: MessageControllerControlHandle {
1300                                inner: this.inner.clone(),
1301                            },
1302                            method_type: fidl::MethodType::OneWay,
1303                        })
1304                    }
1305                    _ if header
1306                        .dynamic_flags()
1307                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1308                    {
1309                        this.inner.send_framework_err(
1310                            fidl::encoding::FrameworkErr::UnknownMethod,
1311                            header.tx_id,
1312                            header.ordinal,
1313                            header.dynamic_flags(),
1314                            (bytes, handles),
1315                        )?;
1316                        Ok(MessageControllerRequest::_UnknownMethod {
1317                            ordinal: header.ordinal,
1318                            control_handle: MessageControllerControlHandle {
1319                                inner: this.inner.clone(),
1320                            },
1321                            method_type: fidl::MethodType::TwoWay,
1322                        })
1323                    }
1324                    _ => Err(fidl::Error::UnknownOrdinal {
1325                        ordinal: header.ordinal,
1326                        protocol_name:
1327                            <MessageControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1328                    }),
1329                }))
1330            },
1331        )
1332    }
1333}
1334
1335#[derive(Debug)]
1336pub enum MessageControllerRequest {
1337    /// Retrieve all available message details.
1338    /// + request `handle` Unique identifier for a Messsage.
1339    /// + request `include_attachment` Whether or not attachment should be included as
1340    ///                                part of Message content if it's available.
1341    /// - response NOT_FOUND error is returned if the message with the given handle does not exist.
1342    GetDetails {
1343        handle: u64,
1344        include_attachment: bool,
1345        responder: MessageControllerGetDetailsResponder,
1346    },
1347    /// An interaction was received which does not match any known method.
1348    #[non_exhaustive]
1349    _UnknownMethod {
1350        /// Ordinal of the method that was called.
1351        ordinal: u64,
1352        control_handle: MessageControllerControlHandle,
1353        method_type: fidl::MethodType,
1354    },
1355}
1356
1357impl MessageControllerRequest {
1358    #[allow(irrefutable_let_patterns)]
1359    pub fn into_get_details(self) -> Option<(u64, bool, MessageControllerGetDetailsResponder)> {
1360        if let MessageControllerRequest::GetDetails { handle, include_attachment, responder } = self
1361        {
1362            Some((handle, include_attachment, responder))
1363        } else {
1364            None
1365        }
1366    }
1367
1368    /// Name of the method defined in FIDL
1369    pub fn method_name(&self) -> &'static str {
1370        match *self {
1371            MessageControllerRequest::GetDetails { .. } => "get_details",
1372            MessageControllerRequest::_UnknownMethod {
1373                method_type: fidl::MethodType::OneWay,
1374                ..
1375            } => "unknown one-way method",
1376            MessageControllerRequest::_UnknownMethod {
1377                method_type: fidl::MethodType::TwoWay,
1378                ..
1379            } => "unknown two-way method",
1380        }
1381    }
1382}
1383
1384#[derive(Debug, Clone)]
1385pub struct MessageControllerControlHandle {
1386    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1387}
1388
1389impl MessageControllerControlHandle {
1390    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1391        self.inner.shutdown_with_epitaph(status.into())
1392    }
1393}
1394
1395impl fidl::endpoints::ControlHandle for MessageControllerControlHandle {
1396    fn shutdown(&self) {
1397        self.inner.shutdown()
1398    }
1399
1400    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1401        self.inner.shutdown_with_epitaph(status)
1402    }
1403
1404    fn is_closed(&self) -> bool {
1405        self.inner.channel().is_closed()
1406    }
1407    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1408        self.inner.channel().on_closed()
1409    }
1410
1411    #[cfg(target_os = "fuchsia")]
1412    fn signal_peer(
1413        &self,
1414        clear_mask: zx::Signals,
1415        set_mask: zx::Signals,
1416    ) -> Result<(), zx_status::Status> {
1417        use fidl::Peered;
1418        self.inner.channel().signal_peer(clear_mask, set_mask)
1419    }
1420}
1421
1422impl MessageControllerControlHandle {}
1423
1424#[must_use = "FIDL methods require a response to be sent"]
1425#[derive(Debug)]
1426pub struct MessageControllerGetDetailsResponder {
1427    control_handle: std::mem::ManuallyDrop<MessageControllerControlHandle>,
1428    tx_id: u32,
1429}
1430
1431/// Set the the channel to be shutdown (see [`MessageControllerControlHandle::shutdown`])
1432/// if the responder is dropped without sending a response, so that the client
1433/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1434impl std::ops::Drop for MessageControllerGetDetailsResponder {
1435    fn drop(&mut self) {
1436        self.control_handle.shutdown();
1437        // Safety: drops once, never accessed again
1438        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1439    }
1440}
1441
1442impl fidl::endpoints::Responder for MessageControllerGetDetailsResponder {
1443    type ControlHandle = MessageControllerControlHandle;
1444
1445    fn control_handle(&self) -> &MessageControllerControlHandle {
1446        &self.control_handle
1447    }
1448
1449    fn drop_without_shutdown(mut self) {
1450        // Safety: drops once, never accessed again due to mem::forget
1451        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1452        // Prevent Drop from running (which would shut down the channel)
1453        std::mem::forget(self);
1454    }
1455}
1456
1457impl MessageControllerGetDetailsResponder {
1458    /// Sends a response to the FIDL transaction.
1459    ///
1460    /// Sets the channel to shutdown if an error occurs.
1461    pub fn send(self, mut result: Result<&Message, Error>) -> Result<(), fidl::Error> {
1462        let _result = self.send_raw(result);
1463        if _result.is_err() {
1464            self.control_handle.shutdown();
1465        }
1466        self.drop_without_shutdown();
1467        _result
1468    }
1469
1470    /// Similar to "send" but does not shutdown the channel if an error occurs.
1471    pub fn send_no_shutdown_on_err(
1472        self,
1473        mut result: Result<&Message, Error>,
1474    ) -> Result<(), fidl::Error> {
1475        let _result = self.send_raw(result);
1476        self.drop_without_shutdown();
1477        _result
1478    }
1479
1480    fn send_raw(&self, mut result: Result<&Message, Error>) -> Result<(), fidl::Error> {
1481        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<Message, Error>>(
1482            fidl::encoding::FlexibleResult::new(result),
1483            self.tx_id,
1484            0x7c3667b69d66691e,
1485            fidl::encoding::DynamicFlags::FLEXIBLE,
1486        )
1487    }
1488}
1489
1490#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1491pub struct MessagingClientMarker;
1492
1493impl fidl::endpoints::ProtocolMarker for MessagingClientMarker {
1494    type Proxy = MessagingClientProxy;
1495    type RequestStream = MessagingClientRequestStream;
1496    #[cfg(target_os = "fuchsia")]
1497    type SynchronousProxy = MessagingClientSynchronousProxy;
1498
1499    const DEBUG_NAME: &'static str = "fuchsia.bluetooth.map.MessagingClient";
1500}
1501impl fidl::endpoints::DiscoverableProtocolMarker for MessagingClientMarker {}
1502pub type MessagingClientWatchAccessorResult = Result<MessagingClientWatchAccessorResponse, Error>;
1503
1504pub trait MessagingClientProxyInterface: Send + Sync {
1505    type WatchAccessorResponseFut: std::future::Future<Output = Result<MessagingClientWatchAccessorResult, fidl::Error>>
1506        + Send;
1507    fn r#watch_accessor(&self) -> Self::WatchAccessorResponseFut;
1508}
1509#[derive(Debug)]
1510#[cfg(target_os = "fuchsia")]
1511pub struct MessagingClientSynchronousProxy {
1512    client: fidl::client::sync::Client,
1513}
1514
1515#[cfg(target_os = "fuchsia")]
1516impl fidl::endpoints::SynchronousProxy for MessagingClientSynchronousProxy {
1517    type Proxy = MessagingClientProxy;
1518    type Protocol = MessagingClientMarker;
1519
1520    fn from_channel(inner: fidl::Channel) -> Self {
1521        Self::new(inner)
1522    }
1523
1524    fn into_channel(self) -> fidl::Channel {
1525        self.client.into_channel()
1526    }
1527
1528    fn as_channel(&self) -> &fidl::Channel {
1529        self.client.as_channel()
1530    }
1531}
1532
1533#[cfg(target_os = "fuchsia")]
1534impl MessagingClientSynchronousProxy {
1535    pub fn new(channel: fidl::Channel) -> Self {
1536        Self { client: fidl::client::sync::Client::new(channel) }
1537    }
1538
1539    pub fn into_channel(self) -> fidl::Channel {
1540        self.client.into_channel()
1541    }
1542
1543    /// Waits until an event arrives and returns it. It is safe for other
1544    /// threads to make concurrent requests while waiting for an event.
1545    pub fn wait_for_event(
1546        &self,
1547        deadline: zx::MonotonicInstant,
1548    ) -> Result<MessagingClientEvent, fidl::Error> {
1549        MessagingClientEvent::decode(self.client.wait_for_event::<MessagingClientMarker>(deadline)?)
1550    }
1551
1552    /// An `Accessor` will be returned for each peer as they are
1553    /// connected, and only one exists at a time for each peer.
1554    /// Hangs until a new peer becomes available once all connected
1555    /// peers have been delivered through this protocol.
1556    /// Returns an error if [WatchAccessor] is called again when there
1557    /// already is a pending request.
1558    pub fn r#watch_accessor(
1559        &self,
1560        ___deadline: zx::MonotonicInstant,
1561    ) -> Result<MessagingClientWatchAccessorResult, fidl::Error> {
1562        let _response = self.client.send_query::<
1563            fidl::encoding::EmptyPayload,
1564            fidl::encoding::FlexibleResultType<MessagingClientWatchAccessorResponse, Error>,
1565            MessagingClientMarker,
1566        >(
1567            (),
1568            0x269e876c67302299,
1569            fidl::encoding::DynamicFlags::FLEXIBLE,
1570            ___deadline,
1571        )?
1572        .into_result::<MessagingClientMarker>("watch_accessor")?;
1573        Ok(_response.map(|x| x))
1574    }
1575}
1576
1577#[cfg(target_os = "fuchsia")]
1578impl From<MessagingClientSynchronousProxy> for zx::NullableHandle {
1579    fn from(value: MessagingClientSynchronousProxy) -> Self {
1580        value.into_channel().into()
1581    }
1582}
1583
1584#[cfg(target_os = "fuchsia")]
1585impl From<fidl::Channel> for MessagingClientSynchronousProxy {
1586    fn from(value: fidl::Channel) -> Self {
1587        Self::new(value)
1588    }
1589}
1590
1591#[cfg(target_os = "fuchsia")]
1592impl fidl::endpoints::FromClient for MessagingClientSynchronousProxy {
1593    type Protocol = MessagingClientMarker;
1594
1595    fn from_client(value: fidl::endpoints::ClientEnd<MessagingClientMarker>) -> Self {
1596        Self::new(value.into_channel())
1597    }
1598}
1599
1600#[derive(Debug, Clone)]
1601pub struct MessagingClientProxy {
1602    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1603}
1604
1605impl fidl::endpoints::Proxy for MessagingClientProxy {
1606    type Protocol = MessagingClientMarker;
1607
1608    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1609        Self::new(inner)
1610    }
1611
1612    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1613        self.client.into_channel().map_err(|client| Self { client })
1614    }
1615
1616    fn as_channel(&self) -> &::fidl::AsyncChannel {
1617        self.client.as_channel()
1618    }
1619}
1620
1621impl MessagingClientProxy {
1622    /// Create a new Proxy for fuchsia.bluetooth.map/MessagingClient.
1623    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1624        let protocol_name = <MessagingClientMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1625        Self { client: fidl::client::Client::new(channel, protocol_name) }
1626    }
1627
1628    /// Get a Stream of events from the remote end of the protocol.
1629    ///
1630    /// # Panics
1631    ///
1632    /// Panics if the event stream was already taken.
1633    pub fn take_event_stream(&self) -> MessagingClientEventStream {
1634        MessagingClientEventStream { event_receiver: self.client.take_event_receiver() }
1635    }
1636
1637    /// An `Accessor` will be returned for each peer as they are
1638    /// connected, and only one exists at a time for each peer.
1639    /// Hangs until a new peer becomes available once all connected
1640    /// peers have been delivered through this protocol.
1641    /// Returns an error if [WatchAccessor] is called again when there
1642    /// already is a pending request.
1643    pub fn r#watch_accessor(
1644        &self,
1645    ) -> fidl::client::QueryResponseFut<
1646        MessagingClientWatchAccessorResult,
1647        fidl::encoding::DefaultFuchsiaResourceDialect,
1648    > {
1649        MessagingClientProxyInterface::r#watch_accessor(self)
1650    }
1651}
1652
1653impl MessagingClientProxyInterface for MessagingClientProxy {
1654    type WatchAccessorResponseFut = fidl::client::QueryResponseFut<
1655        MessagingClientWatchAccessorResult,
1656        fidl::encoding::DefaultFuchsiaResourceDialect,
1657    >;
1658    fn r#watch_accessor(&self) -> Self::WatchAccessorResponseFut {
1659        fn _decode(
1660            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1661        ) -> Result<MessagingClientWatchAccessorResult, fidl::Error> {
1662            let _response = fidl::client::decode_transaction_body::<
1663                fidl::encoding::FlexibleResultType<MessagingClientWatchAccessorResponse, Error>,
1664                fidl::encoding::DefaultFuchsiaResourceDialect,
1665                0x269e876c67302299,
1666            >(_buf?)?
1667            .into_result::<MessagingClientMarker>("watch_accessor")?;
1668            Ok(_response.map(|x| x))
1669        }
1670        self.client.send_query_and_decode::<
1671            fidl::encoding::EmptyPayload,
1672            MessagingClientWatchAccessorResult,
1673        >(
1674            (),
1675            0x269e876c67302299,
1676            fidl::encoding::DynamicFlags::FLEXIBLE,
1677            _decode,
1678        )
1679    }
1680}
1681
1682pub struct MessagingClientEventStream {
1683    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1684}
1685
1686impl std::marker::Unpin for MessagingClientEventStream {}
1687
1688impl futures::stream::FusedStream for MessagingClientEventStream {
1689    fn is_terminated(&self) -> bool {
1690        self.event_receiver.is_terminated()
1691    }
1692}
1693
1694impl futures::Stream for MessagingClientEventStream {
1695    type Item = Result<MessagingClientEvent, fidl::Error>;
1696
1697    fn poll_next(
1698        mut self: std::pin::Pin<&mut Self>,
1699        cx: &mut std::task::Context<'_>,
1700    ) -> std::task::Poll<Option<Self::Item>> {
1701        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1702            &mut self.event_receiver,
1703            cx
1704        )?) {
1705            Some(buf) => std::task::Poll::Ready(Some(MessagingClientEvent::decode(buf))),
1706            None => std::task::Poll::Ready(None),
1707        }
1708    }
1709}
1710
1711#[derive(Debug)]
1712pub enum MessagingClientEvent {
1713    #[non_exhaustive]
1714    _UnknownEvent {
1715        /// Ordinal of the event that was sent.
1716        ordinal: u64,
1717    },
1718}
1719
1720impl MessagingClientEvent {
1721    /// Decodes a message buffer as a [`MessagingClientEvent`].
1722    fn decode(
1723        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1724    ) -> Result<MessagingClientEvent, fidl::Error> {
1725        let (bytes, _handles) = buf.split_mut();
1726        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1727        debug_assert_eq!(tx_header.tx_id, 0);
1728        match tx_header.ordinal {
1729            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1730                Ok(MessagingClientEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1731            }
1732            _ => Err(fidl::Error::UnknownOrdinal {
1733                ordinal: tx_header.ordinal,
1734                protocol_name:
1735                    <MessagingClientMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1736            }),
1737        }
1738    }
1739}
1740
1741/// A Stream of incoming requests for fuchsia.bluetooth.map/MessagingClient.
1742pub struct MessagingClientRequestStream {
1743    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1744    is_terminated: bool,
1745}
1746
1747impl std::marker::Unpin for MessagingClientRequestStream {}
1748
1749impl futures::stream::FusedStream for MessagingClientRequestStream {
1750    fn is_terminated(&self) -> bool {
1751        self.is_terminated
1752    }
1753}
1754
1755impl fidl::endpoints::RequestStream for MessagingClientRequestStream {
1756    type Protocol = MessagingClientMarker;
1757    type ControlHandle = MessagingClientControlHandle;
1758
1759    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1760        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1761    }
1762
1763    fn control_handle(&self) -> Self::ControlHandle {
1764        MessagingClientControlHandle { inner: self.inner.clone() }
1765    }
1766
1767    fn into_inner(
1768        self,
1769    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1770    {
1771        (self.inner, self.is_terminated)
1772    }
1773
1774    fn from_inner(
1775        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1776        is_terminated: bool,
1777    ) -> Self {
1778        Self { inner, is_terminated }
1779    }
1780}
1781
1782impl futures::Stream for MessagingClientRequestStream {
1783    type Item = Result<MessagingClientRequest, fidl::Error>;
1784
1785    fn poll_next(
1786        mut self: std::pin::Pin<&mut Self>,
1787        cx: &mut std::task::Context<'_>,
1788    ) -> std::task::Poll<Option<Self::Item>> {
1789        let this = &mut *self;
1790        if this.inner.check_shutdown(cx) {
1791            this.is_terminated = true;
1792            return std::task::Poll::Ready(None);
1793        }
1794        if this.is_terminated {
1795            panic!("polled MessagingClientRequestStream after completion");
1796        }
1797        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1798            |bytes, handles| {
1799                match this.inner.channel().read_etc(cx, bytes, handles) {
1800                    std::task::Poll::Ready(Ok(())) => {}
1801                    std::task::Poll::Pending => return std::task::Poll::Pending,
1802                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1803                        this.is_terminated = true;
1804                        return std::task::Poll::Ready(None);
1805                    }
1806                    std::task::Poll::Ready(Err(e)) => {
1807                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1808                            e.into(),
1809                        ))));
1810                    }
1811                }
1812
1813                // A message has been received from the channel
1814                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1815
1816                std::task::Poll::Ready(Some(match header.ordinal {
1817                    0x269e876c67302299 => {
1818                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1819                        let mut req = fidl::new_empty!(
1820                            fidl::encoding::EmptyPayload,
1821                            fidl::encoding::DefaultFuchsiaResourceDialect
1822                        );
1823                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1824                        let control_handle =
1825                            MessagingClientControlHandle { inner: this.inner.clone() };
1826                        Ok(MessagingClientRequest::WatchAccessor {
1827                            responder: MessagingClientWatchAccessorResponder {
1828                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1829                                tx_id: header.tx_id,
1830                            },
1831                        })
1832                    }
1833                    _ if header.tx_id == 0
1834                        && header
1835                            .dynamic_flags()
1836                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1837                    {
1838                        Ok(MessagingClientRequest::_UnknownMethod {
1839                            ordinal: header.ordinal,
1840                            control_handle: MessagingClientControlHandle {
1841                                inner: this.inner.clone(),
1842                            },
1843                            method_type: fidl::MethodType::OneWay,
1844                        })
1845                    }
1846                    _ if header
1847                        .dynamic_flags()
1848                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1849                    {
1850                        this.inner.send_framework_err(
1851                            fidl::encoding::FrameworkErr::UnknownMethod,
1852                            header.tx_id,
1853                            header.ordinal,
1854                            header.dynamic_flags(),
1855                            (bytes, handles),
1856                        )?;
1857                        Ok(MessagingClientRequest::_UnknownMethod {
1858                            ordinal: header.ordinal,
1859                            control_handle: MessagingClientControlHandle {
1860                                inner: this.inner.clone(),
1861                            },
1862                            method_type: fidl::MethodType::TwoWay,
1863                        })
1864                    }
1865                    _ => Err(fidl::Error::UnknownOrdinal {
1866                        ordinal: header.ordinal,
1867                        protocol_name:
1868                            <MessagingClientMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1869                    }),
1870                }))
1871            },
1872        )
1873    }
1874}
1875
1876/// Use a MessagingClient to access messages on one or more Instances on
1877/// Message Access Servers.
1878#[derive(Debug)]
1879pub enum MessagingClientRequest {
1880    /// An `Accessor` will be returned for each peer as they are
1881    /// connected, and only one exists at a time for each peer.
1882    /// Hangs until a new peer becomes available once all connected
1883    /// peers have been delivered through this protocol.
1884    /// Returns an error if [WatchAccessor] is called again when there
1885    /// already is a pending request.
1886    WatchAccessor { responder: MessagingClientWatchAccessorResponder },
1887    /// An interaction was received which does not match any known method.
1888    #[non_exhaustive]
1889    _UnknownMethod {
1890        /// Ordinal of the method that was called.
1891        ordinal: u64,
1892        control_handle: MessagingClientControlHandle,
1893        method_type: fidl::MethodType,
1894    },
1895}
1896
1897impl MessagingClientRequest {
1898    #[allow(irrefutable_let_patterns)]
1899    pub fn into_watch_accessor(self) -> Option<(MessagingClientWatchAccessorResponder)> {
1900        if let MessagingClientRequest::WatchAccessor { responder } = self {
1901            Some((responder))
1902        } else {
1903            None
1904        }
1905    }
1906
1907    /// Name of the method defined in FIDL
1908    pub fn method_name(&self) -> &'static str {
1909        match *self {
1910            MessagingClientRequest::WatchAccessor { .. } => "watch_accessor",
1911            MessagingClientRequest::_UnknownMethod {
1912                method_type: fidl::MethodType::OneWay,
1913                ..
1914            } => "unknown one-way method",
1915            MessagingClientRequest::_UnknownMethod {
1916                method_type: fidl::MethodType::TwoWay,
1917                ..
1918            } => "unknown two-way method",
1919        }
1920    }
1921}
1922
1923#[derive(Debug, Clone)]
1924pub struct MessagingClientControlHandle {
1925    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1926}
1927
1928impl MessagingClientControlHandle {
1929    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1930        self.inner.shutdown_with_epitaph(status.into())
1931    }
1932}
1933
1934impl fidl::endpoints::ControlHandle for MessagingClientControlHandle {
1935    fn shutdown(&self) {
1936        self.inner.shutdown()
1937    }
1938
1939    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1940        self.inner.shutdown_with_epitaph(status)
1941    }
1942
1943    fn is_closed(&self) -> bool {
1944        self.inner.channel().is_closed()
1945    }
1946    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1947        self.inner.channel().on_closed()
1948    }
1949
1950    #[cfg(target_os = "fuchsia")]
1951    fn signal_peer(
1952        &self,
1953        clear_mask: zx::Signals,
1954        set_mask: zx::Signals,
1955    ) -> Result<(), zx_status::Status> {
1956        use fidl::Peered;
1957        self.inner.channel().signal_peer(clear_mask, set_mask)
1958    }
1959}
1960
1961impl MessagingClientControlHandle {}
1962
1963#[must_use = "FIDL methods require a response to be sent"]
1964#[derive(Debug)]
1965pub struct MessagingClientWatchAccessorResponder {
1966    control_handle: std::mem::ManuallyDrop<MessagingClientControlHandle>,
1967    tx_id: u32,
1968}
1969
1970/// Set the the channel to be shutdown (see [`MessagingClientControlHandle::shutdown`])
1971/// if the responder is dropped without sending a response, so that the client
1972/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1973impl std::ops::Drop for MessagingClientWatchAccessorResponder {
1974    fn drop(&mut self) {
1975        self.control_handle.shutdown();
1976        // Safety: drops once, never accessed again
1977        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1978    }
1979}
1980
1981impl fidl::endpoints::Responder for MessagingClientWatchAccessorResponder {
1982    type ControlHandle = MessagingClientControlHandle;
1983
1984    fn control_handle(&self) -> &MessagingClientControlHandle {
1985        &self.control_handle
1986    }
1987
1988    fn drop_without_shutdown(mut self) {
1989        // Safety: drops once, never accessed again due to mem::forget
1990        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1991        // Prevent Drop from running (which would shut down the channel)
1992        std::mem::forget(self);
1993    }
1994}
1995
1996impl MessagingClientWatchAccessorResponder {
1997    /// Sends a response to the FIDL transaction.
1998    ///
1999    /// Sets the channel to shutdown if an error occurs.
2000    pub fn send(
2001        self,
2002        mut result: Result<MessagingClientWatchAccessorResponse, Error>,
2003    ) -> Result<(), fidl::Error> {
2004        let _result = self.send_raw(result);
2005        if _result.is_err() {
2006            self.control_handle.shutdown();
2007        }
2008        self.drop_without_shutdown();
2009        _result
2010    }
2011
2012    /// Similar to "send" but does not shutdown the channel if an error occurs.
2013    pub fn send_no_shutdown_on_err(
2014        self,
2015        mut result: Result<MessagingClientWatchAccessorResponse, Error>,
2016    ) -> Result<(), fidl::Error> {
2017        let _result = self.send_raw(result);
2018        self.drop_without_shutdown();
2019        _result
2020    }
2021
2022    fn send_raw(
2023        &self,
2024        mut result: Result<MessagingClientWatchAccessorResponse, Error>,
2025    ) -> Result<(), fidl::Error> {
2026        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2027            MessagingClientWatchAccessorResponse,
2028            Error,
2029        >>(
2030            fidl::encoding::FlexibleResult::new(result.as_mut().map_err(|e| *e)),
2031            self.tx_id,
2032            0x269e876c67302299,
2033            fidl::encoding::DynamicFlags::FLEXIBLE,
2034        )
2035    }
2036}
2037
2038#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2039pub struct NotificationRegistrationMarker;
2040
2041impl fidl::endpoints::ProtocolMarker for NotificationRegistrationMarker {
2042    type Proxy = NotificationRegistrationProxy;
2043    type RequestStream = NotificationRegistrationRequestStream;
2044    #[cfg(target_os = "fuchsia")]
2045    type SynchronousProxy = NotificationRegistrationSynchronousProxy;
2046
2047    const DEBUG_NAME: &'static str = "(anonymous) NotificationRegistration";
2048}
2049
2050pub trait NotificationRegistrationProxyInterface: Send + Sync {
2051    type NewEventReportResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
2052    fn r#new_event_report(
2053        &self,
2054        payload: &NotificationRegistrationNewEventReportRequest,
2055    ) -> Self::NewEventReportResponseFut;
2056}
2057#[derive(Debug)]
2058#[cfg(target_os = "fuchsia")]
2059pub struct NotificationRegistrationSynchronousProxy {
2060    client: fidl::client::sync::Client,
2061}
2062
2063#[cfg(target_os = "fuchsia")]
2064impl fidl::endpoints::SynchronousProxy for NotificationRegistrationSynchronousProxy {
2065    type Proxy = NotificationRegistrationProxy;
2066    type Protocol = NotificationRegistrationMarker;
2067
2068    fn from_channel(inner: fidl::Channel) -> Self {
2069        Self::new(inner)
2070    }
2071
2072    fn into_channel(self) -> fidl::Channel {
2073        self.client.into_channel()
2074    }
2075
2076    fn as_channel(&self) -> &fidl::Channel {
2077        self.client.as_channel()
2078    }
2079}
2080
2081#[cfg(target_os = "fuchsia")]
2082impl NotificationRegistrationSynchronousProxy {
2083    pub fn new(channel: fidl::Channel) -> Self {
2084        Self { client: fidl::client::sync::Client::new(channel) }
2085    }
2086
2087    pub fn into_channel(self) -> fidl::Channel {
2088        self.client.into_channel()
2089    }
2090
2091    /// Waits until an event arrives and returns it. It is safe for other
2092    /// threads to make concurrent requests while waiting for an event.
2093    pub fn wait_for_event(
2094        &self,
2095        deadline: zx::MonotonicInstant,
2096    ) -> Result<NotificationRegistrationEvent, fidl::Error> {
2097        NotificationRegistrationEvent::decode(
2098            self.client.wait_for_event::<NotificationRegistrationMarker>(deadline)?,
2099        )
2100    }
2101
2102    /// Relays incoming event report from the peer as a Notification.
2103    pub fn r#new_event_report(
2104        &self,
2105        mut payload: &NotificationRegistrationNewEventReportRequest,
2106        ___deadline: zx::MonotonicInstant,
2107    ) -> Result<(), fidl::Error> {
2108        let _response = self.client.send_query::<
2109            NotificationRegistrationNewEventReportRequest,
2110            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
2111            NotificationRegistrationMarker,
2112        >(
2113            payload,
2114            0x4c7d185363415f14,
2115            fidl::encoding::DynamicFlags::FLEXIBLE,
2116            ___deadline,
2117        )?
2118        .into_result::<NotificationRegistrationMarker>("new_event_report")?;
2119        Ok(_response)
2120    }
2121}
2122
2123#[cfg(target_os = "fuchsia")]
2124impl From<NotificationRegistrationSynchronousProxy> for zx::NullableHandle {
2125    fn from(value: NotificationRegistrationSynchronousProxy) -> Self {
2126        value.into_channel().into()
2127    }
2128}
2129
2130#[cfg(target_os = "fuchsia")]
2131impl From<fidl::Channel> for NotificationRegistrationSynchronousProxy {
2132    fn from(value: fidl::Channel) -> Self {
2133        Self::new(value)
2134    }
2135}
2136
2137#[cfg(target_os = "fuchsia")]
2138impl fidl::endpoints::FromClient for NotificationRegistrationSynchronousProxy {
2139    type Protocol = NotificationRegistrationMarker;
2140
2141    fn from_client(value: fidl::endpoints::ClientEnd<NotificationRegistrationMarker>) -> Self {
2142        Self::new(value.into_channel())
2143    }
2144}
2145
2146#[derive(Debug, Clone)]
2147pub struct NotificationRegistrationProxy {
2148    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2149}
2150
2151impl fidl::endpoints::Proxy for NotificationRegistrationProxy {
2152    type Protocol = NotificationRegistrationMarker;
2153
2154    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2155        Self::new(inner)
2156    }
2157
2158    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2159        self.client.into_channel().map_err(|client| Self { client })
2160    }
2161
2162    fn as_channel(&self) -> &::fidl::AsyncChannel {
2163        self.client.as_channel()
2164    }
2165}
2166
2167impl NotificationRegistrationProxy {
2168    /// Create a new Proxy for fuchsia.bluetooth.map/NotificationRegistration.
2169    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2170        let protocol_name =
2171            <NotificationRegistrationMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2172        Self { client: fidl::client::Client::new(channel, protocol_name) }
2173    }
2174
2175    /// Get a Stream of events from the remote end of the protocol.
2176    ///
2177    /// # Panics
2178    ///
2179    /// Panics if the event stream was already taken.
2180    pub fn take_event_stream(&self) -> NotificationRegistrationEventStream {
2181        NotificationRegistrationEventStream { event_receiver: self.client.take_event_receiver() }
2182    }
2183
2184    /// Relays incoming event report from the peer as a Notification.
2185    pub fn r#new_event_report(
2186        &self,
2187        mut payload: &NotificationRegistrationNewEventReportRequest,
2188    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
2189        NotificationRegistrationProxyInterface::r#new_event_report(self, payload)
2190    }
2191}
2192
2193impl NotificationRegistrationProxyInterface for NotificationRegistrationProxy {
2194    type NewEventReportResponseFut =
2195        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
2196    fn r#new_event_report(
2197        &self,
2198        mut payload: &NotificationRegistrationNewEventReportRequest,
2199    ) -> Self::NewEventReportResponseFut {
2200        fn _decode(
2201            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2202        ) -> Result<(), fidl::Error> {
2203            let _response = fidl::client::decode_transaction_body::<
2204                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
2205                fidl::encoding::DefaultFuchsiaResourceDialect,
2206                0x4c7d185363415f14,
2207            >(_buf?)?
2208            .into_result::<NotificationRegistrationMarker>("new_event_report")?;
2209            Ok(_response)
2210        }
2211        self.client.send_query_and_decode::<NotificationRegistrationNewEventReportRequest, ()>(
2212            payload,
2213            0x4c7d185363415f14,
2214            fidl::encoding::DynamicFlags::FLEXIBLE,
2215            _decode,
2216        )
2217    }
2218}
2219
2220pub struct NotificationRegistrationEventStream {
2221    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2222}
2223
2224impl std::marker::Unpin for NotificationRegistrationEventStream {}
2225
2226impl futures::stream::FusedStream for NotificationRegistrationEventStream {
2227    fn is_terminated(&self) -> bool {
2228        self.event_receiver.is_terminated()
2229    }
2230}
2231
2232impl futures::Stream for NotificationRegistrationEventStream {
2233    type Item = Result<NotificationRegistrationEvent, fidl::Error>;
2234
2235    fn poll_next(
2236        mut self: std::pin::Pin<&mut Self>,
2237        cx: &mut std::task::Context<'_>,
2238    ) -> std::task::Poll<Option<Self::Item>> {
2239        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2240            &mut self.event_receiver,
2241            cx
2242        )?) {
2243            Some(buf) => std::task::Poll::Ready(Some(NotificationRegistrationEvent::decode(buf))),
2244            None => std::task::Poll::Ready(None),
2245        }
2246    }
2247}
2248
2249#[derive(Debug)]
2250pub enum NotificationRegistrationEvent {
2251    #[non_exhaustive]
2252    _UnknownEvent {
2253        /// Ordinal of the event that was sent.
2254        ordinal: u64,
2255    },
2256}
2257
2258impl NotificationRegistrationEvent {
2259    /// Decodes a message buffer as a [`NotificationRegistrationEvent`].
2260    fn decode(
2261        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2262    ) -> Result<NotificationRegistrationEvent, fidl::Error> {
2263        let (bytes, _handles) = buf.split_mut();
2264        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2265        debug_assert_eq!(tx_header.tx_id, 0);
2266        match tx_header.ordinal {
2267            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2268                Ok(NotificationRegistrationEvent::_UnknownEvent { ordinal: tx_header.ordinal })
2269            }
2270            _ => Err(fidl::Error::UnknownOrdinal {
2271                ordinal: tx_header.ordinal,
2272                protocol_name:
2273                    <NotificationRegistrationMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2274            }),
2275        }
2276    }
2277}
2278
2279/// A Stream of incoming requests for fuchsia.bluetooth.map/NotificationRegistration.
2280pub struct NotificationRegistrationRequestStream {
2281    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2282    is_terminated: bool,
2283}
2284
2285impl std::marker::Unpin for NotificationRegistrationRequestStream {}
2286
2287impl futures::stream::FusedStream for NotificationRegistrationRequestStream {
2288    fn is_terminated(&self) -> bool {
2289        self.is_terminated
2290    }
2291}
2292
2293impl fidl::endpoints::RequestStream for NotificationRegistrationRequestStream {
2294    type Protocol = NotificationRegistrationMarker;
2295    type ControlHandle = NotificationRegistrationControlHandle;
2296
2297    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2298        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2299    }
2300
2301    fn control_handle(&self) -> Self::ControlHandle {
2302        NotificationRegistrationControlHandle { inner: self.inner.clone() }
2303    }
2304
2305    fn into_inner(
2306        self,
2307    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2308    {
2309        (self.inner, self.is_terminated)
2310    }
2311
2312    fn from_inner(
2313        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2314        is_terminated: bool,
2315    ) -> Self {
2316        Self { inner, is_terminated }
2317    }
2318}
2319
2320impl futures::Stream for NotificationRegistrationRequestStream {
2321    type Item = Result<NotificationRegistrationRequest, fidl::Error>;
2322
2323    fn poll_next(
2324        mut self: std::pin::Pin<&mut Self>,
2325        cx: &mut std::task::Context<'_>,
2326    ) -> std::task::Poll<Option<Self::Item>> {
2327        let this = &mut *self;
2328        if this.inner.check_shutdown(cx) {
2329            this.is_terminated = true;
2330            return std::task::Poll::Ready(None);
2331        }
2332        if this.is_terminated {
2333            panic!("polled NotificationRegistrationRequestStream after completion");
2334        }
2335        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2336            |bytes, handles| {
2337                match this.inner.channel().read_etc(cx, bytes, handles) {
2338                    std::task::Poll::Ready(Ok(())) => {}
2339                    std::task::Poll::Pending => return std::task::Poll::Pending,
2340                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2341                        this.is_terminated = true;
2342                        return std::task::Poll::Ready(None);
2343                    }
2344                    std::task::Poll::Ready(Err(e)) => {
2345                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2346                            e.into(),
2347                        ))));
2348                    }
2349                }
2350
2351                // A message has been received from the channel
2352                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2353
2354                std::task::Poll::Ready(Some(match header.ordinal {
2355                0x4c7d185363415f14 => {
2356                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2357                    let mut req = fidl::new_empty!(NotificationRegistrationNewEventReportRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
2358                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NotificationRegistrationNewEventReportRequest>(&header, _body_bytes, handles, &mut req)?;
2359                    let control_handle = NotificationRegistrationControlHandle {
2360                        inner: this.inner.clone(),
2361                    };
2362                    Ok(NotificationRegistrationRequest::NewEventReport {payload: req,
2363                        responder: NotificationRegistrationNewEventReportResponder {
2364                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2365                            tx_id: header.tx_id,
2366                        },
2367                    })
2368                }
2369                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2370                    Ok(NotificationRegistrationRequest::_UnknownMethod {
2371                        ordinal: header.ordinal,
2372                        control_handle: NotificationRegistrationControlHandle { inner: this.inner.clone() },
2373                        method_type: fidl::MethodType::OneWay,
2374                    })
2375                }
2376                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2377                    this.inner.send_framework_err(
2378                        fidl::encoding::FrameworkErr::UnknownMethod,
2379                        header.tx_id,
2380                        header.ordinal,
2381                        header.dynamic_flags(),
2382                        (bytes, handles),
2383                    )?;
2384                    Ok(NotificationRegistrationRequest::_UnknownMethod {
2385                        ordinal: header.ordinal,
2386                        control_handle: NotificationRegistrationControlHandle { inner: this.inner.clone() },
2387                        method_type: fidl::MethodType::TwoWay,
2388                    })
2389                }
2390                _ => Err(fidl::Error::UnknownOrdinal {
2391                    ordinal: header.ordinal,
2392                    protocol_name: <NotificationRegistrationMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2393                }),
2394            }))
2395            },
2396        )
2397    }
2398}
2399
2400/// Protocol for relaying event reports from the peer's message
2401/// repositories to the client.
2402/// This protocol exists to support the Notification Feature of MAP.
2403/// + request `notification` Notification received from the peer.
2404/// + request `received` The monotonic time when the notification was
2405///                      received from the peer.
2406#[derive(Debug)]
2407pub enum NotificationRegistrationRequest {
2408    /// Relays incoming event report from the peer as a Notification.
2409    NewEventReport {
2410        payload: NotificationRegistrationNewEventReportRequest,
2411        responder: NotificationRegistrationNewEventReportResponder,
2412    },
2413    /// An interaction was received which does not match any known method.
2414    #[non_exhaustive]
2415    _UnknownMethod {
2416        /// Ordinal of the method that was called.
2417        ordinal: u64,
2418        control_handle: NotificationRegistrationControlHandle,
2419        method_type: fidl::MethodType,
2420    },
2421}
2422
2423impl NotificationRegistrationRequest {
2424    #[allow(irrefutable_let_patterns)]
2425    pub fn into_new_event_report(
2426        self,
2427    ) -> Option<(
2428        NotificationRegistrationNewEventReportRequest,
2429        NotificationRegistrationNewEventReportResponder,
2430    )> {
2431        if let NotificationRegistrationRequest::NewEventReport { payload, responder } = self {
2432            Some((payload, responder))
2433        } else {
2434            None
2435        }
2436    }
2437
2438    /// Name of the method defined in FIDL
2439    pub fn method_name(&self) -> &'static str {
2440        match *self {
2441            NotificationRegistrationRequest::NewEventReport { .. } => "new_event_report",
2442            NotificationRegistrationRequest::_UnknownMethod {
2443                method_type: fidl::MethodType::OneWay,
2444                ..
2445            } => "unknown one-way method",
2446            NotificationRegistrationRequest::_UnknownMethod {
2447                method_type: fidl::MethodType::TwoWay,
2448                ..
2449            } => "unknown two-way method",
2450        }
2451    }
2452}
2453
2454#[derive(Debug, Clone)]
2455pub struct NotificationRegistrationControlHandle {
2456    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2457}
2458
2459impl NotificationRegistrationControlHandle {
2460    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
2461        self.inner.shutdown_with_epitaph(status.into())
2462    }
2463}
2464
2465impl fidl::endpoints::ControlHandle for NotificationRegistrationControlHandle {
2466    fn shutdown(&self) {
2467        self.inner.shutdown()
2468    }
2469
2470    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
2471        self.inner.shutdown_with_epitaph(status)
2472    }
2473
2474    fn is_closed(&self) -> bool {
2475        self.inner.channel().is_closed()
2476    }
2477    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2478        self.inner.channel().on_closed()
2479    }
2480
2481    #[cfg(target_os = "fuchsia")]
2482    fn signal_peer(
2483        &self,
2484        clear_mask: zx::Signals,
2485        set_mask: zx::Signals,
2486    ) -> Result<(), zx_status::Status> {
2487        use fidl::Peered;
2488        self.inner.channel().signal_peer(clear_mask, set_mask)
2489    }
2490}
2491
2492impl NotificationRegistrationControlHandle {}
2493
2494#[must_use = "FIDL methods require a response to be sent"]
2495#[derive(Debug)]
2496pub struct NotificationRegistrationNewEventReportResponder {
2497    control_handle: std::mem::ManuallyDrop<NotificationRegistrationControlHandle>,
2498    tx_id: u32,
2499}
2500
2501/// Set the the channel to be shutdown (see [`NotificationRegistrationControlHandle::shutdown`])
2502/// if the responder is dropped without sending a response, so that the client
2503/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2504impl std::ops::Drop for NotificationRegistrationNewEventReportResponder {
2505    fn drop(&mut self) {
2506        self.control_handle.shutdown();
2507        // Safety: drops once, never accessed again
2508        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2509    }
2510}
2511
2512impl fidl::endpoints::Responder for NotificationRegistrationNewEventReportResponder {
2513    type ControlHandle = NotificationRegistrationControlHandle;
2514
2515    fn control_handle(&self) -> &NotificationRegistrationControlHandle {
2516        &self.control_handle
2517    }
2518
2519    fn drop_without_shutdown(mut self) {
2520        // Safety: drops once, never accessed again due to mem::forget
2521        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2522        // Prevent Drop from running (which would shut down the channel)
2523        std::mem::forget(self);
2524    }
2525}
2526
2527impl NotificationRegistrationNewEventReportResponder {
2528    /// Sends a response to the FIDL transaction.
2529    ///
2530    /// Sets the channel to shutdown if an error occurs.
2531    pub fn send(self) -> Result<(), fidl::Error> {
2532        let _result = self.send_raw();
2533        if _result.is_err() {
2534            self.control_handle.shutdown();
2535        }
2536        self.drop_without_shutdown();
2537        _result
2538    }
2539
2540    /// Similar to "send" but does not shutdown the channel if an error occurs.
2541    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
2542        let _result = self.send_raw();
2543        self.drop_without_shutdown();
2544        _result
2545    }
2546
2547    fn send_raw(&self) -> Result<(), fidl::Error> {
2548        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
2549            fidl::encoding::Flexible::new(()),
2550            self.tx_id,
2551            0x4c7d185363415f14,
2552            fidl::encoding::DynamicFlags::FLEXIBLE,
2553        )
2554    }
2555}
2556
2557mod internal {
2558    use super::*;
2559
2560    impl AccessorSetNotificationRegistrationRequest {
2561        #[inline(always)]
2562        fn max_ordinal_present(&self) -> u64 {
2563            if let Some(_) = self.server {
2564                return 2;
2565            }
2566            if let Some(_) = self.mas_instance_ids {
2567                return 1;
2568            }
2569            0
2570        }
2571    }
2572
2573    impl fidl::encoding::ResourceTypeMarker for AccessorSetNotificationRegistrationRequest {
2574        type Borrowed<'a> = &'a mut Self;
2575        fn take_or_borrow<'a>(
2576            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2577        ) -> Self::Borrowed<'a> {
2578            value
2579        }
2580    }
2581
2582    unsafe impl fidl::encoding::TypeMarker for AccessorSetNotificationRegistrationRequest {
2583        type Owned = Self;
2584
2585        #[inline(always)]
2586        fn inline_align(_context: fidl::encoding::Context) -> usize {
2587            8
2588        }
2589
2590        #[inline(always)]
2591        fn inline_size(_context: fidl::encoding::Context) -> usize {
2592            16
2593        }
2594    }
2595
2596    unsafe impl
2597        fidl::encoding::Encode<
2598            AccessorSetNotificationRegistrationRequest,
2599            fidl::encoding::DefaultFuchsiaResourceDialect,
2600        > for &mut AccessorSetNotificationRegistrationRequest
2601    {
2602        unsafe fn encode(
2603            self,
2604            encoder: &mut fidl::encoding::Encoder<
2605                '_,
2606                fidl::encoding::DefaultFuchsiaResourceDialect,
2607            >,
2608            offset: usize,
2609            mut depth: fidl::encoding::Depth,
2610        ) -> fidl::Result<()> {
2611            encoder.debug_check_bounds::<AccessorSetNotificationRegistrationRequest>(offset);
2612            // Vector header
2613            let max_ordinal: u64 = self.max_ordinal_present();
2614            encoder.write_num(max_ordinal, offset);
2615            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2616            // Calling encoder.out_of_line_offset(0) is not allowed.
2617            if max_ordinal == 0 {
2618                return Ok(());
2619            }
2620            depth.increment()?;
2621            let envelope_size = 8;
2622            let bytes_len = max_ordinal as usize * envelope_size;
2623            #[allow(unused_variables)]
2624            let offset = encoder.out_of_line_offset(bytes_len);
2625            let mut _prev_end_offset: usize = 0;
2626            if 1 > max_ordinal {
2627                return Ok(());
2628            }
2629
2630            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2631            // are envelope_size bytes.
2632            let cur_offset: usize = (1 - 1) * envelope_size;
2633
2634            // Zero reserved fields.
2635            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2636
2637            // Safety:
2638            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2639            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2640            //   envelope_size bytes, there is always sufficient room.
2641            fidl::encoding::encode_in_envelope_optional::<
2642                fidl::encoding::Vector<u8, 256>,
2643                fidl::encoding::DefaultFuchsiaResourceDialect,
2644            >(
2645                self.mas_instance_ids.as_ref().map(
2646                    <fidl::encoding::Vector<u8, 256> as fidl::encoding::ValueTypeMarker>::borrow,
2647                ),
2648                encoder,
2649                offset + cur_offset,
2650                depth,
2651            )?;
2652
2653            _prev_end_offset = cur_offset + envelope_size;
2654            if 2 > max_ordinal {
2655                return Ok(());
2656            }
2657
2658            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2659            // are envelope_size bytes.
2660            let cur_offset: usize = (2 - 1) * envelope_size;
2661
2662            // Zero reserved fields.
2663            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2664
2665            // Safety:
2666            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2667            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2668            //   envelope_size bytes, there is always sufficient room.
2669            fidl::encoding::encode_in_envelope_optional::<
2670                fidl::encoding::Endpoint<
2671                    fidl::endpoints::ClientEnd<NotificationRegistrationMarker>,
2672                >,
2673                fidl::encoding::DefaultFuchsiaResourceDialect,
2674            >(
2675                self.server.as_mut().map(
2676                    <fidl::encoding::Endpoint<
2677                        fidl::endpoints::ClientEnd<NotificationRegistrationMarker>,
2678                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
2679                ),
2680                encoder,
2681                offset + cur_offset,
2682                depth,
2683            )?;
2684
2685            _prev_end_offset = cur_offset + envelope_size;
2686
2687            Ok(())
2688        }
2689    }
2690
2691    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2692        for AccessorSetNotificationRegistrationRequest
2693    {
2694        #[inline(always)]
2695        fn new_empty() -> Self {
2696            Self::default()
2697        }
2698
2699        unsafe fn decode(
2700            &mut self,
2701            decoder: &mut fidl::encoding::Decoder<
2702                '_,
2703                fidl::encoding::DefaultFuchsiaResourceDialect,
2704            >,
2705            offset: usize,
2706            mut depth: fidl::encoding::Depth,
2707        ) -> fidl::Result<()> {
2708            decoder.debug_check_bounds::<Self>(offset);
2709            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2710                None => return Err(fidl::Error::NotNullable),
2711                Some(len) => len,
2712            };
2713            // Calling decoder.out_of_line_offset(0) is not allowed.
2714            if len == 0 {
2715                return Ok(());
2716            };
2717            depth.increment()?;
2718            let envelope_size = 8;
2719            let bytes_len = len * envelope_size;
2720            let offset = decoder.out_of_line_offset(bytes_len)?;
2721            // Decode the envelope for each type.
2722            let mut _next_ordinal_to_read = 0;
2723            let mut next_offset = offset;
2724            let end_offset = offset + bytes_len;
2725            _next_ordinal_to_read += 1;
2726            if next_offset >= end_offset {
2727                return Ok(());
2728            }
2729
2730            // Decode unknown envelopes for gaps in ordinals.
2731            while _next_ordinal_to_read < 1 {
2732                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2733                _next_ordinal_to_read += 1;
2734                next_offset += envelope_size;
2735            }
2736
2737            let next_out_of_line = decoder.next_out_of_line();
2738            let handles_before = decoder.remaining_handles();
2739            if let Some((inlined, num_bytes, num_handles)) =
2740                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2741            {
2742                let member_inline_size =
2743                    <fidl::encoding::Vector<u8, 256> as fidl::encoding::TypeMarker>::inline_size(
2744                        decoder.context,
2745                    );
2746                if inlined != (member_inline_size <= 4) {
2747                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2748                }
2749                let inner_offset;
2750                let mut inner_depth = depth.clone();
2751                if inlined {
2752                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2753                    inner_offset = next_offset;
2754                } else {
2755                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2756                    inner_depth.increment()?;
2757                }
2758                let val_ref =
2759                self.mas_instance_ids.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<u8, 256>, fidl::encoding::DefaultFuchsiaResourceDialect));
2760                fidl::decode!(fidl::encoding::Vector<u8, 256>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
2761                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2762                {
2763                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2764                }
2765                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2766                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2767                }
2768            }
2769
2770            next_offset += envelope_size;
2771            _next_ordinal_to_read += 1;
2772            if next_offset >= end_offset {
2773                return Ok(());
2774            }
2775
2776            // Decode unknown envelopes for gaps in ordinals.
2777            while _next_ordinal_to_read < 2 {
2778                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2779                _next_ordinal_to_read += 1;
2780                next_offset += envelope_size;
2781            }
2782
2783            let next_out_of_line = decoder.next_out_of_line();
2784            let handles_before = decoder.remaining_handles();
2785            if let Some((inlined, num_bytes, num_handles)) =
2786                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2787            {
2788                let member_inline_size = <fidl::encoding::Endpoint<
2789                    fidl::endpoints::ClientEnd<NotificationRegistrationMarker>,
2790                > as fidl::encoding::TypeMarker>::inline_size(
2791                    decoder.context
2792                );
2793                if inlined != (member_inline_size <= 4) {
2794                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2795                }
2796                let inner_offset;
2797                let mut inner_depth = depth.clone();
2798                if inlined {
2799                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2800                    inner_offset = next_offset;
2801                } else {
2802                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2803                    inner_depth.increment()?;
2804                }
2805                let val_ref = self.server.get_or_insert_with(|| {
2806                    fidl::new_empty!(
2807                        fidl::encoding::Endpoint<
2808                            fidl::endpoints::ClientEnd<NotificationRegistrationMarker>,
2809                        >,
2810                        fidl::encoding::DefaultFuchsiaResourceDialect
2811                    )
2812                });
2813                fidl::decode!(
2814                    fidl::encoding::Endpoint<
2815                        fidl::endpoints::ClientEnd<NotificationRegistrationMarker>,
2816                    >,
2817                    fidl::encoding::DefaultFuchsiaResourceDialect,
2818                    val_ref,
2819                    decoder,
2820                    inner_offset,
2821                    inner_depth
2822                )?;
2823                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2824                {
2825                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2826                }
2827                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2828                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2829                }
2830            }
2831
2832            next_offset += envelope_size;
2833
2834            // Decode the remaining unknown envelopes.
2835            while next_offset < end_offset {
2836                _next_ordinal_to_read += 1;
2837                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2838                next_offset += envelope_size;
2839            }
2840
2841            Ok(())
2842        }
2843    }
2844
2845    impl MessagingClientWatchAccessorResponse {
2846        #[inline(always)]
2847        fn max_ordinal_present(&self) -> u64 {
2848            if let Some(_) = self.accessor {
2849                return 2;
2850            }
2851            if let Some(_) = self.peer_id {
2852                return 1;
2853            }
2854            0
2855        }
2856    }
2857
2858    impl fidl::encoding::ResourceTypeMarker for MessagingClientWatchAccessorResponse {
2859        type Borrowed<'a> = &'a mut Self;
2860        fn take_or_borrow<'a>(
2861            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2862        ) -> Self::Borrowed<'a> {
2863            value
2864        }
2865    }
2866
2867    unsafe impl fidl::encoding::TypeMarker for MessagingClientWatchAccessorResponse {
2868        type Owned = Self;
2869
2870        #[inline(always)]
2871        fn inline_align(_context: fidl::encoding::Context) -> usize {
2872            8
2873        }
2874
2875        #[inline(always)]
2876        fn inline_size(_context: fidl::encoding::Context) -> usize {
2877            16
2878        }
2879    }
2880
2881    unsafe impl
2882        fidl::encoding::Encode<
2883            MessagingClientWatchAccessorResponse,
2884            fidl::encoding::DefaultFuchsiaResourceDialect,
2885        > for &mut MessagingClientWatchAccessorResponse
2886    {
2887        unsafe fn encode(
2888            self,
2889            encoder: &mut fidl::encoding::Encoder<
2890                '_,
2891                fidl::encoding::DefaultFuchsiaResourceDialect,
2892            >,
2893            offset: usize,
2894            mut depth: fidl::encoding::Depth,
2895        ) -> fidl::Result<()> {
2896            encoder.debug_check_bounds::<MessagingClientWatchAccessorResponse>(offset);
2897            // Vector header
2898            let max_ordinal: u64 = self.max_ordinal_present();
2899            encoder.write_num(max_ordinal, offset);
2900            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2901            // Calling encoder.out_of_line_offset(0) is not allowed.
2902            if max_ordinal == 0 {
2903                return Ok(());
2904            }
2905            depth.increment()?;
2906            let envelope_size = 8;
2907            let bytes_len = max_ordinal as usize * envelope_size;
2908            #[allow(unused_variables)]
2909            let offset = encoder.out_of_line_offset(bytes_len);
2910            let mut _prev_end_offset: usize = 0;
2911            if 1 > max_ordinal {
2912                return Ok(());
2913            }
2914
2915            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2916            // are envelope_size bytes.
2917            let cur_offset: usize = (1 - 1) * envelope_size;
2918
2919            // Zero reserved fields.
2920            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2921
2922            // Safety:
2923            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2924            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2925            //   envelope_size bytes, there is always sufficient room.
2926            fidl::encoding::encode_in_envelope_optional::<
2927                fidl_fuchsia_bluetooth::PeerId,
2928                fidl::encoding::DefaultFuchsiaResourceDialect,
2929            >(
2930                self.peer_id.as_ref().map(
2931                    <fidl_fuchsia_bluetooth::PeerId as fidl::encoding::ValueTypeMarker>::borrow,
2932                ),
2933                encoder,
2934                offset + cur_offset,
2935                depth,
2936            )?;
2937
2938            _prev_end_offset = cur_offset + envelope_size;
2939            if 2 > max_ordinal {
2940                return Ok(());
2941            }
2942
2943            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2944            // are envelope_size bytes.
2945            let cur_offset: usize = (2 - 1) * envelope_size;
2946
2947            // Zero reserved fields.
2948            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2949
2950            // Safety:
2951            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2952            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2953            //   envelope_size bytes, there is always sufficient room.
2954            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<AccessorMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
2955            self.accessor.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<AccessorMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
2956            encoder, offset + cur_offset, depth
2957        )?;
2958
2959            _prev_end_offset = cur_offset + envelope_size;
2960
2961            Ok(())
2962        }
2963    }
2964
2965    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2966        for MessagingClientWatchAccessorResponse
2967    {
2968        #[inline(always)]
2969        fn new_empty() -> Self {
2970            Self::default()
2971        }
2972
2973        unsafe fn decode(
2974            &mut self,
2975            decoder: &mut fidl::encoding::Decoder<
2976                '_,
2977                fidl::encoding::DefaultFuchsiaResourceDialect,
2978            >,
2979            offset: usize,
2980            mut depth: fidl::encoding::Depth,
2981        ) -> fidl::Result<()> {
2982            decoder.debug_check_bounds::<Self>(offset);
2983            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2984                None => return Err(fidl::Error::NotNullable),
2985                Some(len) => len,
2986            };
2987            // Calling decoder.out_of_line_offset(0) is not allowed.
2988            if len == 0 {
2989                return Ok(());
2990            };
2991            depth.increment()?;
2992            let envelope_size = 8;
2993            let bytes_len = len * envelope_size;
2994            let offset = decoder.out_of_line_offset(bytes_len)?;
2995            // Decode the envelope for each type.
2996            let mut _next_ordinal_to_read = 0;
2997            let mut next_offset = offset;
2998            let end_offset = offset + bytes_len;
2999            _next_ordinal_to_read += 1;
3000            if next_offset >= end_offset {
3001                return Ok(());
3002            }
3003
3004            // Decode unknown envelopes for gaps in ordinals.
3005            while _next_ordinal_to_read < 1 {
3006                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3007                _next_ordinal_to_read += 1;
3008                next_offset += envelope_size;
3009            }
3010
3011            let next_out_of_line = decoder.next_out_of_line();
3012            let handles_before = decoder.remaining_handles();
3013            if let Some((inlined, num_bytes, num_handles)) =
3014                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3015            {
3016                let member_inline_size =
3017                    <fidl_fuchsia_bluetooth::PeerId as fidl::encoding::TypeMarker>::inline_size(
3018                        decoder.context,
3019                    );
3020                if inlined != (member_inline_size <= 4) {
3021                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3022                }
3023                let inner_offset;
3024                let mut inner_depth = depth.clone();
3025                if inlined {
3026                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3027                    inner_offset = next_offset;
3028                } else {
3029                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3030                    inner_depth.increment()?;
3031                }
3032                let val_ref = self.peer_id.get_or_insert_with(|| {
3033                    fidl::new_empty!(
3034                        fidl_fuchsia_bluetooth::PeerId,
3035                        fidl::encoding::DefaultFuchsiaResourceDialect
3036                    )
3037                });
3038                fidl::decode!(
3039                    fidl_fuchsia_bluetooth::PeerId,
3040                    fidl::encoding::DefaultFuchsiaResourceDialect,
3041                    val_ref,
3042                    decoder,
3043                    inner_offset,
3044                    inner_depth
3045                )?;
3046                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3047                {
3048                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3049                }
3050                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3051                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3052                }
3053            }
3054
3055            next_offset += envelope_size;
3056            _next_ordinal_to_read += 1;
3057            if next_offset >= end_offset {
3058                return Ok(());
3059            }
3060
3061            // Decode unknown envelopes for gaps in ordinals.
3062            while _next_ordinal_to_read < 2 {
3063                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3064                _next_ordinal_to_read += 1;
3065                next_offset += envelope_size;
3066            }
3067
3068            let next_out_of_line = decoder.next_out_of_line();
3069            let handles_before = decoder.remaining_handles();
3070            if let Some((inlined, num_bytes, num_handles)) =
3071                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3072            {
3073                let member_inline_size = <fidl::encoding::Endpoint<
3074                    fidl::endpoints::ClientEnd<AccessorMarker>,
3075                > as fidl::encoding::TypeMarker>::inline_size(
3076                    decoder.context
3077                );
3078                if inlined != (member_inline_size <= 4) {
3079                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3080                }
3081                let inner_offset;
3082                let mut inner_depth = depth.clone();
3083                if inlined {
3084                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3085                    inner_offset = next_offset;
3086                } else {
3087                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3088                    inner_depth.increment()?;
3089                }
3090                let val_ref = self.accessor.get_or_insert_with(|| {
3091                    fidl::new_empty!(
3092                        fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<AccessorMarker>>,
3093                        fidl::encoding::DefaultFuchsiaResourceDialect
3094                    )
3095                });
3096                fidl::decode!(
3097                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<AccessorMarker>>,
3098                    fidl::encoding::DefaultFuchsiaResourceDialect,
3099                    val_ref,
3100                    decoder,
3101                    inner_offset,
3102                    inner_depth
3103                )?;
3104                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3105                {
3106                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3107                }
3108                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3109                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3110                }
3111            }
3112
3113            next_offset += envelope_size;
3114
3115            // Decode the remaining unknown envelopes.
3116            while next_offset < end_offset {
3117                _next_ordinal_to_read += 1;
3118                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3119                next_offset += envelope_size;
3120            }
3121
3122            Ok(())
3123        }
3124    }
3125}