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