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 fidl::endpoints::ControlHandle for AccessorControlHandle {
703    fn shutdown(&self) {
704        self.inner.shutdown()
705    }
706
707    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
708        self.inner.shutdown_with_epitaph(status)
709    }
710
711    fn is_closed(&self) -> bool {
712        self.inner.channel().is_closed()
713    }
714    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
715        self.inner.channel().on_closed()
716    }
717
718    #[cfg(target_os = "fuchsia")]
719    fn signal_peer(
720        &self,
721        clear_mask: zx::Signals,
722        set_mask: zx::Signals,
723    ) -> Result<(), zx_status::Status> {
724        use fidl::Peered;
725        self.inner.channel().signal_peer(clear_mask, set_mask)
726    }
727}
728
729impl AccessorControlHandle {}
730
731#[must_use = "FIDL methods require a response to be sent"]
732#[derive(Debug)]
733pub struct AccessorGetDetailsResponder {
734    control_handle: std::mem::ManuallyDrop<AccessorControlHandle>,
735    tx_id: u32,
736}
737
738/// Set the the channel to be shutdown (see [`AccessorControlHandle::shutdown`])
739/// if the responder is dropped without sending a response, so that the client
740/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
741impl std::ops::Drop for AccessorGetDetailsResponder {
742    fn drop(&mut self) {
743        self.control_handle.shutdown();
744        // Safety: drops once, never accessed again
745        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
746    }
747}
748
749impl fidl::endpoints::Responder for AccessorGetDetailsResponder {
750    type ControlHandle = AccessorControlHandle;
751
752    fn control_handle(&self) -> &AccessorControlHandle {
753        &self.control_handle
754    }
755
756    fn drop_without_shutdown(mut self) {
757        // Safety: drops once, never accessed again due to mem::forget
758        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
759        // Prevent Drop from running (which would shut down the channel)
760        std::mem::forget(self);
761    }
762}
763
764impl AccessorGetDetailsResponder {
765    /// Sends a response to the FIDL transaction.
766    ///
767    /// Sets the channel to shutdown if an error occurs.
768    pub fn send(self, mut result: Result<&Message, Error>) -> Result<(), fidl::Error> {
769        let _result = self.send_raw(result);
770        if _result.is_err() {
771            self.control_handle.shutdown();
772        }
773        self.drop_without_shutdown();
774        _result
775    }
776
777    /// Similar to "send" but does not shutdown the channel if an error occurs.
778    pub fn send_no_shutdown_on_err(
779        self,
780        mut result: Result<&Message, Error>,
781    ) -> Result<(), fidl::Error> {
782        let _result = self.send_raw(result);
783        self.drop_without_shutdown();
784        _result
785    }
786
787    fn send_raw(&self, mut result: Result<&Message, Error>) -> Result<(), fidl::Error> {
788        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<Message, Error>>(
789            fidl::encoding::FlexibleResult::new(result),
790            self.tx_id,
791            0x7c3667b69d66691e,
792            fidl::encoding::DynamicFlags::FLEXIBLE,
793        )
794    }
795}
796
797#[must_use = "FIDL methods require a response to be sent"]
798#[derive(Debug)]
799pub struct AccessorListAllMasInstancesResponder {
800    control_handle: std::mem::ManuallyDrop<AccessorControlHandle>,
801    tx_id: u32,
802}
803
804/// Set the the channel to be shutdown (see [`AccessorControlHandle::shutdown`])
805/// if the responder is dropped without sending a response, so that the client
806/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
807impl std::ops::Drop for AccessorListAllMasInstancesResponder {
808    fn drop(&mut self) {
809        self.control_handle.shutdown();
810        // Safety: drops once, never accessed again
811        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
812    }
813}
814
815impl fidl::endpoints::Responder for AccessorListAllMasInstancesResponder {
816    type ControlHandle = AccessorControlHandle;
817
818    fn control_handle(&self) -> &AccessorControlHandle {
819        &self.control_handle
820    }
821
822    fn drop_without_shutdown(mut self) {
823        // Safety: drops once, never accessed again due to mem::forget
824        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
825        // Prevent Drop from running (which would shut down the channel)
826        std::mem::forget(self);
827    }
828}
829
830impl AccessorListAllMasInstancesResponder {
831    /// Sends a response to the FIDL transaction.
832    ///
833    /// Sets the channel to shutdown if an error occurs.
834    pub fn send(self, mut result: Result<&[MasInstance], Error>) -> Result<(), fidl::Error> {
835        let _result = self.send_raw(result);
836        if _result.is_err() {
837            self.control_handle.shutdown();
838        }
839        self.drop_without_shutdown();
840        _result
841    }
842
843    /// Similar to "send" but does not shutdown the channel if an error occurs.
844    pub fn send_no_shutdown_on_err(
845        self,
846        mut result: Result<&[MasInstance], Error>,
847    ) -> Result<(), fidl::Error> {
848        let _result = self.send_raw(result);
849        self.drop_without_shutdown();
850        _result
851    }
852
853    fn send_raw(&self, mut result: Result<&[MasInstance], Error>) -> Result<(), fidl::Error> {
854        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
855            AccessorListAllMasInstancesResponse,
856            Error,
857        >>(
858            fidl::encoding::FlexibleResult::new(result.map(|instances| (instances,))),
859            self.tx_id,
860            0x6c78ebf9ba9780bd,
861            fidl::encoding::DynamicFlags::FLEXIBLE,
862        )
863    }
864}
865
866#[must_use = "FIDL methods require a response to be sent"]
867#[derive(Debug)]
868pub struct AccessorSetNotificationRegistrationResponder {
869    control_handle: std::mem::ManuallyDrop<AccessorControlHandle>,
870    tx_id: u32,
871}
872
873/// Set the the channel to be shutdown (see [`AccessorControlHandle::shutdown`])
874/// if the responder is dropped without sending a response, so that the client
875/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
876impl std::ops::Drop for AccessorSetNotificationRegistrationResponder {
877    fn drop(&mut self) {
878        self.control_handle.shutdown();
879        // Safety: drops once, never accessed again
880        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
881    }
882}
883
884impl fidl::endpoints::Responder for AccessorSetNotificationRegistrationResponder {
885    type ControlHandle = AccessorControlHandle;
886
887    fn control_handle(&self) -> &AccessorControlHandle {
888        &self.control_handle
889    }
890
891    fn drop_without_shutdown(mut self) {
892        // Safety: drops once, never accessed again due to mem::forget
893        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
894        // Prevent Drop from running (which would shut down the channel)
895        std::mem::forget(self);
896    }
897}
898
899impl AccessorSetNotificationRegistrationResponder {
900    /// Sends a response to the FIDL transaction.
901    ///
902    /// Sets the channel to shutdown if an error occurs.
903    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
904        let _result = self.send_raw(result);
905        if _result.is_err() {
906            self.control_handle.shutdown();
907        }
908        self.drop_without_shutdown();
909        _result
910    }
911
912    /// Similar to "send" but does not shutdown the channel if an error occurs.
913    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
914        let _result = self.send_raw(result);
915        self.drop_without_shutdown();
916        _result
917    }
918
919    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
920        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
921            fidl::encoding::EmptyStruct,
922            Error,
923        >>(
924            fidl::encoding::FlexibleResult::new(result),
925            self.tx_id,
926            0x3d764e196f83bd7c,
927            fidl::encoding::DynamicFlags::FLEXIBLE,
928        )
929    }
930}
931
932#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
933pub struct MessageControllerMarker;
934
935impl fidl::endpoints::ProtocolMarker for MessageControllerMarker {
936    type Proxy = MessageControllerProxy;
937    type RequestStream = MessageControllerRequestStream;
938    #[cfg(target_os = "fuchsia")]
939    type SynchronousProxy = MessageControllerSynchronousProxy;
940
941    const DEBUG_NAME: &'static str = "(anonymous) MessageController";
942}
943pub type MessageControllerGetDetailsResult = Result<Message, Error>;
944
945pub trait MessageControllerProxyInterface: Send + Sync {
946    type GetDetailsResponseFut: std::future::Future<Output = Result<MessageControllerGetDetailsResult, fidl::Error>>
947        + Send;
948    fn r#get_details(&self, handle: u64, include_attachment: bool) -> Self::GetDetailsResponseFut;
949}
950#[derive(Debug)]
951#[cfg(target_os = "fuchsia")]
952pub struct MessageControllerSynchronousProxy {
953    client: fidl::client::sync::Client,
954}
955
956#[cfg(target_os = "fuchsia")]
957impl fidl::endpoints::SynchronousProxy for MessageControllerSynchronousProxy {
958    type Proxy = MessageControllerProxy;
959    type Protocol = MessageControllerMarker;
960
961    fn from_channel(inner: fidl::Channel) -> Self {
962        Self::new(inner)
963    }
964
965    fn into_channel(self) -> fidl::Channel {
966        self.client.into_channel()
967    }
968
969    fn as_channel(&self) -> &fidl::Channel {
970        self.client.as_channel()
971    }
972}
973
974#[cfg(target_os = "fuchsia")]
975impl MessageControllerSynchronousProxy {
976    pub fn new(channel: fidl::Channel) -> Self {
977        Self { client: fidl::client::sync::Client::new(channel) }
978    }
979
980    pub fn into_channel(self) -> fidl::Channel {
981        self.client.into_channel()
982    }
983
984    /// Waits until an event arrives and returns it. It is safe for other
985    /// threads to make concurrent requests while waiting for an event.
986    pub fn wait_for_event(
987        &self,
988        deadline: zx::MonotonicInstant,
989    ) -> Result<MessageControllerEvent, fidl::Error> {
990        MessageControllerEvent::decode(
991            self.client.wait_for_event::<MessageControllerMarker>(deadline)?,
992        )
993    }
994
995    /// Retrieve all available message details.
996    /// + request `handle` Unique identifier for a Messsage.
997    /// + request `include_attachment` Whether or not attachment should be included as
998    ///                                part of Message content if it's available.
999    /// - response NOT_FOUND error is returned if the message with the given handle does not exist.
1000    pub fn r#get_details(
1001        &self,
1002        mut handle: u64,
1003        mut include_attachment: bool,
1004        ___deadline: zx::MonotonicInstant,
1005    ) -> Result<MessageControllerGetDetailsResult, fidl::Error> {
1006        let _response = self.client.send_query::<
1007            MessageControllerGetDetailsRequest,
1008            fidl::encoding::FlexibleResultType<Message, Error>,
1009            MessageControllerMarker,
1010        >(
1011            (handle, include_attachment,),
1012            0x7c3667b69d66691e,
1013            fidl::encoding::DynamicFlags::FLEXIBLE,
1014            ___deadline,
1015        )?
1016        .into_result::<MessageControllerMarker>("get_details")?;
1017        Ok(_response.map(|x| x))
1018    }
1019}
1020
1021#[cfg(target_os = "fuchsia")]
1022impl From<MessageControllerSynchronousProxy> for zx::NullableHandle {
1023    fn from(value: MessageControllerSynchronousProxy) -> Self {
1024        value.into_channel().into()
1025    }
1026}
1027
1028#[cfg(target_os = "fuchsia")]
1029impl From<fidl::Channel> for MessageControllerSynchronousProxy {
1030    fn from(value: fidl::Channel) -> Self {
1031        Self::new(value)
1032    }
1033}
1034
1035#[cfg(target_os = "fuchsia")]
1036impl fidl::endpoints::FromClient for MessageControllerSynchronousProxy {
1037    type Protocol = MessageControllerMarker;
1038
1039    fn from_client(value: fidl::endpoints::ClientEnd<MessageControllerMarker>) -> Self {
1040        Self::new(value.into_channel())
1041    }
1042}
1043
1044#[derive(Debug, Clone)]
1045pub struct MessageControllerProxy {
1046    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1047}
1048
1049impl fidl::endpoints::Proxy for MessageControllerProxy {
1050    type Protocol = MessageControllerMarker;
1051
1052    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1053        Self::new(inner)
1054    }
1055
1056    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1057        self.client.into_channel().map_err(|client| Self { client })
1058    }
1059
1060    fn as_channel(&self) -> &::fidl::AsyncChannel {
1061        self.client.as_channel()
1062    }
1063}
1064
1065impl MessageControllerProxy {
1066    /// Create a new Proxy for fuchsia.bluetooth.map/MessageController.
1067    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1068        let protocol_name =
1069            <MessageControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1070        Self { client: fidl::client::Client::new(channel, protocol_name) }
1071    }
1072
1073    /// Get a Stream of events from the remote end of the protocol.
1074    ///
1075    /// # Panics
1076    ///
1077    /// Panics if the event stream was already taken.
1078    pub fn take_event_stream(&self) -> MessageControllerEventStream {
1079        MessageControllerEventStream { event_receiver: self.client.take_event_receiver() }
1080    }
1081
1082    /// Retrieve all available message details.
1083    /// + request `handle` Unique identifier for a Messsage.
1084    /// + request `include_attachment` Whether or not attachment should be included as
1085    ///                                part of Message content if it's available.
1086    /// - response NOT_FOUND error is returned if the message with the given handle does not exist.
1087    pub fn r#get_details(
1088        &self,
1089        mut handle: u64,
1090        mut include_attachment: bool,
1091    ) -> fidl::client::QueryResponseFut<
1092        MessageControllerGetDetailsResult,
1093        fidl::encoding::DefaultFuchsiaResourceDialect,
1094    > {
1095        MessageControllerProxyInterface::r#get_details(self, handle, include_attachment)
1096    }
1097}
1098
1099impl MessageControllerProxyInterface for MessageControllerProxy {
1100    type GetDetailsResponseFut = fidl::client::QueryResponseFut<
1101        MessageControllerGetDetailsResult,
1102        fidl::encoding::DefaultFuchsiaResourceDialect,
1103    >;
1104    fn r#get_details(
1105        &self,
1106        mut handle: u64,
1107        mut include_attachment: bool,
1108    ) -> Self::GetDetailsResponseFut {
1109        fn _decode(
1110            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1111        ) -> Result<MessageControllerGetDetailsResult, fidl::Error> {
1112            let _response = fidl::client::decode_transaction_body::<
1113                fidl::encoding::FlexibleResultType<Message, Error>,
1114                fidl::encoding::DefaultFuchsiaResourceDialect,
1115                0x7c3667b69d66691e,
1116            >(_buf?)?
1117            .into_result::<MessageControllerMarker>("get_details")?;
1118            Ok(_response.map(|x| x))
1119        }
1120        self.client.send_query_and_decode::<
1121            MessageControllerGetDetailsRequest,
1122            MessageControllerGetDetailsResult,
1123        >(
1124            (handle, include_attachment,),
1125            0x7c3667b69d66691e,
1126            fidl::encoding::DynamicFlags::FLEXIBLE,
1127            _decode,
1128        )
1129    }
1130}
1131
1132pub struct MessageControllerEventStream {
1133    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1134}
1135
1136impl std::marker::Unpin for MessageControllerEventStream {}
1137
1138impl futures::stream::FusedStream for MessageControllerEventStream {
1139    fn is_terminated(&self) -> bool {
1140        self.event_receiver.is_terminated()
1141    }
1142}
1143
1144impl futures::Stream for MessageControllerEventStream {
1145    type Item = Result<MessageControllerEvent, fidl::Error>;
1146
1147    fn poll_next(
1148        mut self: std::pin::Pin<&mut Self>,
1149        cx: &mut std::task::Context<'_>,
1150    ) -> std::task::Poll<Option<Self::Item>> {
1151        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1152            &mut self.event_receiver,
1153            cx
1154        )?) {
1155            Some(buf) => std::task::Poll::Ready(Some(MessageControllerEvent::decode(buf))),
1156            None => std::task::Poll::Ready(None),
1157        }
1158    }
1159}
1160
1161#[derive(Debug)]
1162pub enum MessageControllerEvent {
1163    #[non_exhaustive]
1164    _UnknownEvent {
1165        /// Ordinal of the event that was sent.
1166        ordinal: u64,
1167    },
1168}
1169
1170impl MessageControllerEvent {
1171    /// Decodes a message buffer as a [`MessageControllerEvent`].
1172    fn decode(
1173        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1174    ) -> Result<MessageControllerEvent, fidl::Error> {
1175        let (bytes, _handles) = buf.split_mut();
1176        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1177        debug_assert_eq!(tx_header.tx_id, 0);
1178        match tx_header.ordinal {
1179            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1180                Ok(MessageControllerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1181            }
1182            _ => Err(fidl::Error::UnknownOrdinal {
1183                ordinal: tx_header.ordinal,
1184                protocol_name:
1185                    <MessageControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1186            }),
1187        }
1188    }
1189}
1190
1191/// A Stream of incoming requests for fuchsia.bluetooth.map/MessageController.
1192pub struct MessageControllerRequestStream {
1193    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1194    is_terminated: bool,
1195}
1196
1197impl std::marker::Unpin for MessageControllerRequestStream {}
1198
1199impl futures::stream::FusedStream for MessageControllerRequestStream {
1200    fn is_terminated(&self) -> bool {
1201        self.is_terminated
1202    }
1203}
1204
1205impl fidl::endpoints::RequestStream for MessageControllerRequestStream {
1206    type Protocol = MessageControllerMarker;
1207    type ControlHandle = MessageControllerControlHandle;
1208
1209    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1210        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1211    }
1212
1213    fn control_handle(&self) -> Self::ControlHandle {
1214        MessageControllerControlHandle { inner: self.inner.clone() }
1215    }
1216
1217    fn into_inner(
1218        self,
1219    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1220    {
1221        (self.inner, self.is_terminated)
1222    }
1223
1224    fn from_inner(
1225        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1226        is_terminated: bool,
1227    ) -> Self {
1228        Self { inner, is_terminated }
1229    }
1230}
1231
1232impl futures::Stream for MessageControllerRequestStream {
1233    type Item = Result<MessageControllerRequest, fidl::Error>;
1234
1235    fn poll_next(
1236        mut self: std::pin::Pin<&mut Self>,
1237        cx: &mut std::task::Context<'_>,
1238    ) -> std::task::Poll<Option<Self::Item>> {
1239        let this = &mut *self;
1240        if this.inner.check_shutdown(cx) {
1241            this.is_terminated = true;
1242            return std::task::Poll::Ready(None);
1243        }
1244        if this.is_terminated {
1245            panic!("polled MessageControllerRequestStream after completion");
1246        }
1247        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1248            |bytes, handles| {
1249                match this.inner.channel().read_etc(cx, bytes, handles) {
1250                    std::task::Poll::Ready(Ok(())) => {}
1251                    std::task::Poll::Pending => return std::task::Poll::Pending,
1252                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1253                        this.is_terminated = true;
1254                        return std::task::Poll::Ready(None);
1255                    }
1256                    std::task::Poll::Ready(Err(e)) => {
1257                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1258                            e.into(),
1259                        ))));
1260                    }
1261                }
1262
1263                // A message has been received from the channel
1264                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1265
1266                std::task::Poll::Ready(Some(match header.ordinal {
1267                    0x7c3667b69d66691e => {
1268                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1269                        let mut req = fidl::new_empty!(
1270                            MessageControllerGetDetailsRequest,
1271                            fidl::encoding::DefaultFuchsiaResourceDialect
1272                        );
1273                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<MessageControllerGetDetailsRequest>(&header, _body_bytes, handles, &mut req)?;
1274                        let control_handle =
1275                            MessageControllerControlHandle { inner: this.inner.clone() };
1276                        Ok(MessageControllerRequest::GetDetails {
1277                            handle: req.handle,
1278                            include_attachment: req.include_attachment,
1279
1280                            responder: MessageControllerGetDetailsResponder {
1281                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1282                                tx_id: header.tx_id,
1283                            },
1284                        })
1285                    }
1286                    _ if header.tx_id == 0
1287                        && header
1288                            .dynamic_flags()
1289                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1290                    {
1291                        Ok(MessageControllerRequest::_UnknownMethod {
1292                            ordinal: header.ordinal,
1293                            control_handle: MessageControllerControlHandle {
1294                                inner: this.inner.clone(),
1295                            },
1296                            method_type: fidl::MethodType::OneWay,
1297                        })
1298                    }
1299                    _ if header
1300                        .dynamic_flags()
1301                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1302                    {
1303                        this.inner.send_framework_err(
1304                            fidl::encoding::FrameworkErr::UnknownMethod,
1305                            header.tx_id,
1306                            header.ordinal,
1307                            header.dynamic_flags(),
1308                            (bytes, handles),
1309                        )?;
1310                        Ok(MessageControllerRequest::_UnknownMethod {
1311                            ordinal: header.ordinal,
1312                            control_handle: MessageControllerControlHandle {
1313                                inner: this.inner.clone(),
1314                            },
1315                            method_type: fidl::MethodType::TwoWay,
1316                        })
1317                    }
1318                    _ => Err(fidl::Error::UnknownOrdinal {
1319                        ordinal: header.ordinal,
1320                        protocol_name:
1321                            <MessageControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1322                    }),
1323                }))
1324            },
1325        )
1326    }
1327}
1328
1329#[derive(Debug)]
1330pub enum MessageControllerRequest {
1331    /// Retrieve all available message details.
1332    /// + request `handle` Unique identifier for a Messsage.
1333    /// + request `include_attachment` Whether or not attachment should be included as
1334    ///                                part of Message content if it's available.
1335    /// - response NOT_FOUND error is returned if the message with the given handle does not exist.
1336    GetDetails {
1337        handle: u64,
1338        include_attachment: bool,
1339        responder: MessageControllerGetDetailsResponder,
1340    },
1341    /// An interaction was received which does not match any known method.
1342    #[non_exhaustive]
1343    _UnknownMethod {
1344        /// Ordinal of the method that was called.
1345        ordinal: u64,
1346        control_handle: MessageControllerControlHandle,
1347        method_type: fidl::MethodType,
1348    },
1349}
1350
1351impl MessageControllerRequest {
1352    #[allow(irrefutable_let_patterns)]
1353    pub fn into_get_details(self) -> Option<(u64, bool, MessageControllerGetDetailsResponder)> {
1354        if let MessageControllerRequest::GetDetails { handle, include_attachment, responder } = self
1355        {
1356            Some((handle, include_attachment, responder))
1357        } else {
1358            None
1359        }
1360    }
1361
1362    /// Name of the method defined in FIDL
1363    pub fn method_name(&self) -> &'static str {
1364        match *self {
1365            MessageControllerRequest::GetDetails { .. } => "get_details",
1366            MessageControllerRequest::_UnknownMethod {
1367                method_type: fidl::MethodType::OneWay,
1368                ..
1369            } => "unknown one-way method",
1370            MessageControllerRequest::_UnknownMethod {
1371                method_type: fidl::MethodType::TwoWay,
1372                ..
1373            } => "unknown two-way method",
1374        }
1375    }
1376}
1377
1378#[derive(Debug, Clone)]
1379pub struct MessageControllerControlHandle {
1380    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1381}
1382
1383impl fidl::endpoints::ControlHandle for MessageControllerControlHandle {
1384    fn shutdown(&self) {
1385        self.inner.shutdown()
1386    }
1387
1388    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1389        self.inner.shutdown_with_epitaph(status)
1390    }
1391
1392    fn is_closed(&self) -> bool {
1393        self.inner.channel().is_closed()
1394    }
1395    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1396        self.inner.channel().on_closed()
1397    }
1398
1399    #[cfg(target_os = "fuchsia")]
1400    fn signal_peer(
1401        &self,
1402        clear_mask: zx::Signals,
1403        set_mask: zx::Signals,
1404    ) -> Result<(), zx_status::Status> {
1405        use fidl::Peered;
1406        self.inner.channel().signal_peer(clear_mask, set_mask)
1407    }
1408}
1409
1410impl MessageControllerControlHandle {}
1411
1412#[must_use = "FIDL methods require a response to be sent"]
1413#[derive(Debug)]
1414pub struct MessageControllerGetDetailsResponder {
1415    control_handle: std::mem::ManuallyDrop<MessageControllerControlHandle>,
1416    tx_id: u32,
1417}
1418
1419/// Set the the channel to be shutdown (see [`MessageControllerControlHandle::shutdown`])
1420/// if the responder is dropped without sending a response, so that the client
1421/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1422impl std::ops::Drop for MessageControllerGetDetailsResponder {
1423    fn drop(&mut self) {
1424        self.control_handle.shutdown();
1425        // Safety: drops once, never accessed again
1426        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1427    }
1428}
1429
1430impl fidl::endpoints::Responder for MessageControllerGetDetailsResponder {
1431    type ControlHandle = MessageControllerControlHandle;
1432
1433    fn control_handle(&self) -> &MessageControllerControlHandle {
1434        &self.control_handle
1435    }
1436
1437    fn drop_without_shutdown(mut self) {
1438        // Safety: drops once, never accessed again due to mem::forget
1439        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1440        // Prevent Drop from running (which would shut down the channel)
1441        std::mem::forget(self);
1442    }
1443}
1444
1445impl MessageControllerGetDetailsResponder {
1446    /// Sends a response to the FIDL transaction.
1447    ///
1448    /// Sets the channel to shutdown if an error occurs.
1449    pub fn send(self, mut result: Result<&Message, Error>) -> Result<(), fidl::Error> {
1450        let _result = self.send_raw(result);
1451        if _result.is_err() {
1452            self.control_handle.shutdown();
1453        }
1454        self.drop_without_shutdown();
1455        _result
1456    }
1457
1458    /// Similar to "send" but does not shutdown the channel if an error occurs.
1459    pub fn send_no_shutdown_on_err(
1460        self,
1461        mut result: Result<&Message, Error>,
1462    ) -> Result<(), fidl::Error> {
1463        let _result = self.send_raw(result);
1464        self.drop_without_shutdown();
1465        _result
1466    }
1467
1468    fn send_raw(&self, mut result: Result<&Message, Error>) -> Result<(), fidl::Error> {
1469        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<Message, Error>>(
1470            fidl::encoding::FlexibleResult::new(result),
1471            self.tx_id,
1472            0x7c3667b69d66691e,
1473            fidl::encoding::DynamicFlags::FLEXIBLE,
1474        )
1475    }
1476}
1477
1478#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1479pub struct MessagingClientMarker;
1480
1481impl fidl::endpoints::ProtocolMarker for MessagingClientMarker {
1482    type Proxy = MessagingClientProxy;
1483    type RequestStream = MessagingClientRequestStream;
1484    #[cfg(target_os = "fuchsia")]
1485    type SynchronousProxy = MessagingClientSynchronousProxy;
1486
1487    const DEBUG_NAME: &'static str = "fuchsia.bluetooth.map.MessagingClient";
1488}
1489impl fidl::endpoints::DiscoverableProtocolMarker for MessagingClientMarker {}
1490pub type MessagingClientWatchAccessorResult = Result<MessagingClientWatchAccessorResponse, Error>;
1491
1492pub trait MessagingClientProxyInterface: Send + Sync {
1493    type WatchAccessorResponseFut: std::future::Future<Output = Result<MessagingClientWatchAccessorResult, fidl::Error>>
1494        + Send;
1495    fn r#watch_accessor(&self) -> Self::WatchAccessorResponseFut;
1496}
1497#[derive(Debug)]
1498#[cfg(target_os = "fuchsia")]
1499pub struct MessagingClientSynchronousProxy {
1500    client: fidl::client::sync::Client,
1501}
1502
1503#[cfg(target_os = "fuchsia")]
1504impl fidl::endpoints::SynchronousProxy for MessagingClientSynchronousProxy {
1505    type Proxy = MessagingClientProxy;
1506    type Protocol = MessagingClientMarker;
1507
1508    fn from_channel(inner: fidl::Channel) -> Self {
1509        Self::new(inner)
1510    }
1511
1512    fn into_channel(self) -> fidl::Channel {
1513        self.client.into_channel()
1514    }
1515
1516    fn as_channel(&self) -> &fidl::Channel {
1517        self.client.as_channel()
1518    }
1519}
1520
1521#[cfg(target_os = "fuchsia")]
1522impl MessagingClientSynchronousProxy {
1523    pub fn new(channel: fidl::Channel) -> Self {
1524        Self { client: fidl::client::sync::Client::new(channel) }
1525    }
1526
1527    pub fn into_channel(self) -> fidl::Channel {
1528        self.client.into_channel()
1529    }
1530
1531    /// Waits until an event arrives and returns it. It is safe for other
1532    /// threads to make concurrent requests while waiting for an event.
1533    pub fn wait_for_event(
1534        &self,
1535        deadline: zx::MonotonicInstant,
1536    ) -> Result<MessagingClientEvent, fidl::Error> {
1537        MessagingClientEvent::decode(self.client.wait_for_event::<MessagingClientMarker>(deadline)?)
1538    }
1539
1540    /// An `Accessor` will be returned for each peer as they are
1541    /// connected, and only one exists at a time for each peer.
1542    /// Hangs until a new peer becomes available once all connected
1543    /// peers have been delivered through this protocol.
1544    /// Returns an error if [WatchAccessor] is called again when there
1545    /// already is a pending request.
1546    pub fn r#watch_accessor(
1547        &self,
1548        ___deadline: zx::MonotonicInstant,
1549    ) -> Result<MessagingClientWatchAccessorResult, fidl::Error> {
1550        let _response = self.client.send_query::<
1551            fidl::encoding::EmptyPayload,
1552            fidl::encoding::FlexibleResultType<MessagingClientWatchAccessorResponse, Error>,
1553            MessagingClientMarker,
1554        >(
1555            (),
1556            0x269e876c67302299,
1557            fidl::encoding::DynamicFlags::FLEXIBLE,
1558            ___deadline,
1559        )?
1560        .into_result::<MessagingClientMarker>("watch_accessor")?;
1561        Ok(_response.map(|x| x))
1562    }
1563}
1564
1565#[cfg(target_os = "fuchsia")]
1566impl From<MessagingClientSynchronousProxy> for zx::NullableHandle {
1567    fn from(value: MessagingClientSynchronousProxy) -> Self {
1568        value.into_channel().into()
1569    }
1570}
1571
1572#[cfg(target_os = "fuchsia")]
1573impl From<fidl::Channel> for MessagingClientSynchronousProxy {
1574    fn from(value: fidl::Channel) -> Self {
1575        Self::new(value)
1576    }
1577}
1578
1579#[cfg(target_os = "fuchsia")]
1580impl fidl::endpoints::FromClient for MessagingClientSynchronousProxy {
1581    type Protocol = MessagingClientMarker;
1582
1583    fn from_client(value: fidl::endpoints::ClientEnd<MessagingClientMarker>) -> Self {
1584        Self::new(value.into_channel())
1585    }
1586}
1587
1588#[derive(Debug, Clone)]
1589pub struct MessagingClientProxy {
1590    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1591}
1592
1593impl fidl::endpoints::Proxy for MessagingClientProxy {
1594    type Protocol = MessagingClientMarker;
1595
1596    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1597        Self::new(inner)
1598    }
1599
1600    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1601        self.client.into_channel().map_err(|client| Self { client })
1602    }
1603
1604    fn as_channel(&self) -> &::fidl::AsyncChannel {
1605        self.client.as_channel()
1606    }
1607}
1608
1609impl MessagingClientProxy {
1610    /// Create a new Proxy for fuchsia.bluetooth.map/MessagingClient.
1611    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1612        let protocol_name = <MessagingClientMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1613        Self { client: fidl::client::Client::new(channel, protocol_name) }
1614    }
1615
1616    /// Get a Stream of events from the remote end of the protocol.
1617    ///
1618    /// # Panics
1619    ///
1620    /// Panics if the event stream was already taken.
1621    pub fn take_event_stream(&self) -> MessagingClientEventStream {
1622        MessagingClientEventStream { event_receiver: self.client.take_event_receiver() }
1623    }
1624
1625    /// An `Accessor` will be returned for each peer as they are
1626    /// connected, and only one exists at a time for each peer.
1627    /// Hangs until a new peer becomes available once all connected
1628    /// peers have been delivered through this protocol.
1629    /// Returns an error if [WatchAccessor] is called again when there
1630    /// already is a pending request.
1631    pub fn r#watch_accessor(
1632        &self,
1633    ) -> fidl::client::QueryResponseFut<
1634        MessagingClientWatchAccessorResult,
1635        fidl::encoding::DefaultFuchsiaResourceDialect,
1636    > {
1637        MessagingClientProxyInterface::r#watch_accessor(self)
1638    }
1639}
1640
1641impl MessagingClientProxyInterface for MessagingClientProxy {
1642    type WatchAccessorResponseFut = fidl::client::QueryResponseFut<
1643        MessagingClientWatchAccessorResult,
1644        fidl::encoding::DefaultFuchsiaResourceDialect,
1645    >;
1646    fn r#watch_accessor(&self) -> Self::WatchAccessorResponseFut {
1647        fn _decode(
1648            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1649        ) -> Result<MessagingClientWatchAccessorResult, fidl::Error> {
1650            let _response = fidl::client::decode_transaction_body::<
1651                fidl::encoding::FlexibleResultType<MessagingClientWatchAccessorResponse, Error>,
1652                fidl::encoding::DefaultFuchsiaResourceDialect,
1653                0x269e876c67302299,
1654            >(_buf?)?
1655            .into_result::<MessagingClientMarker>("watch_accessor")?;
1656            Ok(_response.map(|x| x))
1657        }
1658        self.client.send_query_and_decode::<
1659            fidl::encoding::EmptyPayload,
1660            MessagingClientWatchAccessorResult,
1661        >(
1662            (),
1663            0x269e876c67302299,
1664            fidl::encoding::DynamicFlags::FLEXIBLE,
1665            _decode,
1666        )
1667    }
1668}
1669
1670pub struct MessagingClientEventStream {
1671    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1672}
1673
1674impl std::marker::Unpin for MessagingClientEventStream {}
1675
1676impl futures::stream::FusedStream for MessagingClientEventStream {
1677    fn is_terminated(&self) -> bool {
1678        self.event_receiver.is_terminated()
1679    }
1680}
1681
1682impl futures::Stream for MessagingClientEventStream {
1683    type Item = Result<MessagingClientEvent, fidl::Error>;
1684
1685    fn poll_next(
1686        mut self: std::pin::Pin<&mut Self>,
1687        cx: &mut std::task::Context<'_>,
1688    ) -> std::task::Poll<Option<Self::Item>> {
1689        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1690            &mut self.event_receiver,
1691            cx
1692        )?) {
1693            Some(buf) => std::task::Poll::Ready(Some(MessagingClientEvent::decode(buf))),
1694            None => std::task::Poll::Ready(None),
1695        }
1696    }
1697}
1698
1699#[derive(Debug)]
1700pub enum MessagingClientEvent {
1701    #[non_exhaustive]
1702    _UnknownEvent {
1703        /// Ordinal of the event that was sent.
1704        ordinal: u64,
1705    },
1706}
1707
1708impl MessagingClientEvent {
1709    /// Decodes a message buffer as a [`MessagingClientEvent`].
1710    fn decode(
1711        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1712    ) -> Result<MessagingClientEvent, fidl::Error> {
1713        let (bytes, _handles) = buf.split_mut();
1714        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1715        debug_assert_eq!(tx_header.tx_id, 0);
1716        match tx_header.ordinal {
1717            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1718                Ok(MessagingClientEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1719            }
1720            _ => Err(fidl::Error::UnknownOrdinal {
1721                ordinal: tx_header.ordinal,
1722                protocol_name:
1723                    <MessagingClientMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1724            }),
1725        }
1726    }
1727}
1728
1729/// A Stream of incoming requests for fuchsia.bluetooth.map/MessagingClient.
1730pub struct MessagingClientRequestStream {
1731    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1732    is_terminated: bool,
1733}
1734
1735impl std::marker::Unpin for MessagingClientRequestStream {}
1736
1737impl futures::stream::FusedStream for MessagingClientRequestStream {
1738    fn is_terminated(&self) -> bool {
1739        self.is_terminated
1740    }
1741}
1742
1743impl fidl::endpoints::RequestStream for MessagingClientRequestStream {
1744    type Protocol = MessagingClientMarker;
1745    type ControlHandle = MessagingClientControlHandle;
1746
1747    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1748        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1749    }
1750
1751    fn control_handle(&self) -> Self::ControlHandle {
1752        MessagingClientControlHandle { inner: self.inner.clone() }
1753    }
1754
1755    fn into_inner(
1756        self,
1757    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1758    {
1759        (self.inner, self.is_terminated)
1760    }
1761
1762    fn from_inner(
1763        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1764        is_terminated: bool,
1765    ) -> Self {
1766        Self { inner, is_terminated }
1767    }
1768}
1769
1770impl futures::Stream for MessagingClientRequestStream {
1771    type Item = Result<MessagingClientRequest, fidl::Error>;
1772
1773    fn poll_next(
1774        mut self: std::pin::Pin<&mut Self>,
1775        cx: &mut std::task::Context<'_>,
1776    ) -> std::task::Poll<Option<Self::Item>> {
1777        let this = &mut *self;
1778        if this.inner.check_shutdown(cx) {
1779            this.is_terminated = true;
1780            return std::task::Poll::Ready(None);
1781        }
1782        if this.is_terminated {
1783            panic!("polled MessagingClientRequestStream after completion");
1784        }
1785        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1786            |bytes, handles| {
1787                match this.inner.channel().read_etc(cx, bytes, handles) {
1788                    std::task::Poll::Ready(Ok(())) => {}
1789                    std::task::Poll::Pending => return std::task::Poll::Pending,
1790                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1791                        this.is_terminated = true;
1792                        return std::task::Poll::Ready(None);
1793                    }
1794                    std::task::Poll::Ready(Err(e)) => {
1795                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1796                            e.into(),
1797                        ))));
1798                    }
1799                }
1800
1801                // A message has been received from the channel
1802                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1803
1804                std::task::Poll::Ready(Some(match header.ordinal {
1805                    0x269e876c67302299 => {
1806                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1807                        let mut req = fidl::new_empty!(
1808                            fidl::encoding::EmptyPayload,
1809                            fidl::encoding::DefaultFuchsiaResourceDialect
1810                        );
1811                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1812                        let control_handle =
1813                            MessagingClientControlHandle { inner: this.inner.clone() };
1814                        Ok(MessagingClientRequest::WatchAccessor {
1815                            responder: MessagingClientWatchAccessorResponder {
1816                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1817                                tx_id: header.tx_id,
1818                            },
1819                        })
1820                    }
1821                    _ if header.tx_id == 0
1822                        && header
1823                            .dynamic_flags()
1824                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1825                    {
1826                        Ok(MessagingClientRequest::_UnknownMethod {
1827                            ordinal: header.ordinal,
1828                            control_handle: MessagingClientControlHandle {
1829                                inner: this.inner.clone(),
1830                            },
1831                            method_type: fidl::MethodType::OneWay,
1832                        })
1833                    }
1834                    _ if header
1835                        .dynamic_flags()
1836                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1837                    {
1838                        this.inner.send_framework_err(
1839                            fidl::encoding::FrameworkErr::UnknownMethod,
1840                            header.tx_id,
1841                            header.ordinal,
1842                            header.dynamic_flags(),
1843                            (bytes, handles),
1844                        )?;
1845                        Ok(MessagingClientRequest::_UnknownMethod {
1846                            ordinal: header.ordinal,
1847                            control_handle: MessagingClientControlHandle {
1848                                inner: this.inner.clone(),
1849                            },
1850                            method_type: fidl::MethodType::TwoWay,
1851                        })
1852                    }
1853                    _ => Err(fidl::Error::UnknownOrdinal {
1854                        ordinal: header.ordinal,
1855                        protocol_name:
1856                            <MessagingClientMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1857                    }),
1858                }))
1859            },
1860        )
1861    }
1862}
1863
1864/// Use a MessagingClient to access messages on one or more Instances on
1865/// Message Access Servers.
1866#[derive(Debug)]
1867pub enum MessagingClientRequest {
1868    /// An `Accessor` will be returned for each peer as they are
1869    /// connected, and only one exists at a time for each peer.
1870    /// Hangs until a new peer becomes available once all connected
1871    /// peers have been delivered through this protocol.
1872    /// Returns an error if [WatchAccessor] is called again when there
1873    /// already is a pending request.
1874    WatchAccessor { responder: MessagingClientWatchAccessorResponder },
1875    /// An interaction was received which does not match any known method.
1876    #[non_exhaustive]
1877    _UnknownMethod {
1878        /// Ordinal of the method that was called.
1879        ordinal: u64,
1880        control_handle: MessagingClientControlHandle,
1881        method_type: fidl::MethodType,
1882    },
1883}
1884
1885impl MessagingClientRequest {
1886    #[allow(irrefutable_let_patterns)]
1887    pub fn into_watch_accessor(self) -> Option<(MessagingClientWatchAccessorResponder)> {
1888        if let MessagingClientRequest::WatchAccessor { responder } = self {
1889            Some((responder))
1890        } else {
1891            None
1892        }
1893    }
1894
1895    /// Name of the method defined in FIDL
1896    pub fn method_name(&self) -> &'static str {
1897        match *self {
1898            MessagingClientRequest::WatchAccessor { .. } => "watch_accessor",
1899            MessagingClientRequest::_UnknownMethod {
1900                method_type: fidl::MethodType::OneWay,
1901                ..
1902            } => "unknown one-way method",
1903            MessagingClientRequest::_UnknownMethod {
1904                method_type: fidl::MethodType::TwoWay,
1905                ..
1906            } => "unknown two-way method",
1907        }
1908    }
1909}
1910
1911#[derive(Debug, Clone)]
1912pub struct MessagingClientControlHandle {
1913    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1914}
1915
1916impl fidl::endpoints::ControlHandle for MessagingClientControlHandle {
1917    fn shutdown(&self) {
1918        self.inner.shutdown()
1919    }
1920
1921    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1922        self.inner.shutdown_with_epitaph(status)
1923    }
1924
1925    fn is_closed(&self) -> bool {
1926        self.inner.channel().is_closed()
1927    }
1928    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1929        self.inner.channel().on_closed()
1930    }
1931
1932    #[cfg(target_os = "fuchsia")]
1933    fn signal_peer(
1934        &self,
1935        clear_mask: zx::Signals,
1936        set_mask: zx::Signals,
1937    ) -> Result<(), zx_status::Status> {
1938        use fidl::Peered;
1939        self.inner.channel().signal_peer(clear_mask, set_mask)
1940    }
1941}
1942
1943impl MessagingClientControlHandle {}
1944
1945#[must_use = "FIDL methods require a response to be sent"]
1946#[derive(Debug)]
1947pub struct MessagingClientWatchAccessorResponder {
1948    control_handle: std::mem::ManuallyDrop<MessagingClientControlHandle>,
1949    tx_id: u32,
1950}
1951
1952/// Set the the channel to be shutdown (see [`MessagingClientControlHandle::shutdown`])
1953/// if the responder is dropped without sending a response, so that the client
1954/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1955impl std::ops::Drop for MessagingClientWatchAccessorResponder {
1956    fn drop(&mut self) {
1957        self.control_handle.shutdown();
1958        // Safety: drops once, never accessed again
1959        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1960    }
1961}
1962
1963impl fidl::endpoints::Responder for MessagingClientWatchAccessorResponder {
1964    type ControlHandle = MessagingClientControlHandle;
1965
1966    fn control_handle(&self) -> &MessagingClientControlHandle {
1967        &self.control_handle
1968    }
1969
1970    fn drop_without_shutdown(mut self) {
1971        // Safety: drops once, never accessed again due to mem::forget
1972        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1973        // Prevent Drop from running (which would shut down the channel)
1974        std::mem::forget(self);
1975    }
1976}
1977
1978impl MessagingClientWatchAccessorResponder {
1979    /// Sends a response to the FIDL transaction.
1980    ///
1981    /// Sets the channel to shutdown if an error occurs.
1982    pub fn send(
1983        self,
1984        mut result: Result<MessagingClientWatchAccessorResponse, Error>,
1985    ) -> Result<(), fidl::Error> {
1986        let _result = self.send_raw(result);
1987        if _result.is_err() {
1988            self.control_handle.shutdown();
1989        }
1990        self.drop_without_shutdown();
1991        _result
1992    }
1993
1994    /// Similar to "send" but does not shutdown the channel if an error occurs.
1995    pub fn send_no_shutdown_on_err(
1996        self,
1997        mut result: Result<MessagingClientWatchAccessorResponse, Error>,
1998    ) -> Result<(), fidl::Error> {
1999        let _result = self.send_raw(result);
2000        self.drop_without_shutdown();
2001        _result
2002    }
2003
2004    fn send_raw(
2005        &self,
2006        mut result: Result<MessagingClientWatchAccessorResponse, Error>,
2007    ) -> Result<(), fidl::Error> {
2008        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2009            MessagingClientWatchAccessorResponse,
2010            Error,
2011        >>(
2012            fidl::encoding::FlexibleResult::new(result.as_mut().map_err(|e| *e)),
2013            self.tx_id,
2014            0x269e876c67302299,
2015            fidl::encoding::DynamicFlags::FLEXIBLE,
2016        )
2017    }
2018}
2019
2020#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2021pub struct NotificationRegistrationMarker;
2022
2023impl fidl::endpoints::ProtocolMarker for NotificationRegistrationMarker {
2024    type Proxy = NotificationRegistrationProxy;
2025    type RequestStream = NotificationRegistrationRequestStream;
2026    #[cfg(target_os = "fuchsia")]
2027    type SynchronousProxy = NotificationRegistrationSynchronousProxy;
2028
2029    const DEBUG_NAME: &'static str = "(anonymous) NotificationRegistration";
2030}
2031
2032pub trait NotificationRegistrationProxyInterface: Send + Sync {
2033    type NewEventReportResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
2034    fn r#new_event_report(
2035        &self,
2036        payload: &NotificationRegistrationNewEventReportRequest,
2037    ) -> Self::NewEventReportResponseFut;
2038}
2039#[derive(Debug)]
2040#[cfg(target_os = "fuchsia")]
2041pub struct NotificationRegistrationSynchronousProxy {
2042    client: fidl::client::sync::Client,
2043}
2044
2045#[cfg(target_os = "fuchsia")]
2046impl fidl::endpoints::SynchronousProxy for NotificationRegistrationSynchronousProxy {
2047    type Proxy = NotificationRegistrationProxy;
2048    type Protocol = NotificationRegistrationMarker;
2049
2050    fn from_channel(inner: fidl::Channel) -> Self {
2051        Self::new(inner)
2052    }
2053
2054    fn into_channel(self) -> fidl::Channel {
2055        self.client.into_channel()
2056    }
2057
2058    fn as_channel(&self) -> &fidl::Channel {
2059        self.client.as_channel()
2060    }
2061}
2062
2063#[cfg(target_os = "fuchsia")]
2064impl NotificationRegistrationSynchronousProxy {
2065    pub fn new(channel: fidl::Channel) -> Self {
2066        Self { client: fidl::client::sync::Client::new(channel) }
2067    }
2068
2069    pub fn into_channel(self) -> fidl::Channel {
2070        self.client.into_channel()
2071    }
2072
2073    /// Waits until an event arrives and returns it. It is safe for other
2074    /// threads to make concurrent requests while waiting for an event.
2075    pub fn wait_for_event(
2076        &self,
2077        deadline: zx::MonotonicInstant,
2078    ) -> Result<NotificationRegistrationEvent, fidl::Error> {
2079        NotificationRegistrationEvent::decode(
2080            self.client.wait_for_event::<NotificationRegistrationMarker>(deadline)?,
2081        )
2082    }
2083
2084    /// Relays incoming event report from the peer as a Notification.
2085    pub fn r#new_event_report(
2086        &self,
2087        mut payload: &NotificationRegistrationNewEventReportRequest,
2088        ___deadline: zx::MonotonicInstant,
2089    ) -> Result<(), fidl::Error> {
2090        let _response = self.client.send_query::<
2091            NotificationRegistrationNewEventReportRequest,
2092            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
2093            NotificationRegistrationMarker,
2094        >(
2095            payload,
2096            0x4c7d185363415f14,
2097            fidl::encoding::DynamicFlags::FLEXIBLE,
2098            ___deadline,
2099        )?
2100        .into_result::<NotificationRegistrationMarker>("new_event_report")?;
2101        Ok(_response)
2102    }
2103}
2104
2105#[cfg(target_os = "fuchsia")]
2106impl From<NotificationRegistrationSynchronousProxy> for zx::NullableHandle {
2107    fn from(value: NotificationRegistrationSynchronousProxy) -> Self {
2108        value.into_channel().into()
2109    }
2110}
2111
2112#[cfg(target_os = "fuchsia")]
2113impl From<fidl::Channel> for NotificationRegistrationSynchronousProxy {
2114    fn from(value: fidl::Channel) -> Self {
2115        Self::new(value)
2116    }
2117}
2118
2119#[cfg(target_os = "fuchsia")]
2120impl fidl::endpoints::FromClient for NotificationRegistrationSynchronousProxy {
2121    type Protocol = NotificationRegistrationMarker;
2122
2123    fn from_client(value: fidl::endpoints::ClientEnd<NotificationRegistrationMarker>) -> Self {
2124        Self::new(value.into_channel())
2125    }
2126}
2127
2128#[derive(Debug, Clone)]
2129pub struct NotificationRegistrationProxy {
2130    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2131}
2132
2133impl fidl::endpoints::Proxy for NotificationRegistrationProxy {
2134    type Protocol = NotificationRegistrationMarker;
2135
2136    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2137        Self::new(inner)
2138    }
2139
2140    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2141        self.client.into_channel().map_err(|client| Self { client })
2142    }
2143
2144    fn as_channel(&self) -> &::fidl::AsyncChannel {
2145        self.client.as_channel()
2146    }
2147}
2148
2149impl NotificationRegistrationProxy {
2150    /// Create a new Proxy for fuchsia.bluetooth.map/NotificationRegistration.
2151    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2152        let protocol_name =
2153            <NotificationRegistrationMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2154        Self { client: fidl::client::Client::new(channel, protocol_name) }
2155    }
2156
2157    /// Get a Stream of events from the remote end of the protocol.
2158    ///
2159    /// # Panics
2160    ///
2161    /// Panics if the event stream was already taken.
2162    pub fn take_event_stream(&self) -> NotificationRegistrationEventStream {
2163        NotificationRegistrationEventStream { event_receiver: self.client.take_event_receiver() }
2164    }
2165
2166    /// Relays incoming event report from the peer as a Notification.
2167    pub fn r#new_event_report(
2168        &self,
2169        mut payload: &NotificationRegistrationNewEventReportRequest,
2170    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
2171        NotificationRegistrationProxyInterface::r#new_event_report(self, payload)
2172    }
2173}
2174
2175impl NotificationRegistrationProxyInterface for NotificationRegistrationProxy {
2176    type NewEventReportResponseFut =
2177        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
2178    fn r#new_event_report(
2179        &self,
2180        mut payload: &NotificationRegistrationNewEventReportRequest,
2181    ) -> Self::NewEventReportResponseFut {
2182        fn _decode(
2183            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2184        ) -> Result<(), fidl::Error> {
2185            let _response = fidl::client::decode_transaction_body::<
2186                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
2187                fidl::encoding::DefaultFuchsiaResourceDialect,
2188                0x4c7d185363415f14,
2189            >(_buf?)?
2190            .into_result::<NotificationRegistrationMarker>("new_event_report")?;
2191            Ok(_response)
2192        }
2193        self.client.send_query_and_decode::<NotificationRegistrationNewEventReportRequest, ()>(
2194            payload,
2195            0x4c7d185363415f14,
2196            fidl::encoding::DynamicFlags::FLEXIBLE,
2197            _decode,
2198        )
2199    }
2200}
2201
2202pub struct NotificationRegistrationEventStream {
2203    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2204}
2205
2206impl std::marker::Unpin for NotificationRegistrationEventStream {}
2207
2208impl futures::stream::FusedStream for NotificationRegistrationEventStream {
2209    fn is_terminated(&self) -> bool {
2210        self.event_receiver.is_terminated()
2211    }
2212}
2213
2214impl futures::Stream for NotificationRegistrationEventStream {
2215    type Item = Result<NotificationRegistrationEvent, fidl::Error>;
2216
2217    fn poll_next(
2218        mut self: std::pin::Pin<&mut Self>,
2219        cx: &mut std::task::Context<'_>,
2220    ) -> std::task::Poll<Option<Self::Item>> {
2221        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2222            &mut self.event_receiver,
2223            cx
2224        )?) {
2225            Some(buf) => std::task::Poll::Ready(Some(NotificationRegistrationEvent::decode(buf))),
2226            None => std::task::Poll::Ready(None),
2227        }
2228    }
2229}
2230
2231#[derive(Debug)]
2232pub enum NotificationRegistrationEvent {
2233    #[non_exhaustive]
2234    _UnknownEvent {
2235        /// Ordinal of the event that was sent.
2236        ordinal: u64,
2237    },
2238}
2239
2240impl NotificationRegistrationEvent {
2241    /// Decodes a message buffer as a [`NotificationRegistrationEvent`].
2242    fn decode(
2243        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2244    ) -> Result<NotificationRegistrationEvent, fidl::Error> {
2245        let (bytes, _handles) = buf.split_mut();
2246        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2247        debug_assert_eq!(tx_header.tx_id, 0);
2248        match tx_header.ordinal {
2249            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2250                Ok(NotificationRegistrationEvent::_UnknownEvent { ordinal: tx_header.ordinal })
2251            }
2252            _ => Err(fidl::Error::UnknownOrdinal {
2253                ordinal: tx_header.ordinal,
2254                protocol_name:
2255                    <NotificationRegistrationMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2256            }),
2257        }
2258    }
2259}
2260
2261/// A Stream of incoming requests for fuchsia.bluetooth.map/NotificationRegistration.
2262pub struct NotificationRegistrationRequestStream {
2263    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2264    is_terminated: bool,
2265}
2266
2267impl std::marker::Unpin for NotificationRegistrationRequestStream {}
2268
2269impl futures::stream::FusedStream for NotificationRegistrationRequestStream {
2270    fn is_terminated(&self) -> bool {
2271        self.is_terminated
2272    }
2273}
2274
2275impl fidl::endpoints::RequestStream for NotificationRegistrationRequestStream {
2276    type Protocol = NotificationRegistrationMarker;
2277    type ControlHandle = NotificationRegistrationControlHandle;
2278
2279    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2280        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2281    }
2282
2283    fn control_handle(&self) -> Self::ControlHandle {
2284        NotificationRegistrationControlHandle { inner: self.inner.clone() }
2285    }
2286
2287    fn into_inner(
2288        self,
2289    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2290    {
2291        (self.inner, self.is_terminated)
2292    }
2293
2294    fn from_inner(
2295        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2296        is_terminated: bool,
2297    ) -> Self {
2298        Self { inner, is_terminated }
2299    }
2300}
2301
2302impl futures::Stream for NotificationRegistrationRequestStream {
2303    type Item = Result<NotificationRegistrationRequest, fidl::Error>;
2304
2305    fn poll_next(
2306        mut self: std::pin::Pin<&mut Self>,
2307        cx: &mut std::task::Context<'_>,
2308    ) -> std::task::Poll<Option<Self::Item>> {
2309        let this = &mut *self;
2310        if this.inner.check_shutdown(cx) {
2311            this.is_terminated = true;
2312            return std::task::Poll::Ready(None);
2313        }
2314        if this.is_terminated {
2315            panic!("polled NotificationRegistrationRequestStream after completion");
2316        }
2317        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2318            |bytes, handles| {
2319                match this.inner.channel().read_etc(cx, bytes, handles) {
2320                    std::task::Poll::Ready(Ok(())) => {}
2321                    std::task::Poll::Pending => return std::task::Poll::Pending,
2322                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2323                        this.is_terminated = true;
2324                        return std::task::Poll::Ready(None);
2325                    }
2326                    std::task::Poll::Ready(Err(e)) => {
2327                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2328                            e.into(),
2329                        ))));
2330                    }
2331                }
2332
2333                // A message has been received from the channel
2334                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2335
2336                std::task::Poll::Ready(Some(match header.ordinal {
2337                0x4c7d185363415f14 => {
2338                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2339                    let mut req = fidl::new_empty!(NotificationRegistrationNewEventReportRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
2340                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NotificationRegistrationNewEventReportRequest>(&header, _body_bytes, handles, &mut req)?;
2341                    let control_handle = NotificationRegistrationControlHandle {
2342                        inner: this.inner.clone(),
2343                    };
2344                    Ok(NotificationRegistrationRequest::NewEventReport {payload: req,
2345                        responder: NotificationRegistrationNewEventReportResponder {
2346                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2347                            tx_id: header.tx_id,
2348                        },
2349                    })
2350                }
2351                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2352                    Ok(NotificationRegistrationRequest::_UnknownMethod {
2353                        ordinal: header.ordinal,
2354                        control_handle: NotificationRegistrationControlHandle { inner: this.inner.clone() },
2355                        method_type: fidl::MethodType::OneWay,
2356                    })
2357                }
2358                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2359                    this.inner.send_framework_err(
2360                        fidl::encoding::FrameworkErr::UnknownMethod,
2361                        header.tx_id,
2362                        header.ordinal,
2363                        header.dynamic_flags(),
2364                        (bytes, handles),
2365                    )?;
2366                    Ok(NotificationRegistrationRequest::_UnknownMethod {
2367                        ordinal: header.ordinal,
2368                        control_handle: NotificationRegistrationControlHandle { inner: this.inner.clone() },
2369                        method_type: fidl::MethodType::TwoWay,
2370                    })
2371                }
2372                _ => Err(fidl::Error::UnknownOrdinal {
2373                    ordinal: header.ordinal,
2374                    protocol_name: <NotificationRegistrationMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2375                }),
2376            }))
2377            },
2378        )
2379    }
2380}
2381
2382/// Protocol for relaying event reports from the peer's message
2383/// repositories to the client.
2384/// This protocol exists to support the Notification Feature of MAP.
2385/// + request `notification` Notification received from the peer.
2386/// + request `received` The monotonic time when the notification was
2387///                      received from the peer.
2388#[derive(Debug)]
2389pub enum NotificationRegistrationRequest {
2390    /// Relays incoming event report from the peer as a Notification.
2391    NewEventReport {
2392        payload: NotificationRegistrationNewEventReportRequest,
2393        responder: NotificationRegistrationNewEventReportResponder,
2394    },
2395    /// An interaction was received which does not match any known method.
2396    #[non_exhaustive]
2397    _UnknownMethod {
2398        /// Ordinal of the method that was called.
2399        ordinal: u64,
2400        control_handle: NotificationRegistrationControlHandle,
2401        method_type: fidl::MethodType,
2402    },
2403}
2404
2405impl NotificationRegistrationRequest {
2406    #[allow(irrefutable_let_patterns)]
2407    pub fn into_new_event_report(
2408        self,
2409    ) -> Option<(
2410        NotificationRegistrationNewEventReportRequest,
2411        NotificationRegistrationNewEventReportResponder,
2412    )> {
2413        if let NotificationRegistrationRequest::NewEventReport { payload, responder } = self {
2414            Some((payload, responder))
2415        } else {
2416            None
2417        }
2418    }
2419
2420    /// Name of the method defined in FIDL
2421    pub fn method_name(&self) -> &'static str {
2422        match *self {
2423            NotificationRegistrationRequest::NewEventReport { .. } => "new_event_report",
2424            NotificationRegistrationRequest::_UnknownMethod {
2425                method_type: fidl::MethodType::OneWay,
2426                ..
2427            } => "unknown one-way method",
2428            NotificationRegistrationRequest::_UnknownMethod {
2429                method_type: fidl::MethodType::TwoWay,
2430                ..
2431            } => "unknown two-way method",
2432        }
2433    }
2434}
2435
2436#[derive(Debug, Clone)]
2437pub struct NotificationRegistrationControlHandle {
2438    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2439}
2440
2441impl fidl::endpoints::ControlHandle for NotificationRegistrationControlHandle {
2442    fn shutdown(&self) {
2443        self.inner.shutdown()
2444    }
2445
2446    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2447        self.inner.shutdown_with_epitaph(status)
2448    }
2449
2450    fn is_closed(&self) -> bool {
2451        self.inner.channel().is_closed()
2452    }
2453    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2454        self.inner.channel().on_closed()
2455    }
2456
2457    #[cfg(target_os = "fuchsia")]
2458    fn signal_peer(
2459        &self,
2460        clear_mask: zx::Signals,
2461        set_mask: zx::Signals,
2462    ) -> Result<(), zx_status::Status> {
2463        use fidl::Peered;
2464        self.inner.channel().signal_peer(clear_mask, set_mask)
2465    }
2466}
2467
2468impl NotificationRegistrationControlHandle {}
2469
2470#[must_use = "FIDL methods require a response to be sent"]
2471#[derive(Debug)]
2472pub struct NotificationRegistrationNewEventReportResponder {
2473    control_handle: std::mem::ManuallyDrop<NotificationRegistrationControlHandle>,
2474    tx_id: u32,
2475}
2476
2477/// Set the the channel to be shutdown (see [`NotificationRegistrationControlHandle::shutdown`])
2478/// if the responder is dropped without sending a response, so that the client
2479/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2480impl std::ops::Drop for NotificationRegistrationNewEventReportResponder {
2481    fn drop(&mut self) {
2482        self.control_handle.shutdown();
2483        // Safety: drops once, never accessed again
2484        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2485    }
2486}
2487
2488impl fidl::endpoints::Responder for NotificationRegistrationNewEventReportResponder {
2489    type ControlHandle = NotificationRegistrationControlHandle;
2490
2491    fn control_handle(&self) -> &NotificationRegistrationControlHandle {
2492        &self.control_handle
2493    }
2494
2495    fn drop_without_shutdown(mut self) {
2496        // Safety: drops once, never accessed again due to mem::forget
2497        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2498        // Prevent Drop from running (which would shut down the channel)
2499        std::mem::forget(self);
2500    }
2501}
2502
2503impl NotificationRegistrationNewEventReportResponder {
2504    /// Sends a response to the FIDL transaction.
2505    ///
2506    /// Sets the channel to shutdown if an error occurs.
2507    pub fn send(self) -> Result<(), fidl::Error> {
2508        let _result = self.send_raw();
2509        if _result.is_err() {
2510            self.control_handle.shutdown();
2511        }
2512        self.drop_without_shutdown();
2513        _result
2514    }
2515
2516    /// Similar to "send" but does not shutdown the channel if an error occurs.
2517    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
2518        let _result = self.send_raw();
2519        self.drop_without_shutdown();
2520        _result
2521    }
2522
2523    fn send_raw(&self) -> Result<(), fidl::Error> {
2524        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
2525            fidl::encoding::Flexible::new(()),
2526            self.tx_id,
2527            0x4c7d185363415f14,
2528            fidl::encoding::DynamicFlags::FLEXIBLE,
2529        )
2530    }
2531}
2532
2533mod internal {
2534    use super::*;
2535
2536    impl AccessorSetNotificationRegistrationRequest {
2537        #[inline(always)]
2538        fn max_ordinal_present(&self) -> u64 {
2539            if let Some(_) = self.server {
2540                return 2;
2541            }
2542            if let Some(_) = self.mas_instance_ids {
2543                return 1;
2544            }
2545            0
2546        }
2547    }
2548
2549    impl fidl::encoding::ResourceTypeMarker for AccessorSetNotificationRegistrationRequest {
2550        type Borrowed<'a> = &'a mut Self;
2551        fn take_or_borrow<'a>(
2552            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2553        ) -> Self::Borrowed<'a> {
2554            value
2555        }
2556    }
2557
2558    unsafe impl fidl::encoding::TypeMarker for AccessorSetNotificationRegistrationRequest {
2559        type Owned = Self;
2560
2561        #[inline(always)]
2562        fn inline_align(_context: fidl::encoding::Context) -> usize {
2563            8
2564        }
2565
2566        #[inline(always)]
2567        fn inline_size(_context: fidl::encoding::Context) -> usize {
2568            16
2569        }
2570    }
2571
2572    unsafe impl
2573        fidl::encoding::Encode<
2574            AccessorSetNotificationRegistrationRequest,
2575            fidl::encoding::DefaultFuchsiaResourceDialect,
2576        > for &mut AccessorSetNotificationRegistrationRequest
2577    {
2578        unsafe fn encode(
2579            self,
2580            encoder: &mut fidl::encoding::Encoder<
2581                '_,
2582                fidl::encoding::DefaultFuchsiaResourceDialect,
2583            >,
2584            offset: usize,
2585            mut depth: fidl::encoding::Depth,
2586        ) -> fidl::Result<()> {
2587            encoder.debug_check_bounds::<AccessorSetNotificationRegistrationRequest>(offset);
2588            // Vector header
2589            let max_ordinal: u64 = self.max_ordinal_present();
2590            encoder.write_num(max_ordinal, offset);
2591            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2592            // Calling encoder.out_of_line_offset(0) is not allowed.
2593            if max_ordinal == 0 {
2594                return Ok(());
2595            }
2596            depth.increment()?;
2597            let envelope_size = 8;
2598            let bytes_len = max_ordinal as usize * envelope_size;
2599            #[allow(unused_variables)]
2600            let offset = encoder.out_of_line_offset(bytes_len);
2601            let mut _prev_end_offset: usize = 0;
2602            if 1 > max_ordinal {
2603                return Ok(());
2604            }
2605
2606            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2607            // are envelope_size bytes.
2608            let cur_offset: usize = (1 - 1) * envelope_size;
2609
2610            // Zero reserved fields.
2611            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2612
2613            // Safety:
2614            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2615            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2616            //   envelope_size bytes, there is always sufficient room.
2617            fidl::encoding::encode_in_envelope_optional::<
2618                fidl::encoding::Vector<u8, 256>,
2619                fidl::encoding::DefaultFuchsiaResourceDialect,
2620            >(
2621                self.mas_instance_ids.as_ref().map(
2622                    <fidl::encoding::Vector<u8, 256> as fidl::encoding::ValueTypeMarker>::borrow,
2623                ),
2624                encoder,
2625                offset + cur_offset,
2626                depth,
2627            )?;
2628
2629            _prev_end_offset = cur_offset + envelope_size;
2630            if 2 > max_ordinal {
2631                return Ok(());
2632            }
2633
2634            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2635            // are envelope_size bytes.
2636            let cur_offset: usize = (2 - 1) * envelope_size;
2637
2638            // Zero reserved fields.
2639            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2640
2641            // Safety:
2642            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2643            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2644            //   envelope_size bytes, there is always sufficient room.
2645            fidl::encoding::encode_in_envelope_optional::<
2646                fidl::encoding::Endpoint<
2647                    fidl::endpoints::ClientEnd<NotificationRegistrationMarker>,
2648                >,
2649                fidl::encoding::DefaultFuchsiaResourceDialect,
2650            >(
2651                self.server.as_mut().map(
2652                    <fidl::encoding::Endpoint<
2653                        fidl::endpoints::ClientEnd<NotificationRegistrationMarker>,
2654                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
2655                ),
2656                encoder,
2657                offset + cur_offset,
2658                depth,
2659            )?;
2660
2661            _prev_end_offset = cur_offset + envelope_size;
2662
2663            Ok(())
2664        }
2665    }
2666
2667    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2668        for AccessorSetNotificationRegistrationRequest
2669    {
2670        #[inline(always)]
2671        fn new_empty() -> Self {
2672            Self::default()
2673        }
2674
2675        unsafe fn decode(
2676            &mut self,
2677            decoder: &mut fidl::encoding::Decoder<
2678                '_,
2679                fidl::encoding::DefaultFuchsiaResourceDialect,
2680            >,
2681            offset: usize,
2682            mut depth: fidl::encoding::Depth,
2683        ) -> fidl::Result<()> {
2684            decoder.debug_check_bounds::<Self>(offset);
2685            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2686                None => return Err(fidl::Error::NotNullable),
2687                Some(len) => len,
2688            };
2689            // Calling decoder.out_of_line_offset(0) is not allowed.
2690            if len == 0 {
2691                return Ok(());
2692            };
2693            depth.increment()?;
2694            let envelope_size = 8;
2695            let bytes_len = len * envelope_size;
2696            let offset = decoder.out_of_line_offset(bytes_len)?;
2697            // Decode the envelope for each type.
2698            let mut _next_ordinal_to_read = 0;
2699            let mut next_offset = offset;
2700            let end_offset = offset + bytes_len;
2701            _next_ordinal_to_read += 1;
2702            if next_offset >= end_offset {
2703                return Ok(());
2704            }
2705
2706            // Decode unknown envelopes for gaps in ordinals.
2707            while _next_ordinal_to_read < 1 {
2708                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2709                _next_ordinal_to_read += 1;
2710                next_offset += envelope_size;
2711            }
2712
2713            let next_out_of_line = decoder.next_out_of_line();
2714            let handles_before = decoder.remaining_handles();
2715            if let Some((inlined, num_bytes, num_handles)) =
2716                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2717            {
2718                let member_inline_size =
2719                    <fidl::encoding::Vector<u8, 256> as fidl::encoding::TypeMarker>::inline_size(
2720                        decoder.context,
2721                    );
2722                if inlined != (member_inline_size <= 4) {
2723                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2724                }
2725                let inner_offset;
2726                let mut inner_depth = depth.clone();
2727                if inlined {
2728                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2729                    inner_offset = next_offset;
2730                } else {
2731                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2732                    inner_depth.increment()?;
2733                }
2734                let val_ref =
2735                self.mas_instance_ids.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<u8, 256>, fidl::encoding::DefaultFuchsiaResourceDialect));
2736                fidl::decode!(fidl::encoding::Vector<u8, 256>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
2737                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2738                {
2739                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2740                }
2741                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2742                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2743                }
2744            }
2745
2746            next_offset += envelope_size;
2747            _next_ordinal_to_read += 1;
2748            if next_offset >= end_offset {
2749                return Ok(());
2750            }
2751
2752            // Decode unknown envelopes for gaps in ordinals.
2753            while _next_ordinal_to_read < 2 {
2754                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2755                _next_ordinal_to_read += 1;
2756                next_offset += envelope_size;
2757            }
2758
2759            let next_out_of_line = decoder.next_out_of_line();
2760            let handles_before = decoder.remaining_handles();
2761            if let Some((inlined, num_bytes, num_handles)) =
2762                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2763            {
2764                let member_inline_size = <fidl::encoding::Endpoint<
2765                    fidl::endpoints::ClientEnd<NotificationRegistrationMarker>,
2766                > as fidl::encoding::TypeMarker>::inline_size(
2767                    decoder.context
2768                );
2769                if inlined != (member_inline_size <= 4) {
2770                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2771                }
2772                let inner_offset;
2773                let mut inner_depth = depth.clone();
2774                if inlined {
2775                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2776                    inner_offset = next_offset;
2777                } else {
2778                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2779                    inner_depth.increment()?;
2780                }
2781                let val_ref = self.server.get_or_insert_with(|| {
2782                    fidl::new_empty!(
2783                        fidl::encoding::Endpoint<
2784                            fidl::endpoints::ClientEnd<NotificationRegistrationMarker>,
2785                        >,
2786                        fidl::encoding::DefaultFuchsiaResourceDialect
2787                    )
2788                });
2789                fidl::decode!(
2790                    fidl::encoding::Endpoint<
2791                        fidl::endpoints::ClientEnd<NotificationRegistrationMarker>,
2792                    >,
2793                    fidl::encoding::DefaultFuchsiaResourceDialect,
2794                    val_ref,
2795                    decoder,
2796                    inner_offset,
2797                    inner_depth
2798                )?;
2799                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2800                {
2801                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2802                }
2803                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2804                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2805                }
2806            }
2807
2808            next_offset += envelope_size;
2809
2810            // Decode the remaining unknown envelopes.
2811            while next_offset < end_offset {
2812                _next_ordinal_to_read += 1;
2813                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2814                next_offset += envelope_size;
2815            }
2816
2817            Ok(())
2818        }
2819    }
2820
2821    impl MessagingClientWatchAccessorResponse {
2822        #[inline(always)]
2823        fn max_ordinal_present(&self) -> u64 {
2824            if let Some(_) = self.accessor {
2825                return 2;
2826            }
2827            if let Some(_) = self.peer_id {
2828                return 1;
2829            }
2830            0
2831        }
2832    }
2833
2834    impl fidl::encoding::ResourceTypeMarker for MessagingClientWatchAccessorResponse {
2835        type Borrowed<'a> = &'a mut Self;
2836        fn take_or_borrow<'a>(
2837            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2838        ) -> Self::Borrowed<'a> {
2839            value
2840        }
2841    }
2842
2843    unsafe impl fidl::encoding::TypeMarker for MessagingClientWatchAccessorResponse {
2844        type Owned = Self;
2845
2846        #[inline(always)]
2847        fn inline_align(_context: fidl::encoding::Context) -> usize {
2848            8
2849        }
2850
2851        #[inline(always)]
2852        fn inline_size(_context: fidl::encoding::Context) -> usize {
2853            16
2854        }
2855    }
2856
2857    unsafe impl
2858        fidl::encoding::Encode<
2859            MessagingClientWatchAccessorResponse,
2860            fidl::encoding::DefaultFuchsiaResourceDialect,
2861        > for &mut MessagingClientWatchAccessorResponse
2862    {
2863        unsafe fn encode(
2864            self,
2865            encoder: &mut fidl::encoding::Encoder<
2866                '_,
2867                fidl::encoding::DefaultFuchsiaResourceDialect,
2868            >,
2869            offset: usize,
2870            mut depth: fidl::encoding::Depth,
2871        ) -> fidl::Result<()> {
2872            encoder.debug_check_bounds::<MessagingClientWatchAccessorResponse>(offset);
2873            // Vector header
2874            let max_ordinal: u64 = self.max_ordinal_present();
2875            encoder.write_num(max_ordinal, offset);
2876            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2877            // Calling encoder.out_of_line_offset(0) is not allowed.
2878            if max_ordinal == 0 {
2879                return Ok(());
2880            }
2881            depth.increment()?;
2882            let envelope_size = 8;
2883            let bytes_len = max_ordinal as usize * envelope_size;
2884            #[allow(unused_variables)]
2885            let offset = encoder.out_of_line_offset(bytes_len);
2886            let mut _prev_end_offset: usize = 0;
2887            if 1 > max_ordinal {
2888                return Ok(());
2889            }
2890
2891            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2892            // are envelope_size bytes.
2893            let cur_offset: usize = (1 - 1) * envelope_size;
2894
2895            // Zero reserved fields.
2896            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2897
2898            // Safety:
2899            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2900            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2901            //   envelope_size bytes, there is always sufficient room.
2902            fidl::encoding::encode_in_envelope_optional::<
2903                fidl_fuchsia_bluetooth::PeerId,
2904                fidl::encoding::DefaultFuchsiaResourceDialect,
2905            >(
2906                self.peer_id.as_ref().map(
2907                    <fidl_fuchsia_bluetooth::PeerId as fidl::encoding::ValueTypeMarker>::borrow,
2908                ),
2909                encoder,
2910                offset + cur_offset,
2911                depth,
2912            )?;
2913
2914            _prev_end_offset = cur_offset + envelope_size;
2915            if 2 > max_ordinal {
2916                return Ok(());
2917            }
2918
2919            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2920            // are envelope_size bytes.
2921            let cur_offset: usize = (2 - 1) * envelope_size;
2922
2923            // Zero reserved fields.
2924            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2925
2926            // Safety:
2927            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2928            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2929            //   envelope_size bytes, there is always sufficient room.
2930            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<AccessorMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
2931            self.accessor.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<AccessorMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
2932            encoder, offset + cur_offset, depth
2933        )?;
2934
2935            _prev_end_offset = cur_offset + envelope_size;
2936
2937            Ok(())
2938        }
2939    }
2940
2941    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2942        for MessagingClientWatchAccessorResponse
2943    {
2944        #[inline(always)]
2945        fn new_empty() -> Self {
2946            Self::default()
2947        }
2948
2949        unsafe fn decode(
2950            &mut self,
2951            decoder: &mut fidl::encoding::Decoder<
2952                '_,
2953                fidl::encoding::DefaultFuchsiaResourceDialect,
2954            >,
2955            offset: usize,
2956            mut depth: fidl::encoding::Depth,
2957        ) -> fidl::Result<()> {
2958            decoder.debug_check_bounds::<Self>(offset);
2959            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2960                None => return Err(fidl::Error::NotNullable),
2961                Some(len) => len,
2962            };
2963            // Calling decoder.out_of_line_offset(0) is not allowed.
2964            if len == 0 {
2965                return Ok(());
2966            };
2967            depth.increment()?;
2968            let envelope_size = 8;
2969            let bytes_len = len * envelope_size;
2970            let offset = decoder.out_of_line_offset(bytes_len)?;
2971            // Decode the envelope for each type.
2972            let mut _next_ordinal_to_read = 0;
2973            let mut next_offset = offset;
2974            let end_offset = offset + bytes_len;
2975            _next_ordinal_to_read += 1;
2976            if next_offset >= end_offset {
2977                return Ok(());
2978            }
2979
2980            // Decode unknown envelopes for gaps in ordinals.
2981            while _next_ordinal_to_read < 1 {
2982                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2983                _next_ordinal_to_read += 1;
2984                next_offset += envelope_size;
2985            }
2986
2987            let next_out_of_line = decoder.next_out_of_line();
2988            let handles_before = decoder.remaining_handles();
2989            if let Some((inlined, num_bytes, num_handles)) =
2990                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2991            {
2992                let member_inline_size =
2993                    <fidl_fuchsia_bluetooth::PeerId as fidl::encoding::TypeMarker>::inline_size(
2994                        decoder.context,
2995                    );
2996                if inlined != (member_inline_size <= 4) {
2997                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2998                }
2999                let inner_offset;
3000                let mut inner_depth = depth.clone();
3001                if inlined {
3002                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3003                    inner_offset = next_offset;
3004                } else {
3005                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3006                    inner_depth.increment()?;
3007                }
3008                let val_ref = self.peer_id.get_or_insert_with(|| {
3009                    fidl::new_empty!(
3010                        fidl_fuchsia_bluetooth::PeerId,
3011                        fidl::encoding::DefaultFuchsiaResourceDialect
3012                    )
3013                });
3014                fidl::decode!(
3015                    fidl_fuchsia_bluetooth::PeerId,
3016                    fidl::encoding::DefaultFuchsiaResourceDialect,
3017                    val_ref,
3018                    decoder,
3019                    inner_offset,
3020                    inner_depth
3021                )?;
3022                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3023                {
3024                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3025                }
3026                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3027                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3028                }
3029            }
3030
3031            next_offset += envelope_size;
3032            _next_ordinal_to_read += 1;
3033            if next_offset >= end_offset {
3034                return Ok(());
3035            }
3036
3037            // Decode unknown envelopes for gaps in ordinals.
3038            while _next_ordinal_to_read < 2 {
3039                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3040                _next_ordinal_to_read += 1;
3041                next_offset += envelope_size;
3042            }
3043
3044            let next_out_of_line = decoder.next_out_of_line();
3045            let handles_before = decoder.remaining_handles();
3046            if let Some((inlined, num_bytes, num_handles)) =
3047                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3048            {
3049                let member_inline_size = <fidl::encoding::Endpoint<
3050                    fidl::endpoints::ClientEnd<AccessorMarker>,
3051                > as fidl::encoding::TypeMarker>::inline_size(
3052                    decoder.context
3053                );
3054                if inlined != (member_inline_size <= 4) {
3055                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3056                }
3057                let inner_offset;
3058                let mut inner_depth = depth.clone();
3059                if inlined {
3060                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3061                    inner_offset = next_offset;
3062                } else {
3063                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3064                    inner_depth.increment()?;
3065                }
3066                let val_ref = self.accessor.get_or_insert_with(|| {
3067                    fidl::new_empty!(
3068                        fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<AccessorMarker>>,
3069                        fidl::encoding::DefaultFuchsiaResourceDialect
3070                    )
3071                });
3072                fidl::decode!(
3073                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<AccessorMarker>>,
3074                    fidl::encoding::DefaultFuchsiaResourceDialect,
3075                    val_ref,
3076                    decoder,
3077                    inner_offset,
3078                    inner_depth
3079                )?;
3080                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3081                {
3082                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3083                }
3084                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3085                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3086                }
3087            }
3088
3089            next_offset += envelope_size;
3090
3091            // Decode the remaining unknown envelopes.
3092            while next_offset < end_offset {
3093                _next_ordinal_to_read += 1;
3094                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3095                next_offset += envelope_size;
3096            }
3097
3098            Ok(())
3099        }
3100    }
3101}