fidl_fuchsia_bluetooth_gatt2/
fidl_fuchsia_bluetooth_gatt2.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_gatt2__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct ClientConnectToServiceRequest {
16    pub handle: ServiceHandle,
17    pub service: fidl::endpoints::ServerEnd<RemoteServiceMarker>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
21    for ClientConnectToServiceRequest
22{
23}
24
25#[derive(Debug, PartialEq)]
26pub struct LocalServiceOnIndicateValueRequest {
27    pub update: ValueChangedParameters,
28    pub confirmation: fidl::EventPair,
29}
30
31impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
32    for LocalServiceOnIndicateValueRequest
33{
34}
35
36#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
37pub struct RemoteServiceRegisterCharacteristicNotifierRequest {
38    pub handle: Handle,
39    pub notifier: fidl::endpoints::ClientEnd<CharacteristicNotifierMarker>,
40}
41
42impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
43    for RemoteServiceRegisterCharacteristicNotifierRequest
44{
45}
46
47#[derive(Debug, PartialEq)]
48pub struct ServerPublishServiceRequest {
49    pub info: ServiceInfo,
50    pub service: fidl::endpoints::ClientEnd<LocalServiceMarker>,
51}
52
53impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
54    for ServerPublishServiceRequest
55{
56}
57
58#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
59pub struct CharacteristicNotifierMarker;
60
61impl fidl::endpoints::ProtocolMarker for CharacteristicNotifierMarker {
62    type Proxy = CharacteristicNotifierProxy;
63    type RequestStream = CharacteristicNotifierRequestStream;
64    #[cfg(target_os = "fuchsia")]
65    type SynchronousProxy = CharacteristicNotifierSynchronousProxy;
66
67    const DEBUG_NAME: &'static str = "(anonymous) CharacteristicNotifier";
68}
69
70pub trait CharacteristicNotifierProxyInterface: Send + Sync {
71    type OnNotificationResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
72    fn r#on_notification(&self, value: &ReadValue) -> Self::OnNotificationResponseFut;
73}
74#[derive(Debug)]
75#[cfg(target_os = "fuchsia")]
76pub struct CharacteristicNotifierSynchronousProxy {
77    client: fidl::client::sync::Client,
78}
79
80#[cfg(target_os = "fuchsia")]
81impl fidl::endpoints::SynchronousProxy for CharacteristicNotifierSynchronousProxy {
82    type Proxy = CharacteristicNotifierProxy;
83    type Protocol = CharacteristicNotifierMarker;
84
85    fn from_channel(inner: fidl::Channel) -> Self {
86        Self::new(inner)
87    }
88
89    fn into_channel(self) -> fidl::Channel {
90        self.client.into_channel()
91    }
92
93    fn as_channel(&self) -> &fidl::Channel {
94        self.client.as_channel()
95    }
96}
97
98#[cfg(target_os = "fuchsia")]
99impl CharacteristicNotifierSynchronousProxy {
100    pub fn new(channel: fidl::Channel) -> Self {
101        let protocol_name =
102            <CharacteristicNotifierMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
103        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
104    }
105
106    pub fn into_channel(self) -> fidl::Channel {
107        self.client.into_channel()
108    }
109
110    /// Waits until an event arrives and returns it. It is safe for other
111    /// threads to make concurrent requests while waiting for an event.
112    pub fn wait_for_event(
113        &self,
114        deadline: zx::MonotonicInstant,
115    ) -> Result<CharacteristicNotifierEvent, fidl::Error> {
116        CharacteristicNotifierEvent::decode(self.client.wait_for_event(deadline)?)
117    }
118
119    /// Called when a characteristic value notification or indication is
120    /// received from the server.
121    ///
122    /// + request `value` the value of the updated characteristic.
123    /// - response An empty response should be sent immediately as an
124    ///   acknowledgement that the notification was received (for flow control).
125    pub fn r#on_notification(
126        &self,
127        mut value: &ReadValue,
128        ___deadline: zx::MonotonicInstant,
129    ) -> Result<(), fidl::Error> {
130        let _response = self.client.send_query::<
131            CharacteristicNotifierOnNotificationRequest,
132            fidl::encoding::EmptyPayload,
133        >(
134            (value,),
135            0x8edda1bd01f3c0a,
136            fidl::encoding::DynamicFlags::empty(),
137            ___deadline,
138        )?;
139        Ok(_response)
140    }
141}
142
143#[cfg(target_os = "fuchsia")]
144impl From<CharacteristicNotifierSynchronousProxy> for zx::NullableHandle {
145    fn from(value: CharacteristicNotifierSynchronousProxy) -> Self {
146        value.into_channel().into()
147    }
148}
149
150#[cfg(target_os = "fuchsia")]
151impl From<fidl::Channel> for CharacteristicNotifierSynchronousProxy {
152    fn from(value: fidl::Channel) -> Self {
153        Self::new(value)
154    }
155}
156
157#[cfg(target_os = "fuchsia")]
158impl fidl::endpoints::FromClient for CharacteristicNotifierSynchronousProxy {
159    type Protocol = CharacteristicNotifierMarker;
160
161    fn from_client(value: fidl::endpoints::ClientEnd<CharacteristicNotifierMarker>) -> Self {
162        Self::new(value.into_channel())
163    }
164}
165
166#[derive(Debug, Clone)]
167pub struct CharacteristicNotifierProxy {
168    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
169}
170
171impl fidl::endpoints::Proxy for CharacteristicNotifierProxy {
172    type Protocol = CharacteristicNotifierMarker;
173
174    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
175        Self::new(inner)
176    }
177
178    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
179        self.client.into_channel().map_err(|client| Self { client })
180    }
181
182    fn as_channel(&self) -> &::fidl::AsyncChannel {
183        self.client.as_channel()
184    }
185}
186
187impl CharacteristicNotifierProxy {
188    /// Create a new Proxy for fuchsia.bluetooth.gatt2/CharacteristicNotifier.
189    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
190        let protocol_name =
191            <CharacteristicNotifierMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
192        Self { client: fidl::client::Client::new(channel, protocol_name) }
193    }
194
195    /// Get a Stream of events from the remote end of the protocol.
196    ///
197    /// # Panics
198    ///
199    /// Panics if the event stream was already taken.
200    pub fn take_event_stream(&self) -> CharacteristicNotifierEventStream {
201        CharacteristicNotifierEventStream { event_receiver: self.client.take_event_receiver() }
202    }
203
204    /// Called when a characteristic value notification or indication is
205    /// received from the server.
206    ///
207    /// + request `value` the value of the updated characteristic.
208    /// - response An empty response should be sent immediately as an
209    ///   acknowledgement that the notification was received (for flow control).
210    pub fn r#on_notification(
211        &self,
212        mut value: &ReadValue,
213    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
214        CharacteristicNotifierProxyInterface::r#on_notification(self, value)
215    }
216}
217
218impl CharacteristicNotifierProxyInterface for CharacteristicNotifierProxy {
219    type OnNotificationResponseFut =
220        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
221    fn r#on_notification(&self, mut value: &ReadValue) -> Self::OnNotificationResponseFut {
222        fn _decode(
223            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
224        ) -> Result<(), fidl::Error> {
225            let _response = fidl::client::decode_transaction_body::<
226                fidl::encoding::EmptyPayload,
227                fidl::encoding::DefaultFuchsiaResourceDialect,
228                0x8edda1bd01f3c0a,
229            >(_buf?)?;
230            Ok(_response)
231        }
232        self.client.send_query_and_decode::<CharacteristicNotifierOnNotificationRequest, ()>(
233            (value,),
234            0x8edda1bd01f3c0a,
235            fidl::encoding::DynamicFlags::empty(),
236            _decode,
237        )
238    }
239}
240
241pub struct CharacteristicNotifierEventStream {
242    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
243}
244
245impl std::marker::Unpin for CharacteristicNotifierEventStream {}
246
247impl futures::stream::FusedStream for CharacteristicNotifierEventStream {
248    fn is_terminated(&self) -> bool {
249        self.event_receiver.is_terminated()
250    }
251}
252
253impl futures::Stream for CharacteristicNotifierEventStream {
254    type Item = Result<CharacteristicNotifierEvent, fidl::Error>;
255
256    fn poll_next(
257        mut self: std::pin::Pin<&mut Self>,
258        cx: &mut std::task::Context<'_>,
259    ) -> std::task::Poll<Option<Self::Item>> {
260        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
261            &mut self.event_receiver,
262            cx
263        )?) {
264            Some(buf) => std::task::Poll::Ready(Some(CharacteristicNotifierEvent::decode(buf))),
265            None => std::task::Poll::Ready(None),
266        }
267    }
268}
269
270#[derive(Debug)]
271pub enum CharacteristicNotifierEvent {}
272
273impl CharacteristicNotifierEvent {
274    /// Decodes a message buffer as a [`CharacteristicNotifierEvent`].
275    fn decode(
276        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
277    ) -> Result<CharacteristicNotifierEvent, fidl::Error> {
278        let (bytes, _handles) = buf.split_mut();
279        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
280        debug_assert_eq!(tx_header.tx_id, 0);
281        match tx_header.ordinal {
282            _ => Err(fidl::Error::UnknownOrdinal {
283                ordinal: tx_header.ordinal,
284                protocol_name:
285                    <CharacteristicNotifierMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
286            }),
287        }
288    }
289}
290
291/// A Stream of incoming requests for fuchsia.bluetooth.gatt2/CharacteristicNotifier.
292pub struct CharacteristicNotifierRequestStream {
293    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
294    is_terminated: bool,
295}
296
297impl std::marker::Unpin for CharacteristicNotifierRequestStream {}
298
299impl futures::stream::FusedStream for CharacteristicNotifierRequestStream {
300    fn is_terminated(&self) -> bool {
301        self.is_terminated
302    }
303}
304
305impl fidl::endpoints::RequestStream for CharacteristicNotifierRequestStream {
306    type Protocol = CharacteristicNotifierMarker;
307    type ControlHandle = CharacteristicNotifierControlHandle;
308
309    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
310        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
311    }
312
313    fn control_handle(&self) -> Self::ControlHandle {
314        CharacteristicNotifierControlHandle { inner: self.inner.clone() }
315    }
316
317    fn into_inner(
318        self,
319    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
320    {
321        (self.inner, self.is_terminated)
322    }
323
324    fn from_inner(
325        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
326        is_terminated: bool,
327    ) -> Self {
328        Self { inner, is_terminated }
329    }
330}
331
332impl futures::Stream for CharacteristicNotifierRequestStream {
333    type Item = Result<CharacteristicNotifierRequest, fidl::Error>;
334
335    fn poll_next(
336        mut self: std::pin::Pin<&mut Self>,
337        cx: &mut std::task::Context<'_>,
338    ) -> std::task::Poll<Option<Self::Item>> {
339        let this = &mut *self;
340        if this.inner.check_shutdown(cx) {
341            this.is_terminated = true;
342            return std::task::Poll::Ready(None);
343        }
344        if this.is_terminated {
345            panic!("polled CharacteristicNotifierRequestStream after completion");
346        }
347        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
348            |bytes, handles| {
349                match this.inner.channel().read_etc(cx, bytes, handles) {
350                    std::task::Poll::Ready(Ok(())) => {}
351                    std::task::Poll::Pending => return std::task::Poll::Pending,
352                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
353                        this.is_terminated = true;
354                        return std::task::Poll::Ready(None);
355                    }
356                    std::task::Poll::Ready(Err(e)) => {
357                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
358                            e.into(),
359                        ))));
360                    }
361                }
362
363                // A message has been received from the channel
364                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
365
366                std::task::Poll::Ready(Some(match header.ordinal {
367                0x8edda1bd01f3c0a => {
368                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
369                    let mut req = fidl::new_empty!(CharacteristicNotifierOnNotificationRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
370                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CharacteristicNotifierOnNotificationRequest>(&header, _body_bytes, handles, &mut req)?;
371                    let control_handle = CharacteristicNotifierControlHandle {
372                        inner: this.inner.clone(),
373                    };
374                    Ok(CharacteristicNotifierRequest::OnNotification {value: req.value,
375
376                        responder: CharacteristicNotifierOnNotificationResponder {
377                            control_handle: std::mem::ManuallyDrop::new(control_handle),
378                            tx_id: header.tx_id,
379                        },
380                    })
381                }
382                _ => Err(fidl::Error::UnknownOrdinal {
383                    ordinal: header.ordinal,
384                    protocol_name: <CharacteristicNotifierMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
385                }),
386            }))
387            },
388        )
389    }
390}
391
392/// Listens to characteristic notifications & indications.
393#[derive(Debug)]
394pub enum CharacteristicNotifierRequest {
395    /// Called when a characteristic value notification or indication is
396    /// received from the server.
397    ///
398    /// + request `value` the value of the updated characteristic.
399    /// - response An empty response should be sent immediately as an
400    ///   acknowledgement that the notification was received (for flow control).
401    OnNotification { value: ReadValue, responder: CharacteristicNotifierOnNotificationResponder },
402}
403
404impl CharacteristicNotifierRequest {
405    #[allow(irrefutable_let_patterns)]
406    pub fn into_on_notification(
407        self,
408    ) -> Option<(ReadValue, CharacteristicNotifierOnNotificationResponder)> {
409        if let CharacteristicNotifierRequest::OnNotification { value, responder } = self {
410            Some((value, responder))
411        } else {
412            None
413        }
414    }
415
416    /// Name of the method defined in FIDL
417    pub fn method_name(&self) -> &'static str {
418        match *self {
419            CharacteristicNotifierRequest::OnNotification { .. } => "on_notification",
420        }
421    }
422}
423
424#[derive(Debug, Clone)]
425pub struct CharacteristicNotifierControlHandle {
426    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
427}
428
429impl fidl::endpoints::ControlHandle for CharacteristicNotifierControlHandle {
430    fn shutdown(&self) {
431        self.inner.shutdown()
432    }
433
434    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
435        self.inner.shutdown_with_epitaph(status)
436    }
437
438    fn is_closed(&self) -> bool {
439        self.inner.channel().is_closed()
440    }
441    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
442        self.inner.channel().on_closed()
443    }
444
445    #[cfg(target_os = "fuchsia")]
446    fn signal_peer(
447        &self,
448        clear_mask: zx::Signals,
449        set_mask: zx::Signals,
450    ) -> Result<(), zx_status::Status> {
451        use fidl::Peered;
452        self.inner.channel().signal_peer(clear_mask, set_mask)
453    }
454}
455
456impl CharacteristicNotifierControlHandle {}
457
458#[must_use = "FIDL methods require a response to be sent"]
459#[derive(Debug)]
460pub struct CharacteristicNotifierOnNotificationResponder {
461    control_handle: std::mem::ManuallyDrop<CharacteristicNotifierControlHandle>,
462    tx_id: u32,
463}
464
465/// Set the the channel to be shutdown (see [`CharacteristicNotifierControlHandle::shutdown`])
466/// if the responder is dropped without sending a response, so that the client
467/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
468impl std::ops::Drop for CharacteristicNotifierOnNotificationResponder {
469    fn drop(&mut self) {
470        self.control_handle.shutdown();
471        // Safety: drops once, never accessed again
472        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
473    }
474}
475
476impl fidl::endpoints::Responder for CharacteristicNotifierOnNotificationResponder {
477    type ControlHandle = CharacteristicNotifierControlHandle;
478
479    fn control_handle(&self) -> &CharacteristicNotifierControlHandle {
480        &self.control_handle
481    }
482
483    fn drop_without_shutdown(mut self) {
484        // Safety: drops once, never accessed again due to mem::forget
485        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
486        // Prevent Drop from running (which would shut down the channel)
487        std::mem::forget(self);
488    }
489}
490
491impl CharacteristicNotifierOnNotificationResponder {
492    /// Sends a response to the FIDL transaction.
493    ///
494    /// Sets the channel to shutdown if an error occurs.
495    pub fn send(self) -> Result<(), fidl::Error> {
496        let _result = self.send_raw();
497        if _result.is_err() {
498            self.control_handle.shutdown();
499        }
500        self.drop_without_shutdown();
501        _result
502    }
503
504    /// Similar to "send" but does not shutdown the channel if an error occurs.
505    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
506        let _result = self.send_raw();
507        self.drop_without_shutdown();
508        _result
509    }
510
511    fn send_raw(&self) -> Result<(), fidl::Error> {
512        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
513            (),
514            self.tx_id,
515            0x8edda1bd01f3c0a,
516            fidl::encoding::DynamicFlags::empty(),
517        )
518    }
519}
520
521#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
522pub struct ClientMarker;
523
524impl fidl::endpoints::ProtocolMarker for ClientMarker {
525    type Proxy = ClientProxy;
526    type RequestStream = ClientRequestStream;
527    #[cfg(target_os = "fuchsia")]
528    type SynchronousProxy = ClientSynchronousProxy;
529
530    const DEBUG_NAME: &'static str = "(anonymous) Client";
531}
532
533pub trait ClientProxyInterface: Send + Sync {
534    type WatchServicesResponseFut: std::future::Future<Output = Result<(Vec<ServiceInfo>, Vec<Handle>), fidl::Error>>
535        + Send;
536    fn r#watch_services(
537        &self,
538        uuids: &[fidl_fuchsia_bluetooth::Uuid],
539    ) -> Self::WatchServicesResponseFut;
540    fn r#connect_to_service(
541        &self,
542        handle: &ServiceHandle,
543        service: fidl::endpoints::ServerEnd<RemoteServiceMarker>,
544    ) -> Result<(), fidl::Error>;
545}
546#[derive(Debug)]
547#[cfg(target_os = "fuchsia")]
548pub struct ClientSynchronousProxy {
549    client: fidl::client::sync::Client,
550}
551
552#[cfg(target_os = "fuchsia")]
553impl fidl::endpoints::SynchronousProxy for ClientSynchronousProxy {
554    type Proxy = ClientProxy;
555    type Protocol = ClientMarker;
556
557    fn from_channel(inner: fidl::Channel) -> Self {
558        Self::new(inner)
559    }
560
561    fn into_channel(self) -> fidl::Channel {
562        self.client.into_channel()
563    }
564
565    fn as_channel(&self) -> &fidl::Channel {
566        self.client.as_channel()
567    }
568}
569
570#[cfg(target_os = "fuchsia")]
571impl ClientSynchronousProxy {
572    pub fn new(channel: fidl::Channel) -> Self {
573        let protocol_name = <ClientMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
574        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
575    }
576
577    pub fn into_channel(self) -> fidl::Channel {
578        self.client.into_channel()
579    }
580
581    /// Waits until an event arrives and returns it. It is safe for other
582    /// threads to make concurrent requests while waiting for an event.
583    pub fn wait_for_event(
584        &self,
585        deadline: zx::MonotonicInstant,
586    ) -> Result<ClientEvent, fidl::Error> {
587        ClientEvent::decode(self.client.wait_for_event(deadline)?)
588    }
589
590    /// Enumerates services found on the peer that this Client represents.
591    ///
592    /// Results can be filtered by specifying a list of UUIDs in `uuids`. This
593    /// method follows the hanging get pattern. On the initial request, a
594    /// complete snapshot will be returned. Subsequent calls with the same set
595    /// of `uuids` receive a response only when one or more services have been
596    /// added, modified, or removed from the entries reported since the most
597    /// recent call. Calls with new values of `uuids` will reset the filter and
598    /// receive a complete snapshot.
599    ///
600    /// Handles may be reused across services, so a handle may be in both
601    /// `updated` and `removed`. For this reason, it is recommended to process
602    /// removed services before updated services.
603    ///
604    /// To further interact with services, clients must obtain a RemoteService
605    /// protocol by calling ConnectToService().
606    ///
607    /// + request `uuids` the UUID allowlist. If empty, all services will be
608    ///   returned.
609    /// - response `updated` the services that have been added or modified since
610    ///   WatchServices() was last called. The returned ServiceInfo tables will
611    ///   contain only basic information about each service and the
612    ///   `characteristics` and `includes` fields will be null. If a service has
613    ///   been added/modified and then removed since the last call, it will only
614    ///   be present in `removed`, not `updated`.
615    ///   If concluded due to a new call with a new `uuids` value, `updated`
616    ///   will be empty.
617    /// - response `removed` the handles of the services that have been removed
618    ///   since the last call to WatchServices().
619    pub fn r#watch_services(
620        &self,
621        mut uuids: &[fidl_fuchsia_bluetooth::Uuid],
622        ___deadline: zx::MonotonicInstant,
623    ) -> Result<(Vec<ServiceInfo>, Vec<Handle>), fidl::Error> {
624        let _response =
625            self.client.send_query::<ClientWatchServicesRequest, ClientWatchServicesResponse>(
626                (uuids,),
627                0x23243a22d6f08640,
628                fidl::encoding::DynamicFlags::empty(),
629                ___deadline,
630            )?;
631        Ok((_response.updated, _response.removed))
632    }
633
634    /// Connects the RemoteService with the given identifier. Only 1 connection
635    /// per service is allowed.
636    ///
637    /// `service` will be closed on error, with an epitaph that provides a
638    /// reason.
639    /// * error Returns a `ZX_ERR_INVALID_ARGS` if `handle` is invalid.
640    /// * error Returns a `ZX_ERR_NOT_FOUND` if the service is not found.
641    /// * error Returns a `ZX_ERR_CONNECTION_RESET` if the service is removed.
642    /// * error Returns a `ZX_ERR_NOT_CONNECTED` if the peer disconnects.
643    /// * error Returns a `ZX_ERR_ALREADY_EXISTS` if the service is already connected.
644    pub fn r#connect_to_service(
645        &self,
646        mut handle: &ServiceHandle,
647        mut service: fidl::endpoints::ServerEnd<RemoteServiceMarker>,
648    ) -> Result<(), fidl::Error> {
649        self.client.send::<ClientConnectToServiceRequest>(
650            (handle, service),
651            0x61b59f2b6d075ff8,
652            fidl::encoding::DynamicFlags::empty(),
653        )
654    }
655}
656
657#[cfg(target_os = "fuchsia")]
658impl From<ClientSynchronousProxy> for zx::NullableHandle {
659    fn from(value: ClientSynchronousProxy) -> Self {
660        value.into_channel().into()
661    }
662}
663
664#[cfg(target_os = "fuchsia")]
665impl From<fidl::Channel> for ClientSynchronousProxy {
666    fn from(value: fidl::Channel) -> Self {
667        Self::new(value)
668    }
669}
670
671#[cfg(target_os = "fuchsia")]
672impl fidl::endpoints::FromClient for ClientSynchronousProxy {
673    type Protocol = ClientMarker;
674
675    fn from_client(value: fidl::endpoints::ClientEnd<ClientMarker>) -> Self {
676        Self::new(value.into_channel())
677    }
678}
679
680#[derive(Debug, Clone)]
681pub struct ClientProxy {
682    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
683}
684
685impl fidl::endpoints::Proxy for ClientProxy {
686    type Protocol = ClientMarker;
687
688    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
689        Self::new(inner)
690    }
691
692    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
693        self.client.into_channel().map_err(|client| Self { client })
694    }
695
696    fn as_channel(&self) -> &::fidl::AsyncChannel {
697        self.client.as_channel()
698    }
699}
700
701impl ClientProxy {
702    /// Create a new Proxy for fuchsia.bluetooth.gatt2/Client.
703    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
704        let protocol_name = <ClientMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
705        Self { client: fidl::client::Client::new(channel, protocol_name) }
706    }
707
708    /// Get a Stream of events from the remote end of the protocol.
709    ///
710    /// # Panics
711    ///
712    /// Panics if the event stream was already taken.
713    pub fn take_event_stream(&self) -> ClientEventStream {
714        ClientEventStream { event_receiver: self.client.take_event_receiver() }
715    }
716
717    /// Enumerates services found on the peer that this Client represents.
718    ///
719    /// Results can be filtered by specifying a list of UUIDs in `uuids`. This
720    /// method follows the hanging get pattern. On the initial request, a
721    /// complete snapshot will be returned. Subsequent calls with the same set
722    /// of `uuids` receive a response only when one or more services have been
723    /// added, modified, or removed from the entries reported since the most
724    /// recent call. Calls with new values of `uuids` will reset the filter and
725    /// receive a complete snapshot.
726    ///
727    /// Handles may be reused across services, so a handle may be in both
728    /// `updated` and `removed`. For this reason, it is recommended to process
729    /// removed services before updated services.
730    ///
731    /// To further interact with services, clients must obtain a RemoteService
732    /// protocol by calling ConnectToService().
733    ///
734    /// + request `uuids` the UUID allowlist. If empty, all services will be
735    ///   returned.
736    /// - response `updated` the services that have been added or modified since
737    ///   WatchServices() was last called. The returned ServiceInfo tables will
738    ///   contain only basic information about each service and the
739    ///   `characteristics` and `includes` fields will be null. If a service has
740    ///   been added/modified and then removed since the last call, it will only
741    ///   be present in `removed`, not `updated`.
742    ///   If concluded due to a new call with a new `uuids` value, `updated`
743    ///   will be empty.
744    /// - response `removed` the handles of the services that have been removed
745    ///   since the last call to WatchServices().
746    pub fn r#watch_services(
747        &self,
748        mut uuids: &[fidl_fuchsia_bluetooth::Uuid],
749    ) -> fidl::client::QueryResponseFut<
750        (Vec<ServiceInfo>, Vec<Handle>),
751        fidl::encoding::DefaultFuchsiaResourceDialect,
752    > {
753        ClientProxyInterface::r#watch_services(self, uuids)
754    }
755
756    /// Connects the RemoteService with the given identifier. Only 1 connection
757    /// per service is allowed.
758    ///
759    /// `service` will be closed on error, with an epitaph that provides a
760    /// reason.
761    /// * error Returns a `ZX_ERR_INVALID_ARGS` if `handle` is invalid.
762    /// * error Returns a `ZX_ERR_NOT_FOUND` if the service is not found.
763    /// * error Returns a `ZX_ERR_CONNECTION_RESET` if the service is removed.
764    /// * error Returns a `ZX_ERR_NOT_CONNECTED` if the peer disconnects.
765    /// * error Returns a `ZX_ERR_ALREADY_EXISTS` if the service is already connected.
766    pub fn r#connect_to_service(
767        &self,
768        mut handle: &ServiceHandle,
769        mut service: fidl::endpoints::ServerEnd<RemoteServiceMarker>,
770    ) -> Result<(), fidl::Error> {
771        ClientProxyInterface::r#connect_to_service(self, handle, service)
772    }
773}
774
775impl ClientProxyInterface for ClientProxy {
776    type WatchServicesResponseFut = fidl::client::QueryResponseFut<
777        (Vec<ServiceInfo>, Vec<Handle>),
778        fidl::encoding::DefaultFuchsiaResourceDialect,
779    >;
780    fn r#watch_services(
781        &self,
782        mut uuids: &[fidl_fuchsia_bluetooth::Uuid],
783    ) -> Self::WatchServicesResponseFut {
784        fn _decode(
785            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
786        ) -> Result<(Vec<ServiceInfo>, Vec<Handle>), fidl::Error> {
787            let _response = fidl::client::decode_transaction_body::<
788                ClientWatchServicesResponse,
789                fidl::encoding::DefaultFuchsiaResourceDialect,
790                0x23243a22d6f08640,
791            >(_buf?)?;
792            Ok((_response.updated, _response.removed))
793        }
794        self.client
795            .send_query_and_decode::<ClientWatchServicesRequest, (Vec<ServiceInfo>, Vec<Handle>)>(
796                (uuids,),
797                0x23243a22d6f08640,
798                fidl::encoding::DynamicFlags::empty(),
799                _decode,
800            )
801    }
802
803    fn r#connect_to_service(
804        &self,
805        mut handle: &ServiceHandle,
806        mut service: fidl::endpoints::ServerEnd<RemoteServiceMarker>,
807    ) -> Result<(), fidl::Error> {
808        self.client.send::<ClientConnectToServiceRequest>(
809            (handle, service),
810            0x61b59f2b6d075ff8,
811            fidl::encoding::DynamicFlags::empty(),
812        )
813    }
814}
815
816pub struct ClientEventStream {
817    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
818}
819
820impl std::marker::Unpin for ClientEventStream {}
821
822impl futures::stream::FusedStream for ClientEventStream {
823    fn is_terminated(&self) -> bool {
824        self.event_receiver.is_terminated()
825    }
826}
827
828impl futures::Stream for ClientEventStream {
829    type Item = Result<ClientEvent, fidl::Error>;
830
831    fn poll_next(
832        mut self: std::pin::Pin<&mut Self>,
833        cx: &mut std::task::Context<'_>,
834    ) -> std::task::Poll<Option<Self::Item>> {
835        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
836            &mut self.event_receiver,
837            cx
838        )?) {
839            Some(buf) => std::task::Poll::Ready(Some(ClientEvent::decode(buf))),
840            None => std::task::Poll::Ready(None),
841        }
842    }
843}
844
845#[derive(Debug)]
846pub enum ClientEvent {}
847
848impl ClientEvent {
849    /// Decodes a message buffer as a [`ClientEvent`].
850    fn decode(
851        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
852    ) -> Result<ClientEvent, fidl::Error> {
853        let (bytes, _handles) = buf.split_mut();
854        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
855        debug_assert_eq!(tx_header.tx_id, 0);
856        match tx_header.ordinal {
857            _ => Err(fidl::Error::UnknownOrdinal {
858                ordinal: tx_header.ordinal,
859                protocol_name: <ClientMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
860            }),
861        }
862    }
863}
864
865/// A Stream of incoming requests for fuchsia.bluetooth.gatt2/Client.
866pub struct ClientRequestStream {
867    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
868    is_terminated: bool,
869}
870
871impl std::marker::Unpin for ClientRequestStream {}
872
873impl futures::stream::FusedStream for ClientRequestStream {
874    fn is_terminated(&self) -> bool {
875        self.is_terminated
876    }
877}
878
879impl fidl::endpoints::RequestStream for ClientRequestStream {
880    type Protocol = ClientMarker;
881    type ControlHandle = ClientControlHandle;
882
883    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
884        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
885    }
886
887    fn control_handle(&self) -> Self::ControlHandle {
888        ClientControlHandle { inner: self.inner.clone() }
889    }
890
891    fn into_inner(
892        self,
893    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
894    {
895        (self.inner, self.is_terminated)
896    }
897
898    fn from_inner(
899        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
900        is_terminated: bool,
901    ) -> Self {
902        Self { inner, is_terminated }
903    }
904}
905
906impl futures::Stream for ClientRequestStream {
907    type Item = Result<ClientRequest, fidl::Error>;
908
909    fn poll_next(
910        mut self: std::pin::Pin<&mut Self>,
911        cx: &mut std::task::Context<'_>,
912    ) -> std::task::Poll<Option<Self::Item>> {
913        let this = &mut *self;
914        if this.inner.check_shutdown(cx) {
915            this.is_terminated = true;
916            return std::task::Poll::Ready(None);
917        }
918        if this.is_terminated {
919            panic!("polled ClientRequestStream after completion");
920        }
921        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
922            |bytes, handles| {
923                match this.inner.channel().read_etc(cx, bytes, handles) {
924                    std::task::Poll::Ready(Ok(())) => {}
925                    std::task::Poll::Pending => return std::task::Poll::Pending,
926                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
927                        this.is_terminated = true;
928                        return std::task::Poll::Ready(None);
929                    }
930                    std::task::Poll::Ready(Err(e)) => {
931                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
932                            e.into(),
933                        ))));
934                    }
935                }
936
937                // A message has been received from the channel
938                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
939
940                std::task::Poll::Ready(Some(match header.ordinal {
941                    0x23243a22d6f08640 => {
942                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
943                        let mut req = fidl::new_empty!(
944                            ClientWatchServicesRequest,
945                            fidl::encoding::DefaultFuchsiaResourceDialect
946                        );
947                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ClientWatchServicesRequest>(&header, _body_bytes, handles, &mut req)?;
948                        let control_handle = ClientControlHandle { inner: this.inner.clone() };
949                        Ok(ClientRequest::WatchServices {
950                            uuids: req.uuids,
951
952                            responder: ClientWatchServicesResponder {
953                                control_handle: std::mem::ManuallyDrop::new(control_handle),
954                                tx_id: header.tx_id,
955                            },
956                        })
957                    }
958                    0x61b59f2b6d075ff8 => {
959                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
960                        let mut req = fidl::new_empty!(
961                            ClientConnectToServiceRequest,
962                            fidl::encoding::DefaultFuchsiaResourceDialect
963                        );
964                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ClientConnectToServiceRequest>(&header, _body_bytes, handles, &mut req)?;
965                        let control_handle = ClientControlHandle { inner: this.inner.clone() };
966                        Ok(ClientRequest::ConnectToService {
967                            handle: req.handle,
968                            service: req.service,
969
970                            control_handle,
971                        })
972                    }
973                    _ => Err(fidl::Error::UnknownOrdinal {
974                        ordinal: header.ordinal,
975                        protocol_name:
976                            <ClientMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
977                    }),
978                }))
979            },
980        )
981    }
982}
983
984#[derive(Debug)]
985pub enum ClientRequest {
986    /// Enumerates services found on the peer that this Client represents.
987    ///
988    /// Results can be filtered by specifying a list of UUIDs in `uuids`. This
989    /// method follows the hanging get pattern. On the initial request, a
990    /// complete snapshot will be returned. Subsequent calls with the same set
991    /// of `uuids` receive a response only when one or more services have been
992    /// added, modified, or removed from the entries reported since the most
993    /// recent call. Calls with new values of `uuids` will reset the filter and
994    /// receive a complete snapshot.
995    ///
996    /// Handles may be reused across services, so a handle may be in both
997    /// `updated` and `removed`. For this reason, it is recommended to process
998    /// removed services before updated services.
999    ///
1000    /// To further interact with services, clients must obtain a RemoteService
1001    /// protocol by calling ConnectToService().
1002    ///
1003    /// + request `uuids` the UUID allowlist. If empty, all services will be
1004    ///   returned.
1005    /// - response `updated` the services that have been added or modified since
1006    ///   WatchServices() was last called. The returned ServiceInfo tables will
1007    ///   contain only basic information about each service and the
1008    ///   `characteristics` and `includes` fields will be null. If a service has
1009    ///   been added/modified and then removed since the last call, it will only
1010    ///   be present in `removed`, not `updated`.
1011    ///   If concluded due to a new call with a new `uuids` value, `updated`
1012    ///   will be empty.
1013    /// - response `removed` the handles of the services that have been removed
1014    ///   since the last call to WatchServices().
1015    WatchServices {
1016        uuids: Vec<fidl_fuchsia_bluetooth::Uuid>,
1017        responder: ClientWatchServicesResponder,
1018    },
1019    /// Connects the RemoteService with the given identifier. Only 1 connection
1020    /// per service is allowed.
1021    ///
1022    /// `service` will be closed on error, with an epitaph that provides a
1023    /// reason.
1024    /// * error Returns a `ZX_ERR_INVALID_ARGS` if `handle` is invalid.
1025    /// * error Returns a `ZX_ERR_NOT_FOUND` if the service is not found.
1026    /// * error Returns a `ZX_ERR_CONNECTION_RESET` if the service is removed.
1027    /// * error Returns a `ZX_ERR_NOT_CONNECTED` if the peer disconnects.
1028    /// * error Returns a `ZX_ERR_ALREADY_EXISTS` if the service is already connected.
1029    ConnectToService {
1030        handle: ServiceHandle,
1031        service: fidl::endpoints::ServerEnd<RemoteServiceMarker>,
1032        control_handle: ClientControlHandle,
1033    },
1034}
1035
1036impl ClientRequest {
1037    #[allow(irrefutable_let_patterns)]
1038    pub fn into_watch_services(
1039        self,
1040    ) -> Option<(Vec<fidl_fuchsia_bluetooth::Uuid>, ClientWatchServicesResponder)> {
1041        if let ClientRequest::WatchServices { uuids, responder } = self {
1042            Some((uuids, responder))
1043        } else {
1044            None
1045        }
1046    }
1047
1048    #[allow(irrefutable_let_patterns)]
1049    pub fn into_connect_to_service(
1050        self,
1051    ) -> Option<(ServiceHandle, fidl::endpoints::ServerEnd<RemoteServiceMarker>, ClientControlHandle)>
1052    {
1053        if let ClientRequest::ConnectToService { handle, service, control_handle } = self {
1054            Some((handle, service, control_handle))
1055        } else {
1056            None
1057        }
1058    }
1059
1060    /// Name of the method defined in FIDL
1061    pub fn method_name(&self) -> &'static str {
1062        match *self {
1063            ClientRequest::WatchServices { .. } => "watch_services",
1064            ClientRequest::ConnectToService { .. } => "connect_to_service",
1065        }
1066    }
1067}
1068
1069#[derive(Debug, Clone)]
1070pub struct ClientControlHandle {
1071    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1072}
1073
1074impl fidl::endpoints::ControlHandle for ClientControlHandle {
1075    fn shutdown(&self) {
1076        self.inner.shutdown()
1077    }
1078
1079    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1080        self.inner.shutdown_with_epitaph(status)
1081    }
1082
1083    fn is_closed(&self) -> bool {
1084        self.inner.channel().is_closed()
1085    }
1086    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1087        self.inner.channel().on_closed()
1088    }
1089
1090    #[cfg(target_os = "fuchsia")]
1091    fn signal_peer(
1092        &self,
1093        clear_mask: zx::Signals,
1094        set_mask: zx::Signals,
1095    ) -> Result<(), zx_status::Status> {
1096        use fidl::Peered;
1097        self.inner.channel().signal_peer(clear_mask, set_mask)
1098    }
1099}
1100
1101impl ClientControlHandle {}
1102
1103#[must_use = "FIDL methods require a response to be sent"]
1104#[derive(Debug)]
1105pub struct ClientWatchServicesResponder {
1106    control_handle: std::mem::ManuallyDrop<ClientControlHandle>,
1107    tx_id: u32,
1108}
1109
1110/// Set the the channel to be shutdown (see [`ClientControlHandle::shutdown`])
1111/// if the responder is dropped without sending a response, so that the client
1112/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1113impl std::ops::Drop for ClientWatchServicesResponder {
1114    fn drop(&mut self) {
1115        self.control_handle.shutdown();
1116        // Safety: drops once, never accessed again
1117        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1118    }
1119}
1120
1121impl fidl::endpoints::Responder for ClientWatchServicesResponder {
1122    type ControlHandle = ClientControlHandle;
1123
1124    fn control_handle(&self) -> &ClientControlHandle {
1125        &self.control_handle
1126    }
1127
1128    fn drop_without_shutdown(mut self) {
1129        // Safety: drops once, never accessed again due to mem::forget
1130        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1131        // Prevent Drop from running (which would shut down the channel)
1132        std::mem::forget(self);
1133    }
1134}
1135
1136impl ClientWatchServicesResponder {
1137    /// Sends a response to the FIDL transaction.
1138    ///
1139    /// Sets the channel to shutdown if an error occurs.
1140    pub fn send(
1141        self,
1142        mut updated: &[ServiceInfo],
1143        mut removed: &[Handle],
1144    ) -> Result<(), fidl::Error> {
1145        let _result = self.send_raw(updated, removed);
1146        if _result.is_err() {
1147            self.control_handle.shutdown();
1148        }
1149        self.drop_without_shutdown();
1150        _result
1151    }
1152
1153    /// Similar to "send" but does not shutdown the channel if an error occurs.
1154    pub fn send_no_shutdown_on_err(
1155        self,
1156        mut updated: &[ServiceInfo],
1157        mut removed: &[Handle],
1158    ) -> Result<(), fidl::Error> {
1159        let _result = self.send_raw(updated, removed);
1160        self.drop_without_shutdown();
1161        _result
1162    }
1163
1164    fn send_raw(
1165        &self,
1166        mut updated: &[ServiceInfo],
1167        mut removed: &[Handle],
1168    ) -> Result<(), fidl::Error> {
1169        self.control_handle.inner.send::<ClientWatchServicesResponse>(
1170            (updated, removed),
1171            self.tx_id,
1172            0x23243a22d6f08640,
1173            fidl::encoding::DynamicFlags::empty(),
1174        )
1175    }
1176}
1177
1178#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1179pub struct LocalServiceMarker;
1180
1181impl fidl::endpoints::ProtocolMarker for LocalServiceMarker {
1182    type Proxy = LocalServiceProxy;
1183    type RequestStream = LocalServiceRequestStream;
1184    #[cfg(target_os = "fuchsia")]
1185    type SynchronousProxy = LocalServiceSynchronousProxy;
1186
1187    const DEBUG_NAME: &'static str = "(anonymous) LocalService";
1188}
1189pub type LocalServiceReadValueResult = Result<Vec<u8>, Error>;
1190pub type LocalServiceWriteValueResult = Result<(), Error>;
1191
1192pub trait LocalServiceProxyInterface: Send + Sync {
1193    type CharacteristicConfigurationResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
1194        + Send;
1195    fn r#characteristic_configuration(
1196        &self,
1197        peer_id: &fidl_fuchsia_bluetooth::PeerId,
1198        handle: &Handle,
1199        notify: bool,
1200        indicate: bool,
1201    ) -> Self::CharacteristicConfigurationResponseFut;
1202    type ReadValueResponseFut: std::future::Future<Output = Result<LocalServiceReadValueResult, fidl::Error>>
1203        + Send;
1204    fn r#read_value(
1205        &self,
1206        peer_id: &fidl_fuchsia_bluetooth::PeerId,
1207        handle: &Handle,
1208        offset: i32,
1209    ) -> Self::ReadValueResponseFut;
1210    type WriteValueResponseFut: std::future::Future<Output = Result<LocalServiceWriteValueResult, fidl::Error>>
1211        + Send;
1212    fn r#write_value(&self, payload: &LocalServiceWriteValueRequest)
1213    -> Self::WriteValueResponseFut;
1214    type PeerUpdateResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1215    fn r#peer_update(&self, payload: &LocalServicePeerUpdateRequest)
1216    -> Self::PeerUpdateResponseFut;
1217    fn r#value_changed_credit(&self, additional_credit: u8) -> Result<(), fidl::Error>;
1218}
1219#[derive(Debug)]
1220#[cfg(target_os = "fuchsia")]
1221pub struct LocalServiceSynchronousProxy {
1222    client: fidl::client::sync::Client,
1223}
1224
1225#[cfg(target_os = "fuchsia")]
1226impl fidl::endpoints::SynchronousProxy for LocalServiceSynchronousProxy {
1227    type Proxy = LocalServiceProxy;
1228    type Protocol = LocalServiceMarker;
1229
1230    fn from_channel(inner: fidl::Channel) -> Self {
1231        Self::new(inner)
1232    }
1233
1234    fn into_channel(self) -> fidl::Channel {
1235        self.client.into_channel()
1236    }
1237
1238    fn as_channel(&self) -> &fidl::Channel {
1239        self.client.as_channel()
1240    }
1241}
1242
1243#[cfg(target_os = "fuchsia")]
1244impl LocalServiceSynchronousProxy {
1245    pub fn new(channel: fidl::Channel) -> Self {
1246        let protocol_name = <LocalServiceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1247        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1248    }
1249
1250    pub fn into_channel(self) -> fidl::Channel {
1251        self.client.into_channel()
1252    }
1253
1254    /// Waits until an event arrives and returns it. It is safe for other
1255    /// threads to make concurrent requests while waiting for an event.
1256    pub fn wait_for_event(
1257        &self,
1258        deadline: zx::MonotonicInstant,
1259    ) -> Result<LocalServiceEvent, fidl::Error> {
1260        LocalServiceEvent::decode(self.client.wait_for_event(deadline)?)
1261    }
1262
1263    /// This notifies the current configuration of a particular characteristic/descriptor for a
1264    /// particular peer. It will be called when the peer GATT client changes the configuration.
1265    ///
1266    /// The Bluetooth stack maintains the state of each peer's configuration across reconnections.
1267    /// As such, this method will also be called when a peer connects for each characteristic with
1268    /// the initial, persisted state of the newly-connected peer's configuration. However, clients
1269    /// should not rely on this state being persisted indefinitely by the Bluetooth stack.
1270    ///
1271    /// + request `peer_id` The PeerId of the GATT client associated with this particular CCC.
1272    /// + request `handle` The handle of the characteristic associated with the `notify` and
1273    ///  `indicate` parameters.
1274    /// + request `notify` True if the client has enabled notifications, false otherwise.
1275    /// + request `indicate` True if the client has enabled indications, false otherwise.
1276    /// - response empty Returns nothing to acknowledge the characteristic configuration.
1277    pub fn r#characteristic_configuration(
1278        &self,
1279        mut peer_id: &fidl_fuchsia_bluetooth::PeerId,
1280        mut handle: &Handle,
1281        mut notify: bool,
1282        mut indicate: bool,
1283        ___deadline: zx::MonotonicInstant,
1284    ) -> Result<(), fidl::Error> {
1285        let _response = self.client.send_query::<
1286            LocalServiceCharacteristicConfigurationRequest,
1287            fidl::encoding::EmptyPayload,
1288        >(
1289            (peer_id, handle, notify, indicate,),
1290            0x431101fcd8d9ef15,
1291            fidl::encoding::DynamicFlags::empty(),
1292            ___deadline,
1293        )?;
1294        Ok(_response)
1295    }
1296
1297    /// Called when a peer requests to read the value of a characteristic or descriptor. It is
1298    /// guaranteed that the peer satisfies the permssions associated with this attribute.
1299    ///
1300    /// + request `peer_id` The PeerId of the GATT client making the read request.
1301    /// + request `handle` The handle of the requested descriptor/characteristic.
1302    /// + request `offset` The offset at which to start reading the requested value.
1303    /// - response `value` The value of the characteristic.
1304    /// * error See `gatt2.Error` documentation for possible errors.
1305    pub fn r#read_value(
1306        &self,
1307        mut peer_id: &fidl_fuchsia_bluetooth::PeerId,
1308        mut handle: &Handle,
1309        mut offset: i32,
1310        ___deadline: zx::MonotonicInstant,
1311    ) -> Result<LocalServiceReadValueResult, fidl::Error> {
1312        let _response = self.client.send_query::<
1313            LocalServiceReadValueRequest,
1314            fidl::encoding::ResultType<LocalServiceReadValueResponse, Error>,
1315        >(
1316            (peer_id, handle, offset,),
1317            0x49e11d396625d104,
1318            fidl::encoding::DynamicFlags::empty(),
1319            ___deadline,
1320        )?;
1321        Ok(_response.map(|x| x.value))
1322    }
1323
1324    /// Called when a peer issues a request to write the value of a characteristic or descriptor. It
1325    /// is guaranteed that the peer satisfies the permissions associated with this attribute.
1326    ///
1327    /// + request `peer_id` The PeerId of the GATT client making the write request. Always present.
1328    /// + request `handle` The handle of the requested descriptor/characteristic. Always present.
1329    /// + request `offset` The offset at which to start writing the value. If the offset is 0, any
1330    ///   existing value should be overwritten by the new value. Otherwise, the existing value from
1331    ///   offset:(offset + len(value)) should be changed to `value`. Always present.
1332    /// + request `value` The new value for the descriptor/characteristic. Always present, but may
1333    ///   be the empty string.
1334    /// - response  The implementation must send an empty response once the value has been updated
1335    ///   as confirmation.
1336    /// * error See `gatt2.Error` documentation for possible errors.
1337    pub fn r#write_value(
1338        &self,
1339        mut payload: &LocalServiceWriteValueRequest,
1340        ___deadline: zx::MonotonicInstant,
1341    ) -> Result<LocalServiceWriteValueResult, fidl::Error> {
1342        let _response = self.client.send_query::<
1343            LocalServiceWriteValueRequest,
1344            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
1345        >(
1346            payload,
1347            0x7d6ae631baf18260,
1348            fidl::encoding::DynamicFlags::empty(),
1349            ___deadline,
1350        )?;
1351        Ok(_response.map(|x| x))
1352    }
1353
1354    /// Called to provide GATT information specific to a peer. PeerUpdate will not be called unless
1355    /// the prior invocation received a response. As such, the implementation can simply ignore the
1356    /// first invocation if they are not interested in any PeerUpdate fields.
1357    ///
1358    /// A PeerUpdate will be made before propagating any other interaction from the peer to the
1359    /// LocalService (Write/ReadValue, CharacteristicConfiguration) on a best-effort basis, as long
1360    /// as all preceding PeerUpdates were acknowledged.
1361    ///
1362    /// Not currently sent. Comment on https://fxbug.dev/42178509 to request support
1363    ///
1364    /// + request `peer_id` The PeerId the update pertains to. Always present.
1365    /// + request `mtu` The maximum number of bytes that fit in a notification/indication to this
1366    ///   peer. Any bytes past this limit are silently truncated. Most clients need not concern
1367    ///   themselves with this unless they are using notifications/indications for high throughput.
1368    ///   Optional.
1369    /// - response An empty response to acknowledge that the update was received.
1370    pub fn r#peer_update(
1371        &self,
1372        mut payload: &LocalServicePeerUpdateRequest,
1373        ___deadline: zx::MonotonicInstant,
1374    ) -> Result<(), fidl::Error> {
1375        let _response =
1376            self.client.send_query::<LocalServicePeerUpdateRequest, fidl::encoding::EmptyPayload>(
1377                payload,
1378                0x7e362177a04108b8,
1379                fidl::encoding::DynamicFlags::empty(),
1380                ___deadline,
1381            )?;
1382        Ok(_response)
1383    }
1384
1385    /// Add credit for sending indications/notifications. Implementors are defined to start out with
1386    /// INITIAL_VALUE_CHANGED_CREDITS credits before this method is called. Implementors must keep
1387    /// track of the available credit they have. The implementor can send exactly one OnNotifyValue
1388    /// or OnIndicateValue event for each credit. Note that `ValueChangedCredit` will only be called
1389    /// if at least one indication/notification has been sent since the prior call.
1390    pub fn r#value_changed_credit(&self, mut additional_credit: u8) -> Result<(), fidl::Error> {
1391        self.client.send::<LocalServiceValueChangedCreditRequest>(
1392            (additional_credit,),
1393            0x7cf0931548318566,
1394            fidl::encoding::DynamicFlags::empty(),
1395        )
1396    }
1397}
1398
1399#[cfg(target_os = "fuchsia")]
1400impl From<LocalServiceSynchronousProxy> for zx::NullableHandle {
1401    fn from(value: LocalServiceSynchronousProxy) -> Self {
1402        value.into_channel().into()
1403    }
1404}
1405
1406#[cfg(target_os = "fuchsia")]
1407impl From<fidl::Channel> for LocalServiceSynchronousProxy {
1408    fn from(value: fidl::Channel) -> Self {
1409        Self::new(value)
1410    }
1411}
1412
1413#[cfg(target_os = "fuchsia")]
1414impl fidl::endpoints::FromClient for LocalServiceSynchronousProxy {
1415    type Protocol = LocalServiceMarker;
1416
1417    fn from_client(value: fidl::endpoints::ClientEnd<LocalServiceMarker>) -> Self {
1418        Self::new(value.into_channel())
1419    }
1420}
1421
1422#[derive(Debug, Clone)]
1423pub struct LocalServiceProxy {
1424    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1425}
1426
1427impl fidl::endpoints::Proxy for LocalServiceProxy {
1428    type Protocol = LocalServiceMarker;
1429
1430    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1431        Self::new(inner)
1432    }
1433
1434    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1435        self.client.into_channel().map_err(|client| Self { client })
1436    }
1437
1438    fn as_channel(&self) -> &::fidl::AsyncChannel {
1439        self.client.as_channel()
1440    }
1441}
1442
1443impl LocalServiceProxy {
1444    /// Create a new Proxy for fuchsia.bluetooth.gatt2/LocalService.
1445    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1446        let protocol_name = <LocalServiceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1447        Self { client: fidl::client::Client::new(channel, protocol_name) }
1448    }
1449
1450    /// Get a Stream of events from the remote end of the protocol.
1451    ///
1452    /// # Panics
1453    ///
1454    /// Panics if the event stream was already taken.
1455    pub fn take_event_stream(&self) -> LocalServiceEventStream {
1456        LocalServiceEventStream { event_receiver: self.client.take_event_receiver() }
1457    }
1458
1459    /// This notifies the current configuration of a particular characteristic/descriptor for a
1460    /// particular peer. It will be called when the peer GATT client changes the configuration.
1461    ///
1462    /// The Bluetooth stack maintains the state of each peer's configuration across reconnections.
1463    /// As such, this method will also be called when a peer connects for each characteristic with
1464    /// the initial, persisted state of the newly-connected peer's configuration. However, clients
1465    /// should not rely on this state being persisted indefinitely by the Bluetooth stack.
1466    ///
1467    /// + request `peer_id` The PeerId of the GATT client associated with this particular CCC.
1468    /// + request `handle` The handle of the characteristic associated with the `notify` and
1469    ///  `indicate` parameters.
1470    /// + request `notify` True if the client has enabled notifications, false otherwise.
1471    /// + request `indicate` True if the client has enabled indications, false otherwise.
1472    /// - response empty Returns nothing to acknowledge the characteristic configuration.
1473    pub fn r#characteristic_configuration(
1474        &self,
1475        mut peer_id: &fidl_fuchsia_bluetooth::PeerId,
1476        mut handle: &Handle,
1477        mut notify: bool,
1478        mut indicate: bool,
1479    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1480        LocalServiceProxyInterface::r#characteristic_configuration(
1481            self, peer_id, handle, notify, indicate,
1482        )
1483    }
1484
1485    /// Called when a peer requests to read the value of a characteristic or descriptor. It is
1486    /// guaranteed that the peer satisfies the permssions associated with this attribute.
1487    ///
1488    /// + request `peer_id` The PeerId of the GATT client making the read request.
1489    /// + request `handle` The handle of the requested descriptor/characteristic.
1490    /// + request `offset` The offset at which to start reading the requested value.
1491    /// - response `value` The value of the characteristic.
1492    /// * error See `gatt2.Error` documentation for possible errors.
1493    pub fn r#read_value(
1494        &self,
1495        mut peer_id: &fidl_fuchsia_bluetooth::PeerId,
1496        mut handle: &Handle,
1497        mut offset: i32,
1498    ) -> fidl::client::QueryResponseFut<
1499        LocalServiceReadValueResult,
1500        fidl::encoding::DefaultFuchsiaResourceDialect,
1501    > {
1502        LocalServiceProxyInterface::r#read_value(self, peer_id, handle, offset)
1503    }
1504
1505    /// Called when a peer issues a request to write the value of a characteristic or descriptor. It
1506    /// is guaranteed that the peer satisfies the permissions associated with this attribute.
1507    ///
1508    /// + request `peer_id` The PeerId of the GATT client making the write request. Always present.
1509    /// + request `handle` The handle of the requested descriptor/characteristic. Always present.
1510    /// + request `offset` The offset at which to start writing the value. If the offset is 0, any
1511    ///   existing value should be overwritten by the new value. Otherwise, the existing value from
1512    ///   offset:(offset + len(value)) should be changed to `value`. Always present.
1513    /// + request `value` The new value for the descriptor/characteristic. Always present, but may
1514    ///   be the empty string.
1515    /// - response  The implementation must send an empty response once the value has been updated
1516    ///   as confirmation.
1517    /// * error See `gatt2.Error` documentation for possible errors.
1518    pub fn r#write_value(
1519        &self,
1520        mut payload: &LocalServiceWriteValueRequest,
1521    ) -> fidl::client::QueryResponseFut<
1522        LocalServiceWriteValueResult,
1523        fidl::encoding::DefaultFuchsiaResourceDialect,
1524    > {
1525        LocalServiceProxyInterface::r#write_value(self, payload)
1526    }
1527
1528    /// Called to provide GATT information specific to a peer. PeerUpdate will not be called unless
1529    /// the prior invocation received a response. As such, the implementation can simply ignore the
1530    /// first invocation if they are not interested in any PeerUpdate fields.
1531    ///
1532    /// A PeerUpdate will be made before propagating any other interaction from the peer to the
1533    /// LocalService (Write/ReadValue, CharacteristicConfiguration) on a best-effort basis, as long
1534    /// as all preceding PeerUpdates were acknowledged.
1535    ///
1536    /// Not currently sent. Comment on https://fxbug.dev/42178509 to request support
1537    ///
1538    /// + request `peer_id` The PeerId the update pertains to. Always present.
1539    /// + request `mtu` The maximum number of bytes that fit in a notification/indication to this
1540    ///   peer. Any bytes past this limit are silently truncated. Most clients need not concern
1541    ///   themselves with this unless they are using notifications/indications for high throughput.
1542    ///   Optional.
1543    /// - response An empty response to acknowledge that the update was received.
1544    pub fn r#peer_update(
1545        &self,
1546        mut payload: &LocalServicePeerUpdateRequest,
1547    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1548        LocalServiceProxyInterface::r#peer_update(self, payload)
1549    }
1550
1551    /// Add credit for sending indications/notifications. Implementors are defined to start out with
1552    /// INITIAL_VALUE_CHANGED_CREDITS credits before this method is called. Implementors must keep
1553    /// track of the available credit they have. The implementor can send exactly one OnNotifyValue
1554    /// or OnIndicateValue event for each credit. Note that `ValueChangedCredit` will only be called
1555    /// if at least one indication/notification has been sent since the prior call.
1556    pub fn r#value_changed_credit(&self, mut additional_credit: u8) -> Result<(), fidl::Error> {
1557        LocalServiceProxyInterface::r#value_changed_credit(self, additional_credit)
1558    }
1559}
1560
1561impl LocalServiceProxyInterface for LocalServiceProxy {
1562    type CharacteristicConfigurationResponseFut =
1563        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
1564    fn r#characteristic_configuration(
1565        &self,
1566        mut peer_id: &fidl_fuchsia_bluetooth::PeerId,
1567        mut handle: &Handle,
1568        mut notify: bool,
1569        mut indicate: bool,
1570    ) -> Self::CharacteristicConfigurationResponseFut {
1571        fn _decode(
1572            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1573        ) -> Result<(), fidl::Error> {
1574            let _response = fidl::client::decode_transaction_body::<
1575                fidl::encoding::EmptyPayload,
1576                fidl::encoding::DefaultFuchsiaResourceDialect,
1577                0x431101fcd8d9ef15,
1578            >(_buf?)?;
1579            Ok(_response)
1580        }
1581        self.client.send_query_and_decode::<LocalServiceCharacteristicConfigurationRequest, ()>(
1582            (peer_id, handle, notify, indicate),
1583            0x431101fcd8d9ef15,
1584            fidl::encoding::DynamicFlags::empty(),
1585            _decode,
1586        )
1587    }
1588
1589    type ReadValueResponseFut = fidl::client::QueryResponseFut<
1590        LocalServiceReadValueResult,
1591        fidl::encoding::DefaultFuchsiaResourceDialect,
1592    >;
1593    fn r#read_value(
1594        &self,
1595        mut peer_id: &fidl_fuchsia_bluetooth::PeerId,
1596        mut handle: &Handle,
1597        mut offset: i32,
1598    ) -> Self::ReadValueResponseFut {
1599        fn _decode(
1600            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1601        ) -> Result<LocalServiceReadValueResult, fidl::Error> {
1602            let _response = fidl::client::decode_transaction_body::<
1603                fidl::encoding::ResultType<LocalServiceReadValueResponse, Error>,
1604                fidl::encoding::DefaultFuchsiaResourceDialect,
1605                0x49e11d396625d104,
1606            >(_buf?)?;
1607            Ok(_response.map(|x| x.value))
1608        }
1609        self.client
1610            .send_query_and_decode::<LocalServiceReadValueRequest, LocalServiceReadValueResult>(
1611                (peer_id, handle, offset),
1612                0x49e11d396625d104,
1613                fidl::encoding::DynamicFlags::empty(),
1614                _decode,
1615            )
1616    }
1617
1618    type WriteValueResponseFut = fidl::client::QueryResponseFut<
1619        LocalServiceWriteValueResult,
1620        fidl::encoding::DefaultFuchsiaResourceDialect,
1621    >;
1622    fn r#write_value(
1623        &self,
1624        mut payload: &LocalServiceWriteValueRequest,
1625    ) -> Self::WriteValueResponseFut {
1626        fn _decode(
1627            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1628        ) -> Result<LocalServiceWriteValueResult, fidl::Error> {
1629            let _response = fidl::client::decode_transaction_body::<
1630                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
1631                fidl::encoding::DefaultFuchsiaResourceDialect,
1632                0x7d6ae631baf18260,
1633            >(_buf?)?;
1634            Ok(_response.map(|x| x))
1635        }
1636        self.client
1637            .send_query_and_decode::<LocalServiceWriteValueRequest, LocalServiceWriteValueResult>(
1638                payload,
1639                0x7d6ae631baf18260,
1640                fidl::encoding::DynamicFlags::empty(),
1641                _decode,
1642            )
1643    }
1644
1645    type PeerUpdateResponseFut =
1646        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
1647    fn r#peer_update(
1648        &self,
1649        mut payload: &LocalServicePeerUpdateRequest,
1650    ) -> Self::PeerUpdateResponseFut {
1651        fn _decode(
1652            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1653        ) -> Result<(), fidl::Error> {
1654            let _response = fidl::client::decode_transaction_body::<
1655                fidl::encoding::EmptyPayload,
1656                fidl::encoding::DefaultFuchsiaResourceDialect,
1657                0x7e362177a04108b8,
1658            >(_buf?)?;
1659            Ok(_response)
1660        }
1661        self.client.send_query_and_decode::<LocalServicePeerUpdateRequest, ()>(
1662            payload,
1663            0x7e362177a04108b8,
1664            fidl::encoding::DynamicFlags::empty(),
1665            _decode,
1666        )
1667    }
1668
1669    fn r#value_changed_credit(&self, mut additional_credit: u8) -> Result<(), fidl::Error> {
1670        self.client.send::<LocalServiceValueChangedCreditRequest>(
1671            (additional_credit,),
1672            0x7cf0931548318566,
1673            fidl::encoding::DynamicFlags::empty(),
1674        )
1675    }
1676}
1677
1678pub struct LocalServiceEventStream {
1679    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1680}
1681
1682impl std::marker::Unpin for LocalServiceEventStream {}
1683
1684impl futures::stream::FusedStream for LocalServiceEventStream {
1685    fn is_terminated(&self) -> bool {
1686        self.event_receiver.is_terminated()
1687    }
1688}
1689
1690impl futures::Stream for LocalServiceEventStream {
1691    type Item = Result<LocalServiceEvent, fidl::Error>;
1692
1693    fn poll_next(
1694        mut self: std::pin::Pin<&mut Self>,
1695        cx: &mut std::task::Context<'_>,
1696    ) -> std::task::Poll<Option<Self::Item>> {
1697        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1698            &mut self.event_receiver,
1699            cx
1700        )?) {
1701            Some(buf) => std::task::Poll::Ready(Some(LocalServiceEvent::decode(buf))),
1702            None => std::task::Poll::Ready(None),
1703        }
1704    }
1705}
1706
1707#[derive(Debug)]
1708pub enum LocalServiceEvent {
1709    OnSuppressDiscovery {},
1710    OnNotifyValue { payload: ValueChangedParameters },
1711    OnIndicateValue { update: ValueChangedParameters, confirmation: fidl::EventPair },
1712}
1713
1714impl LocalServiceEvent {
1715    #[allow(irrefutable_let_patterns)]
1716    pub fn into_on_suppress_discovery(self) -> Option<()> {
1717        if let LocalServiceEvent::OnSuppressDiscovery {} = self { Some(()) } else { None }
1718    }
1719    #[allow(irrefutable_let_patterns)]
1720    pub fn into_on_notify_value(self) -> Option<ValueChangedParameters> {
1721        if let LocalServiceEvent::OnNotifyValue { payload } = self { Some((payload)) } else { None }
1722    }
1723    #[allow(irrefutable_let_patterns)]
1724    pub fn into_on_indicate_value(self) -> Option<(ValueChangedParameters, fidl::EventPair)> {
1725        if let LocalServiceEvent::OnIndicateValue { update, confirmation } = self {
1726            Some((update, confirmation))
1727        } else {
1728            None
1729        }
1730    }
1731
1732    /// Decodes a message buffer as a [`LocalServiceEvent`].
1733    fn decode(
1734        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1735    ) -> Result<LocalServiceEvent, fidl::Error> {
1736        let (bytes, _handles) = buf.split_mut();
1737        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1738        debug_assert_eq!(tx_header.tx_id, 0);
1739        match tx_header.ordinal {
1740            0x106d36281c3cfb66 => {
1741                let mut out = fidl::new_empty!(
1742                    fidl::encoding::EmptyPayload,
1743                    fidl::encoding::DefaultFuchsiaResourceDialect
1744                );
1745                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
1746                Ok((LocalServiceEvent::OnSuppressDiscovery {}))
1747            }
1748            0x190c1c528bfd0068 => {
1749                let mut out = fidl::new_empty!(
1750                    ValueChangedParameters,
1751                    fidl::encoding::DefaultFuchsiaResourceDialect
1752                );
1753                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ValueChangedParameters>(&tx_header, _body_bytes, _handles, &mut out)?;
1754                Ok((LocalServiceEvent::OnNotifyValue { payload: out }))
1755            }
1756            0x59431c3653ac531f => {
1757                let mut out = fidl::new_empty!(
1758                    LocalServiceOnIndicateValueRequest,
1759                    fidl::encoding::DefaultFuchsiaResourceDialect
1760                );
1761                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LocalServiceOnIndicateValueRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
1762                Ok((LocalServiceEvent::OnIndicateValue {
1763                    update: out.update,
1764                    confirmation: out.confirmation,
1765                }))
1766            }
1767            _ => Err(fidl::Error::UnknownOrdinal {
1768                ordinal: tx_header.ordinal,
1769                protocol_name: <LocalServiceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1770            }),
1771        }
1772    }
1773}
1774
1775/// A Stream of incoming requests for fuchsia.bluetooth.gatt2/LocalService.
1776pub struct LocalServiceRequestStream {
1777    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1778    is_terminated: bool,
1779}
1780
1781impl std::marker::Unpin for LocalServiceRequestStream {}
1782
1783impl futures::stream::FusedStream for LocalServiceRequestStream {
1784    fn is_terminated(&self) -> bool {
1785        self.is_terminated
1786    }
1787}
1788
1789impl fidl::endpoints::RequestStream for LocalServiceRequestStream {
1790    type Protocol = LocalServiceMarker;
1791    type ControlHandle = LocalServiceControlHandle;
1792
1793    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1794        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1795    }
1796
1797    fn control_handle(&self) -> Self::ControlHandle {
1798        LocalServiceControlHandle { inner: self.inner.clone() }
1799    }
1800
1801    fn into_inner(
1802        self,
1803    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1804    {
1805        (self.inner, self.is_terminated)
1806    }
1807
1808    fn from_inner(
1809        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1810        is_terminated: bool,
1811    ) -> Self {
1812        Self { inner, is_terminated }
1813    }
1814}
1815
1816impl futures::Stream for LocalServiceRequestStream {
1817    type Item = Result<LocalServiceRequest, fidl::Error>;
1818
1819    fn poll_next(
1820        mut self: std::pin::Pin<&mut Self>,
1821        cx: &mut std::task::Context<'_>,
1822    ) -> std::task::Poll<Option<Self::Item>> {
1823        let this = &mut *self;
1824        if this.inner.check_shutdown(cx) {
1825            this.is_terminated = true;
1826            return std::task::Poll::Ready(None);
1827        }
1828        if this.is_terminated {
1829            panic!("polled LocalServiceRequestStream after completion");
1830        }
1831        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1832            |bytes, handles| {
1833                match this.inner.channel().read_etc(cx, bytes, handles) {
1834                    std::task::Poll::Ready(Ok(())) => {}
1835                    std::task::Poll::Pending => return std::task::Poll::Pending,
1836                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1837                        this.is_terminated = true;
1838                        return std::task::Poll::Ready(None);
1839                    }
1840                    std::task::Poll::Ready(Err(e)) => {
1841                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1842                            e.into(),
1843                        ))));
1844                    }
1845                }
1846
1847                // A message has been received from the channel
1848                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1849
1850                std::task::Poll::Ready(Some(match header.ordinal {
1851                    0x431101fcd8d9ef15 => {
1852                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1853                        let mut req = fidl::new_empty!(
1854                            LocalServiceCharacteristicConfigurationRequest,
1855                            fidl::encoding::DefaultFuchsiaResourceDialect
1856                        );
1857                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LocalServiceCharacteristicConfigurationRequest>(&header, _body_bytes, handles, &mut req)?;
1858                        let control_handle =
1859                            LocalServiceControlHandle { inner: this.inner.clone() };
1860                        Ok(LocalServiceRequest::CharacteristicConfiguration {
1861                            peer_id: req.peer_id,
1862                            handle: req.handle,
1863                            notify: req.notify,
1864                            indicate: req.indicate,
1865
1866                            responder: LocalServiceCharacteristicConfigurationResponder {
1867                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1868                                tx_id: header.tx_id,
1869                            },
1870                        })
1871                    }
1872                    0x49e11d396625d104 => {
1873                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1874                        let mut req = fidl::new_empty!(
1875                            LocalServiceReadValueRequest,
1876                            fidl::encoding::DefaultFuchsiaResourceDialect
1877                        );
1878                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LocalServiceReadValueRequest>(&header, _body_bytes, handles, &mut req)?;
1879                        let control_handle =
1880                            LocalServiceControlHandle { inner: this.inner.clone() };
1881                        Ok(LocalServiceRequest::ReadValue {
1882                            peer_id: req.peer_id,
1883                            handle: req.handle,
1884                            offset: req.offset,
1885
1886                            responder: LocalServiceReadValueResponder {
1887                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1888                                tx_id: header.tx_id,
1889                            },
1890                        })
1891                    }
1892                    0x7d6ae631baf18260 => {
1893                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1894                        let mut req = fidl::new_empty!(
1895                            LocalServiceWriteValueRequest,
1896                            fidl::encoding::DefaultFuchsiaResourceDialect
1897                        );
1898                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LocalServiceWriteValueRequest>(&header, _body_bytes, handles, &mut req)?;
1899                        let control_handle =
1900                            LocalServiceControlHandle { inner: this.inner.clone() };
1901                        Ok(LocalServiceRequest::WriteValue {
1902                            payload: req,
1903                            responder: LocalServiceWriteValueResponder {
1904                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1905                                tx_id: header.tx_id,
1906                            },
1907                        })
1908                    }
1909                    0x7e362177a04108b8 => {
1910                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1911                        let mut req = fidl::new_empty!(
1912                            LocalServicePeerUpdateRequest,
1913                            fidl::encoding::DefaultFuchsiaResourceDialect
1914                        );
1915                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LocalServicePeerUpdateRequest>(&header, _body_bytes, handles, &mut req)?;
1916                        let control_handle =
1917                            LocalServiceControlHandle { inner: this.inner.clone() };
1918                        Ok(LocalServiceRequest::PeerUpdate {
1919                            payload: req,
1920                            responder: LocalServicePeerUpdateResponder {
1921                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1922                                tx_id: header.tx_id,
1923                            },
1924                        })
1925                    }
1926                    0x7cf0931548318566 => {
1927                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1928                        let mut req = fidl::new_empty!(
1929                            LocalServiceValueChangedCreditRequest,
1930                            fidl::encoding::DefaultFuchsiaResourceDialect
1931                        );
1932                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LocalServiceValueChangedCreditRequest>(&header, _body_bytes, handles, &mut req)?;
1933                        let control_handle =
1934                            LocalServiceControlHandle { inner: this.inner.clone() };
1935                        Ok(LocalServiceRequest::ValueChangedCredit {
1936                            additional_credit: req.additional_credit,
1937
1938                            control_handle,
1939                        })
1940                    }
1941                    _ => Err(fidl::Error::UnknownOrdinal {
1942                        ordinal: header.ordinal,
1943                        protocol_name:
1944                            <LocalServiceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1945                    }),
1946                }))
1947            },
1948        )
1949    }
1950}
1951
1952/// Interface for serving a local GATT service. Closing the server_end of this protocol causes the
1953/// GATT service to be removed from the local GATT database. Similarly, closure of the client_end
1954/// of this protocol means the Bluetooth stack has removed this service from its GATT database.
1955#[derive(Debug)]
1956pub enum LocalServiceRequest {
1957    /// This notifies the current configuration of a particular characteristic/descriptor for a
1958    /// particular peer. It will be called when the peer GATT client changes the configuration.
1959    ///
1960    /// The Bluetooth stack maintains the state of each peer's configuration across reconnections.
1961    /// As such, this method will also be called when a peer connects for each characteristic with
1962    /// the initial, persisted state of the newly-connected peer's configuration. However, clients
1963    /// should not rely on this state being persisted indefinitely by the Bluetooth stack.
1964    ///
1965    /// + request `peer_id` The PeerId of the GATT client associated with this particular CCC.
1966    /// + request `handle` The handle of the characteristic associated with the `notify` and
1967    ///  `indicate` parameters.
1968    /// + request `notify` True if the client has enabled notifications, false otherwise.
1969    /// + request `indicate` True if the client has enabled indications, false otherwise.
1970    /// - response empty Returns nothing to acknowledge the characteristic configuration.
1971    CharacteristicConfiguration {
1972        peer_id: fidl_fuchsia_bluetooth::PeerId,
1973        handle: Handle,
1974        notify: bool,
1975        indicate: bool,
1976        responder: LocalServiceCharacteristicConfigurationResponder,
1977    },
1978    /// Called when a peer requests to read the value of a characteristic or descriptor. It is
1979    /// guaranteed that the peer satisfies the permssions associated with this attribute.
1980    ///
1981    /// + request `peer_id` The PeerId of the GATT client making the read request.
1982    /// + request `handle` The handle of the requested descriptor/characteristic.
1983    /// + request `offset` The offset at which to start reading the requested value.
1984    /// - response `value` The value of the characteristic.
1985    /// * error See `gatt2.Error` documentation for possible errors.
1986    ReadValue {
1987        peer_id: fidl_fuchsia_bluetooth::PeerId,
1988        handle: Handle,
1989        offset: i32,
1990        responder: LocalServiceReadValueResponder,
1991    },
1992    /// Called when a peer issues a request to write the value of a characteristic or descriptor. It
1993    /// is guaranteed that the peer satisfies the permissions associated with this attribute.
1994    ///
1995    /// + request `peer_id` The PeerId of the GATT client making the write request. Always present.
1996    /// + request `handle` The handle of the requested descriptor/characteristic. Always present.
1997    /// + request `offset` The offset at which to start writing the value. If the offset is 0, any
1998    ///   existing value should be overwritten by the new value. Otherwise, the existing value from
1999    ///   offset:(offset + len(value)) should be changed to `value`. Always present.
2000    /// + request `value` The new value for the descriptor/characteristic. Always present, but may
2001    ///   be the empty string.
2002    /// - response  The implementation must send an empty response once the value has been updated
2003    ///   as confirmation.
2004    /// * error See `gatt2.Error` documentation for possible errors.
2005    WriteValue {
2006        payload: LocalServiceWriteValueRequest,
2007        responder: LocalServiceWriteValueResponder,
2008    },
2009    /// Called to provide GATT information specific to a peer. PeerUpdate will not be called unless
2010    /// the prior invocation received a response. As such, the implementation can simply ignore the
2011    /// first invocation if they are not interested in any PeerUpdate fields.
2012    ///
2013    /// A PeerUpdate will be made before propagating any other interaction from the peer to the
2014    /// LocalService (Write/ReadValue, CharacteristicConfiguration) on a best-effort basis, as long
2015    /// as all preceding PeerUpdates were acknowledged.
2016    ///
2017    /// Not currently sent. Comment on https://fxbug.dev/42178509 to request support
2018    ///
2019    /// + request `peer_id` The PeerId the update pertains to. Always present.
2020    /// + request `mtu` The maximum number of bytes that fit in a notification/indication to this
2021    ///   peer. Any bytes past this limit are silently truncated. Most clients need not concern
2022    ///   themselves with this unless they are using notifications/indications for high throughput.
2023    ///   Optional.
2024    /// - response An empty response to acknowledge that the update was received.
2025    PeerUpdate {
2026        payload: LocalServicePeerUpdateRequest,
2027        responder: LocalServicePeerUpdateResponder,
2028    },
2029    /// Add credit for sending indications/notifications. Implementors are defined to start out with
2030    /// INITIAL_VALUE_CHANGED_CREDITS credits before this method is called. Implementors must keep
2031    /// track of the available credit they have. The implementor can send exactly one OnNotifyValue
2032    /// or OnIndicateValue event for each credit. Note that `ValueChangedCredit` will only be called
2033    /// if at least one indication/notification has been sent since the prior call.
2034    ValueChangedCredit { additional_credit: u8, control_handle: LocalServiceControlHandle },
2035}
2036
2037impl LocalServiceRequest {
2038    #[allow(irrefutable_let_patterns)]
2039    pub fn into_characteristic_configuration(
2040        self,
2041    ) -> Option<(
2042        fidl_fuchsia_bluetooth::PeerId,
2043        Handle,
2044        bool,
2045        bool,
2046        LocalServiceCharacteristicConfigurationResponder,
2047    )> {
2048        if let LocalServiceRequest::CharacteristicConfiguration {
2049            peer_id,
2050            handle,
2051            notify,
2052            indicate,
2053            responder,
2054        } = self
2055        {
2056            Some((peer_id, handle, notify, indicate, responder))
2057        } else {
2058            None
2059        }
2060    }
2061
2062    #[allow(irrefutable_let_patterns)]
2063    pub fn into_read_value(
2064        self,
2065    ) -> Option<(fidl_fuchsia_bluetooth::PeerId, Handle, i32, LocalServiceReadValueResponder)> {
2066        if let LocalServiceRequest::ReadValue { peer_id, handle, offset, responder } = self {
2067            Some((peer_id, handle, offset, responder))
2068        } else {
2069            None
2070        }
2071    }
2072
2073    #[allow(irrefutable_let_patterns)]
2074    pub fn into_write_value(
2075        self,
2076    ) -> Option<(LocalServiceWriteValueRequest, LocalServiceWriteValueResponder)> {
2077        if let LocalServiceRequest::WriteValue { payload, responder } = self {
2078            Some((payload, responder))
2079        } else {
2080            None
2081        }
2082    }
2083
2084    #[allow(irrefutable_let_patterns)]
2085    pub fn into_peer_update(
2086        self,
2087    ) -> Option<(LocalServicePeerUpdateRequest, LocalServicePeerUpdateResponder)> {
2088        if let LocalServiceRequest::PeerUpdate { payload, responder } = self {
2089            Some((payload, responder))
2090        } else {
2091            None
2092        }
2093    }
2094
2095    #[allow(irrefutable_let_patterns)]
2096    pub fn into_value_changed_credit(self) -> Option<(u8, LocalServiceControlHandle)> {
2097        if let LocalServiceRequest::ValueChangedCredit { additional_credit, control_handle } = self
2098        {
2099            Some((additional_credit, control_handle))
2100        } else {
2101            None
2102        }
2103    }
2104
2105    /// Name of the method defined in FIDL
2106    pub fn method_name(&self) -> &'static str {
2107        match *self {
2108            LocalServiceRequest::CharacteristicConfiguration { .. } => {
2109                "characteristic_configuration"
2110            }
2111            LocalServiceRequest::ReadValue { .. } => "read_value",
2112            LocalServiceRequest::WriteValue { .. } => "write_value",
2113            LocalServiceRequest::PeerUpdate { .. } => "peer_update",
2114            LocalServiceRequest::ValueChangedCredit { .. } => "value_changed_credit",
2115        }
2116    }
2117}
2118
2119#[derive(Debug, Clone)]
2120pub struct LocalServiceControlHandle {
2121    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2122}
2123
2124impl fidl::endpoints::ControlHandle for LocalServiceControlHandle {
2125    fn shutdown(&self) {
2126        self.inner.shutdown()
2127    }
2128
2129    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2130        self.inner.shutdown_with_epitaph(status)
2131    }
2132
2133    fn is_closed(&self) -> bool {
2134        self.inner.channel().is_closed()
2135    }
2136    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2137        self.inner.channel().on_closed()
2138    }
2139
2140    #[cfg(target_os = "fuchsia")]
2141    fn signal_peer(
2142        &self,
2143        clear_mask: zx::Signals,
2144        set_mask: zx::Signals,
2145    ) -> Result<(), zx_status::Status> {
2146        use fidl::Peered;
2147        self.inner.channel().signal_peer(clear_mask, set_mask)
2148    }
2149}
2150
2151impl LocalServiceControlHandle {
2152    pub fn send_on_suppress_discovery(&self) -> Result<(), fidl::Error> {
2153        self.inner.send::<fidl::encoding::EmptyPayload>(
2154            (),
2155            0,
2156            0x106d36281c3cfb66,
2157            fidl::encoding::DynamicFlags::empty(),
2158        )
2159    }
2160
2161    pub fn send_on_notify_value(
2162        &self,
2163        mut payload: &ValueChangedParameters,
2164    ) -> Result<(), fidl::Error> {
2165        self.inner.send::<ValueChangedParameters>(
2166            payload,
2167            0,
2168            0x190c1c528bfd0068,
2169            fidl::encoding::DynamicFlags::empty(),
2170        )
2171    }
2172
2173    pub fn send_on_indicate_value(
2174        &self,
2175        mut update: &ValueChangedParameters,
2176        mut confirmation: fidl::EventPair,
2177    ) -> Result<(), fidl::Error> {
2178        self.inner.send::<LocalServiceOnIndicateValueRequest>(
2179            (update, confirmation),
2180            0,
2181            0x59431c3653ac531f,
2182            fidl::encoding::DynamicFlags::empty(),
2183        )
2184    }
2185}
2186
2187#[must_use = "FIDL methods require a response to be sent"]
2188#[derive(Debug)]
2189pub struct LocalServiceCharacteristicConfigurationResponder {
2190    control_handle: std::mem::ManuallyDrop<LocalServiceControlHandle>,
2191    tx_id: u32,
2192}
2193
2194/// Set the the channel to be shutdown (see [`LocalServiceControlHandle::shutdown`])
2195/// if the responder is dropped without sending a response, so that the client
2196/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2197impl std::ops::Drop for LocalServiceCharacteristicConfigurationResponder {
2198    fn drop(&mut self) {
2199        self.control_handle.shutdown();
2200        // Safety: drops once, never accessed again
2201        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2202    }
2203}
2204
2205impl fidl::endpoints::Responder for LocalServiceCharacteristicConfigurationResponder {
2206    type ControlHandle = LocalServiceControlHandle;
2207
2208    fn control_handle(&self) -> &LocalServiceControlHandle {
2209        &self.control_handle
2210    }
2211
2212    fn drop_without_shutdown(mut self) {
2213        // Safety: drops once, never accessed again due to mem::forget
2214        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2215        // Prevent Drop from running (which would shut down the channel)
2216        std::mem::forget(self);
2217    }
2218}
2219
2220impl LocalServiceCharacteristicConfigurationResponder {
2221    /// Sends a response to the FIDL transaction.
2222    ///
2223    /// Sets the channel to shutdown if an error occurs.
2224    pub fn send(self) -> Result<(), fidl::Error> {
2225        let _result = self.send_raw();
2226        if _result.is_err() {
2227            self.control_handle.shutdown();
2228        }
2229        self.drop_without_shutdown();
2230        _result
2231    }
2232
2233    /// Similar to "send" but does not shutdown the channel if an error occurs.
2234    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
2235        let _result = self.send_raw();
2236        self.drop_without_shutdown();
2237        _result
2238    }
2239
2240    fn send_raw(&self) -> Result<(), fidl::Error> {
2241        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
2242            (),
2243            self.tx_id,
2244            0x431101fcd8d9ef15,
2245            fidl::encoding::DynamicFlags::empty(),
2246        )
2247    }
2248}
2249
2250#[must_use = "FIDL methods require a response to be sent"]
2251#[derive(Debug)]
2252pub struct LocalServiceReadValueResponder {
2253    control_handle: std::mem::ManuallyDrop<LocalServiceControlHandle>,
2254    tx_id: u32,
2255}
2256
2257/// Set the the channel to be shutdown (see [`LocalServiceControlHandle::shutdown`])
2258/// if the responder is dropped without sending a response, so that the client
2259/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2260impl std::ops::Drop for LocalServiceReadValueResponder {
2261    fn drop(&mut self) {
2262        self.control_handle.shutdown();
2263        // Safety: drops once, never accessed again
2264        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2265    }
2266}
2267
2268impl fidl::endpoints::Responder for LocalServiceReadValueResponder {
2269    type ControlHandle = LocalServiceControlHandle;
2270
2271    fn control_handle(&self) -> &LocalServiceControlHandle {
2272        &self.control_handle
2273    }
2274
2275    fn drop_without_shutdown(mut self) {
2276        // Safety: drops once, never accessed again due to mem::forget
2277        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2278        // Prevent Drop from running (which would shut down the channel)
2279        std::mem::forget(self);
2280    }
2281}
2282
2283impl LocalServiceReadValueResponder {
2284    /// Sends a response to the FIDL transaction.
2285    ///
2286    /// Sets the channel to shutdown if an error occurs.
2287    pub fn send(self, mut result: Result<&[u8], Error>) -> Result<(), fidl::Error> {
2288        let _result = self.send_raw(result);
2289        if _result.is_err() {
2290            self.control_handle.shutdown();
2291        }
2292        self.drop_without_shutdown();
2293        _result
2294    }
2295
2296    /// Similar to "send" but does not shutdown the channel if an error occurs.
2297    pub fn send_no_shutdown_on_err(
2298        self,
2299        mut result: Result<&[u8], Error>,
2300    ) -> Result<(), fidl::Error> {
2301        let _result = self.send_raw(result);
2302        self.drop_without_shutdown();
2303        _result
2304    }
2305
2306    fn send_raw(&self, mut result: Result<&[u8], Error>) -> Result<(), fidl::Error> {
2307        self.control_handle
2308            .inner
2309            .send::<fidl::encoding::ResultType<LocalServiceReadValueResponse, Error>>(
2310                result.map(|value| (value,)),
2311                self.tx_id,
2312                0x49e11d396625d104,
2313                fidl::encoding::DynamicFlags::empty(),
2314            )
2315    }
2316}
2317
2318#[must_use = "FIDL methods require a response to be sent"]
2319#[derive(Debug)]
2320pub struct LocalServiceWriteValueResponder {
2321    control_handle: std::mem::ManuallyDrop<LocalServiceControlHandle>,
2322    tx_id: u32,
2323}
2324
2325/// Set the the channel to be shutdown (see [`LocalServiceControlHandle::shutdown`])
2326/// if the responder is dropped without sending a response, so that the client
2327/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2328impl std::ops::Drop for LocalServiceWriteValueResponder {
2329    fn drop(&mut self) {
2330        self.control_handle.shutdown();
2331        // Safety: drops once, never accessed again
2332        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2333    }
2334}
2335
2336impl fidl::endpoints::Responder for LocalServiceWriteValueResponder {
2337    type ControlHandle = LocalServiceControlHandle;
2338
2339    fn control_handle(&self) -> &LocalServiceControlHandle {
2340        &self.control_handle
2341    }
2342
2343    fn drop_without_shutdown(mut self) {
2344        // Safety: drops once, never accessed again due to mem::forget
2345        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2346        // Prevent Drop from running (which would shut down the channel)
2347        std::mem::forget(self);
2348    }
2349}
2350
2351impl LocalServiceWriteValueResponder {
2352    /// Sends a response to the FIDL transaction.
2353    ///
2354    /// Sets the channel to shutdown if an error occurs.
2355    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2356        let _result = self.send_raw(result);
2357        if _result.is_err() {
2358            self.control_handle.shutdown();
2359        }
2360        self.drop_without_shutdown();
2361        _result
2362    }
2363
2364    /// Similar to "send" but does not shutdown the channel if an error occurs.
2365    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2366        let _result = self.send_raw(result);
2367        self.drop_without_shutdown();
2368        _result
2369    }
2370
2371    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2372        self.control_handle
2373            .inner
2374            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
2375                result,
2376                self.tx_id,
2377                0x7d6ae631baf18260,
2378                fidl::encoding::DynamicFlags::empty(),
2379            )
2380    }
2381}
2382
2383#[must_use = "FIDL methods require a response to be sent"]
2384#[derive(Debug)]
2385pub struct LocalServicePeerUpdateResponder {
2386    control_handle: std::mem::ManuallyDrop<LocalServiceControlHandle>,
2387    tx_id: u32,
2388}
2389
2390/// Set the the channel to be shutdown (see [`LocalServiceControlHandle::shutdown`])
2391/// if the responder is dropped without sending a response, so that the client
2392/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2393impl std::ops::Drop for LocalServicePeerUpdateResponder {
2394    fn drop(&mut self) {
2395        self.control_handle.shutdown();
2396        // Safety: drops once, never accessed again
2397        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2398    }
2399}
2400
2401impl fidl::endpoints::Responder for LocalServicePeerUpdateResponder {
2402    type ControlHandle = LocalServiceControlHandle;
2403
2404    fn control_handle(&self) -> &LocalServiceControlHandle {
2405        &self.control_handle
2406    }
2407
2408    fn drop_without_shutdown(mut self) {
2409        // Safety: drops once, never accessed again due to mem::forget
2410        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2411        // Prevent Drop from running (which would shut down the channel)
2412        std::mem::forget(self);
2413    }
2414}
2415
2416impl LocalServicePeerUpdateResponder {
2417    /// Sends a response to the FIDL transaction.
2418    ///
2419    /// Sets the channel to shutdown if an error occurs.
2420    pub fn send(self) -> Result<(), fidl::Error> {
2421        let _result = self.send_raw();
2422        if _result.is_err() {
2423            self.control_handle.shutdown();
2424        }
2425        self.drop_without_shutdown();
2426        _result
2427    }
2428
2429    /// Similar to "send" but does not shutdown the channel if an error occurs.
2430    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
2431        let _result = self.send_raw();
2432        self.drop_without_shutdown();
2433        _result
2434    }
2435
2436    fn send_raw(&self) -> Result<(), fidl::Error> {
2437        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
2438            (),
2439            self.tx_id,
2440            0x7e362177a04108b8,
2441            fidl::encoding::DynamicFlags::empty(),
2442        )
2443    }
2444}
2445
2446#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2447pub struct RemoteServiceMarker;
2448
2449impl fidl::endpoints::ProtocolMarker for RemoteServiceMarker {
2450    type Proxy = RemoteServiceProxy;
2451    type RequestStream = RemoteServiceRequestStream;
2452    #[cfg(target_os = "fuchsia")]
2453    type SynchronousProxy = RemoteServiceSynchronousProxy;
2454
2455    const DEBUG_NAME: &'static str = "(anonymous) RemoteService";
2456}
2457pub type RemoteServiceReadByTypeResult = Result<Vec<ReadByTypeResult>, Error>;
2458pub type RemoteServiceReadCharacteristicResult = Result<ReadValue, Error>;
2459pub type RemoteServiceWriteCharacteristicResult = Result<(), Error>;
2460pub type RemoteServiceReadDescriptorResult = Result<ReadValue, Error>;
2461pub type RemoteServiceWriteDescriptorResult = Result<(), Error>;
2462pub type RemoteServiceRegisterCharacteristicNotifierResult = Result<(), Error>;
2463
2464pub trait RemoteServiceProxyInterface: Send + Sync {
2465    type DiscoverCharacteristicsResponseFut: std::future::Future<Output = Result<Vec<Characteristic>, fidl::Error>>
2466        + Send;
2467    fn r#discover_characteristics(&self) -> Self::DiscoverCharacteristicsResponseFut;
2468    type ReadByTypeResponseFut: std::future::Future<Output = Result<RemoteServiceReadByTypeResult, fidl::Error>>
2469        + Send;
2470    fn r#read_by_type(&self, uuid: &fidl_fuchsia_bluetooth::Uuid) -> Self::ReadByTypeResponseFut;
2471    type ReadCharacteristicResponseFut: std::future::Future<Output = Result<RemoteServiceReadCharacteristicResult, fidl::Error>>
2472        + Send;
2473    fn r#read_characteristic(
2474        &self,
2475        handle: &Handle,
2476        options: &ReadOptions,
2477    ) -> Self::ReadCharacteristicResponseFut;
2478    type WriteCharacteristicResponseFut: std::future::Future<Output = Result<RemoteServiceWriteCharacteristicResult, fidl::Error>>
2479        + Send;
2480    fn r#write_characteristic(
2481        &self,
2482        handle: &Handle,
2483        value: &[u8],
2484        options: &WriteOptions,
2485    ) -> Self::WriteCharacteristicResponseFut;
2486    type ReadDescriptorResponseFut: std::future::Future<Output = Result<RemoteServiceReadDescriptorResult, fidl::Error>>
2487        + Send;
2488    fn r#read_descriptor(
2489        &self,
2490        handle: &Handle,
2491        options: &ReadOptions,
2492    ) -> Self::ReadDescriptorResponseFut;
2493    type WriteDescriptorResponseFut: std::future::Future<Output = Result<RemoteServiceWriteDescriptorResult, fidl::Error>>
2494        + Send;
2495    fn r#write_descriptor(
2496        &self,
2497        handle: &Handle,
2498        value: &[u8],
2499        options: &WriteOptions,
2500    ) -> Self::WriteDescriptorResponseFut;
2501    type RegisterCharacteristicNotifierResponseFut: std::future::Future<
2502            Output = Result<RemoteServiceRegisterCharacteristicNotifierResult, fidl::Error>,
2503        > + Send;
2504    fn r#register_characteristic_notifier(
2505        &self,
2506        handle: &Handle,
2507        notifier: fidl::endpoints::ClientEnd<CharacteristicNotifierMarker>,
2508    ) -> Self::RegisterCharacteristicNotifierResponseFut;
2509}
2510#[derive(Debug)]
2511#[cfg(target_os = "fuchsia")]
2512pub struct RemoteServiceSynchronousProxy {
2513    client: fidl::client::sync::Client,
2514}
2515
2516#[cfg(target_os = "fuchsia")]
2517impl fidl::endpoints::SynchronousProxy for RemoteServiceSynchronousProxy {
2518    type Proxy = RemoteServiceProxy;
2519    type Protocol = RemoteServiceMarker;
2520
2521    fn from_channel(inner: fidl::Channel) -> Self {
2522        Self::new(inner)
2523    }
2524
2525    fn into_channel(self) -> fidl::Channel {
2526        self.client.into_channel()
2527    }
2528
2529    fn as_channel(&self) -> &fidl::Channel {
2530        self.client.as_channel()
2531    }
2532}
2533
2534#[cfg(target_os = "fuchsia")]
2535impl RemoteServiceSynchronousProxy {
2536    pub fn new(channel: fidl::Channel) -> Self {
2537        let protocol_name = <RemoteServiceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2538        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
2539    }
2540
2541    pub fn into_channel(self) -> fidl::Channel {
2542        self.client.into_channel()
2543    }
2544
2545    /// Waits until an event arrives and returns it. It is safe for other
2546    /// threads to make concurrent requests while waiting for an event.
2547    pub fn wait_for_event(
2548        &self,
2549        deadline: zx::MonotonicInstant,
2550    ) -> Result<RemoteServiceEvent, fidl::Error> {
2551        RemoteServiceEvent::decode(self.client.wait_for_event(deadline)?)
2552    }
2553
2554    /// Returns the characteristics and characteristic descriptors that belong to
2555    /// this service.
2556    pub fn r#discover_characteristics(
2557        &self,
2558        ___deadline: zx::MonotonicInstant,
2559    ) -> Result<Vec<Characteristic>, fidl::Error> {
2560        let _response = self.client.send_query::<
2561            fidl::encoding::EmptyPayload,
2562            RemoteServiceDiscoverCharacteristicsResponse,
2563        >(
2564            (),
2565            0x6cd730f12e402543,
2566            fidl::encoding::DynamicFlags::empty(),
2567            ___deadline,
2568        )?;
2569        Ok(_response.characteristics)
2570    }
2571
2572    /// Reads characteristics and descriptors with the given `uuid`.
2573    ///
2574    /// This method is useful for reading values before discovery has completed,
2575    /// thereby reducing latency.
2576    ///
2577    /// + request `uuid` The UUID of the characteristics/descriptors to read.
2578    /// - response `results` The results of the read. May be empty if no
2579    ///            matching values are read. If reading a value results in a
2580    ///            permission error, the handle and error will be included.
2581    /// * error Returns `INVALID_PARAMETERS` if `uuid` refers to an internally
2582    ///         reserved descriptor type (e.g. the Client Characteristic
2583    ///         Configuration descriptor).
2584    /// * error Returns `TOO_MANY_RESULTS` if more results were read than can fit
2585    ///         in a FIDL response. Consider reading characteristics/descriptors
2586    ///         individually after performing discovery.
2587    /// * error Returns `FAILURE` if the server returns an error not specific to
2588    ///         a single result.
2589    pub fn r#read_by_type(
2590        &self,
2591        mut uuid: &fidl_fuchsia_bluetooth::Uuid,
2592        ___deadline: zx::MonotonicInstant,
2593    ) -> Result<RemoteServiceReadByTypeResult, fidl::Error> {
2594        let _response = self.client.send_query::<
2595            RemoteServiceReadByTypeRequest,
2596            fidl::encoding::ResultType<RemoteServiceReadByTypeResponse, Error>,
2597        >(
2598            (uuid,),
2599            0x739bb1e313162bbc,
2600            fidl::encoding::DynamicFlags::empty(),
2601            ___deadline,
2602        )?;
2603        Ok(_response.map(|x| x.results))
2604    }
2605
2606    /// Reads the value of a characteristic with the given `handle`.
2607    ///
2608    /// + request `handle` The characteristic handle to read.
2609    /// + request `options` Options that apply to the read.
2610    /// - response `value` The value of the characteristic.
2611    /// * error Returns `INVALID_HANDLE` if `handle` is invalid.
2612    /// * error Returns `INVALID_PARAMETERS` if `options` is invalid.
2613    /// * error Returns `READ_NOT_PERMITTED` or `INSUFFICIENT_*` if the server
2614    ///         rejects the read request.
2615    /// * error Returns `FAILURE` if the server returns an error.
2616    pub fn r#read_characteristic(
2617        &self,
2618        mut handle: &Handle,
2619        mut options: &ReadOptions,
2620        ___deadline: zx::MonotonicInstant,
2621    ) -> Result<RemoteServiceReadCharacteristicResult, fidl::Error> {
2622        let _response = self.client.send_query::<
2623            RemoteServiceReadCharacteristicRequest,
2624            fidl::encoding::ResultType<RemoteServiceReadCharacteristicResponse, Error>,
2625        >(
2626            (handle, options,),
2627            0x4d41757ed69a96cb,
2628            fidl::encoding::DynamicFlags::empty(),
2629            ___deadline,
2630        )?;
2631        Ok(_response.map(|x| x.value))
2632    }
2633
2634    /// Writes `value` to the characteristic with `handle` using the provided
2635    /// `options`.
2636    ///
2637    /// It is not recommended to send additional writes while a write is already
2638    /// in progress (the server may receive simultaneous writes in any order).
2639    ///
2640    /// + request `handle` The characteristic to be written to.
2641    /// + request `value` The value to be written.
2642    /// + request `options` Options that apply to the write.
2643    /// - response An empty response will be sent when a success response is
2644    ///            received from the server (or immediately if
2645    ///            `options.with_response` is false)
2646    /// * error Returns `INVALID_HANDLE` if `handle` is invalid.
2647    /// * error Returns `INVALID_PARAMETERS` if `options` is invalid.
2648    /// * error Returns `WRITE_NOT_PERMITTED` or `INSUFFICIENT_*`if the server
2649    ///         rejects the write request with a reason.
2650    /// * error Returns `FAILURE` if the server returns an error.
2651    pub fn r#write_characteristic(
2652        &self,
2653        mut handle: &Handle,
2654        mut value: &[u8],
2655        mut options: &WriteOptions,
2656        ___deadline: zx::MonotonicInstant,
2657    ) -> Result<RemoteServiceWriteCharacteristicResult, fidl::Error> {
2658        let _response = self.client.send_query::<
2659            RemoteServiceWriteCharacteristicRequest,
2660            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
2661        >(
2662            (handle, value, options,),
2663            0x7fc7511adecde8c,
2664            fidl::encoding::DynamicFlags::empty(),
2665            ___deadline,
2666        )?;
2667        Ok(_response.map(|x| x))
2668    }
2669
2670    /// Reads the value of the characteristic descriptor with `handle` and
2671    /// returns it in the reply.
2672    ///
2673    /// + request `handle` The descriptor handle to read.
2674    /// + request `options` Options that apply to the read.
2675    /// - response `value` The value of the descriptor.
2676    /// * error Returns `INVALID_HANDLE` if `handle` is invalid.
2677    /// * error Returns `INVALID_PARAMETERS` if `options` is invalid.
2678    /// * error Returns `READ_NOT_PERMITTED` or `INSUFFICIENT_*` if the server
2679    ///         rejects the read request.
2680    /// * error Returns `FAILURE` if the server returns an error.
2681    pub fn r#read_descriptor(
2682        &self,
2683        mut handle: &Handle,
2684        mut options: &ReadOptions,
2685        ___deadline: zx::MonotonicInstant,
2686    ) -> Result<RemoteServiceReadDescriptorResult, fidl::Error> {
2687        let _response = self.client.send_query::<
2688            RemoteServiceReadDescriptorRequest,
2689            fidl::encoding::ResultType<RemoteServiceReadDescriptorResponse, Error>,
2690        >(
2691            (handle, options,),
2692            0x7ed7ce00457dcec1,
2693            fidl::encoding::DynamicFlags::empty(),
2694            ___deadline,
2695        )?;
2696        Ok(_response.map(|x| x.value))
2697    }
2698
2699    /// Writes `value` to the characteristic descriptor with `handle`.
2700    /// It is not recommended to send additional writes while a write is already
2701    /// in progress (the server may receive simultaneous writes in any order).
2702    ///
2703    /// + request `handle` The descriptor handle to written to.
2704    /// + request `value` The value to be written.
2705    /// + request `options` Options that apply to the write.
2706    /// - response An empty response will be sent when a success response is
2707    ///            received from the server (or immediately if
2708    ///            `options.with_response` is false)
2709    /// * error Returns `INVALID_HANDLE` if `handle` is invalid or refers to an
2710    ///         internally reserved descriptor type (e.g. the Client
2711    ///         Characteristic Configuration descriptor).
2712    /// * error Returns `INVALID_PARAMETERS` if `options` is invalid.
2713    /// * error Returns `WRITE_NOT_PERMITTED` or `INSUFFICIENT_*` if the server
2714    ///         rejects the write with a reason.
2715    /// * error Returns `FAILURE` if the server returns an error.
2716    pub fn r#write_descriptor(
2717        &self,
2718        mut handle: &Handle,
2719        mut value: &[u8],
2720        mut options: &WriteOptions,
2721        ___deadline: zx::MonotonicInstant,
2722    ) -> Result<RemoteServiceWriteDescriptorResult, fidl::Error> {
2723        let _response = self.client.send_query::<
2724            RemoteServiceWriteDescriptorRequest,
2725            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
2726        >(
2727            (handle, value, options,),
2728            0x21d9106bfd6b7351,
2729            fidl::encoding::DynamicFlags::empty(),
2730            ___deadline,
2731        )?;
2732        Ok(_response.map(|x| x))
2733    }
2734
2735    /// Subscribe to notifications & indications from the characteristic with
2736    /// the given `handle`.
2737    ///
2738    /// Either notifications or indications will be enabled depending on
2739    /// characteristic properties. Indications will be preferred if they are
2740    /// supported. This operation fails if the characteristic does not have the
2741    /// "notify" or "indicate" property.
2742    ///
2743    /// A write request will be issued to configure the characteristic for
2744    /// notifications/indications if it contains a Client Characteristic
2745    /// Configuration descriptor. This method fails if an error occurs while
2746    /// writing to the descriptor.
2747    ///
2748    /// On success, the `notifier` protocol can be used to be notified when
2749    /// the peer sends a notification or indication. Indications are
2750    /// automatically confirmed. When the protocol is dropped, the subscription
2751    /// may end if no other local client is receiving notifications.
2752    ///
2753    /// + request `handle` the characteristic handle.
2754    /// + request `notifier` the protocol used for notifications.
2755    /// - response An empty response will be sent immediately if registration
2756    ///            succeeds.
2757    /// * error Returns a `FAILURE` if the characteristic does not support
2758    ///         notifications or indications.
2759    /// * error Returns a `INVALID_HANDLE` if `handle` is invalid.
2760    /// * error Returns a `WRITE_NOT_PERMITTED`  or `INSUFFICIENT_*`for a
2761    ///         descriptor write error.
2762    pub fn r#register_characteristic_notifier(
2763        &self,
2764        mut handle: &Handle,
2765        mut notifier: fidl::endpoints::ClientEnd<CharacteristicNotifierMarker>,
2766        ___deadline: zx::MonotonicInstant,
2767    ) -> Result<RemoteServiceRegisterCharacteristicNotifierResult, fidl::Error> {
2768        let _response = self.client.send_query::<
2769            RemoteServiceRegisterCharacteristicNotifierRequest,
2770            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
2771        >(
2772            (handle, notifier,),
2773            0x35007a85245f5cc6,
2774            fidl::encoding::DynamicFlags::empty(),
2775            ___deadline,
2776        )?;
2777        Ok(_response.map(|x| x))
2778    }
2779}
2780
2781#[cfg(target_os = "fuchsia")]
2782impl From<RemoteServiceSynchronousProxy> for zx::NullableHandle {
2783    fn from(value: RemoteServiceSynchronousProxy) -> Self {
2784        value.into_channel().into()
2785    }
2786}
2787
2788#[cfg(target_os = "fuchsia")]
2789impl From<fidl::Channel> for RemoteServiceSynchronousProxy {
2790    fn from(value: fidl::Channel) -> Self {
2791        Self::new(value)
2792    }
2793}
2794
2795#[cfg(target_os = "fuchsia")]
2796impl fidl::endpoints::FromClient for RemoteServiceSynchronousProxy {
2797    type Protocol = RemoteServiceMarker;
2798
2799    fn from_client(value: fidl::endpoints::ClientEnd<RemoteServiceMarker>) -> Self {
2800        Self::new(value.into_channel())
2801    }
2802}
2803
2804#[derive(Debug, Clone)]
2805pub struct RemoteServiceProxy {
2806    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2807}
2808
2809impl fidl::endpoints::Proxy for RemoteServiceProxy {
2810    type Protocol = RemoteServiceMarker;
2811
2812    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2813        Self::new(inner)
2814    }
2815
2816    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2817        self.client.into_channel().map_err(|client| Self { client })
2818    }
2819
2820    fn as_channel(&self) -> &::fidl::AsyncChannel {
2821        self.client.as_channel()
2822    }
2823}
2824
2825impl RemoteServiceProxy {
2826    /// Create a new Proxy for fuchsia.bluetooth.gatt2/RemoteService.
2827    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2828        let protocol_name = <RemoteServiceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2829        Self { client: fidl::client::Client::new(channel, protocol_name) }
2830    }
2831
2832    /// Get a Stream of events from the remote end of the protocol.
2833    ///
2834    /// # Panics
2835    ///
2836    /// Panics if the event stream was already taken.
2837    pub fn take_event_stream(&self) -> RemoteServiceEventStream {
2838        RemoteServiceEventStream { event_receiver: self.client.take_event_receiver() }
2839    }
2840
2841    /// Returns the characteristics and characteristic descriptors that belong to
2842    /// this service.
2843    pub fn r#discover_characteristics(
2844        &self,
2845    ) -> fidl::client::QueryResponseFut<
2846        Vec<Characteristic>,
2847        fidl::encoding::DefaultFuchsiaResourceDialect,
2848    > {
2849        RemoteServiceProxyInterface::r#discover_characteristics(self)
2850    }
2851
2852    /// Reads characteristics and descriptors with the given `uuid`.
2853    ///
2854    /// This method is useful for reading values before discovery has completed,
2855    /// thereby reducing latency.
2856    ///
2857    /// + request `uuid` The UUID of the characteristics/descriptors to read.
2858    /// - response `results` The results of the read. May be empty if no
2859    ///            matching values are read. If reading a value results in a
2860    ///            permission error, the handle and error will be included.
2861    /// * error Returns `INVALID_PARAMETERS` if `uuid` refers to an internally
2862    ///         reserved descriptor type (e.g. the Client Characteristic
2863    ///         Configuration descriptor).
2864    /// * error Returns `TOO_MANY_RESULTS` if more results were read than can fit
2865    ///         in a FIDL response. Consider reading characteristics/descriptors
2866    ///         individually after performing discovery.
2867    /// * error Returns `FAILURE` if the server returns an error not specific to
2868    ///         a single result.
2869    pub fn r#read_by_type(
2870        &self,
2871        mut uuid: &fidl_fuchsia_bluetooth::Uuid,
2872    ) -> fidl::client::QueryResponseFut<
2873        RemoteServiceReadByTypeResult,
2874        fidl::encoding::DefaultFuchsiaResourceDialect,
2875    > {
2876        RemoteServiceProxyInterface::r#read_by_type(self, uuid)
2877    }
2878
2879    /// Reads the value of a characteristic with the given `handle`.
2880    ///
2881    /// + request `handle` The characteristic handle to read.
2882    /// + request `options` Options that apply to the read.
2883    /// - response `value` The value of the characteristic.
2884    /// * error Returns `INVALID_HANDLE` if `handle` is invalid.
2885    /// * error Returns `INVALID_PARAMETERS` if `options` is invalid.
2886    /// * error Returns `READ_NOT_PERMITTED` or `INSUFFICIENT_*` if the server
2887    ///         rejects the read request.
2888    /// * error Returns `FAILURE` if the server returns an error.
2889    pub fn r#read_characteristic(
2890        &self,
2891        mut handle: &Handle,
2892        mut options: &ReadOptions,
2893    ) -> fidl::client::QueryResponseFut<
2894        RemoteServiceReadCharacteristicResult,
2895        fidl::encoding::DefaultFuchsiaResourceDialect,
2896    > {
2897        RemoteServiceProxyInterface::r#read_characteristic(self, handle, options)
2898    }
2899
2900    /// Writes `value` to the characteristic with `handle` using the provided
2901    /// `options`.
2902    ///
2903    /// It is not recommended to send additional writes while a write is already
2904    /// in progress (the server may receive simultaneous writes in any order).
2905    ///
2906    /// + request `handle` The characteristic to be written to.
2907    /// + request `value` The value to be written.
2908    /// + request `options` Options that apply to the write.
2909    /// - response An empty response will be sent when a success response is
2910    ///            received from the server (or immediately if
2911    ///            `options.with_response` is false)
2912    /// * error Returns `INVALID_HANDLE` if `handle` is invalid.
2913    /// * error Returns `INVALID_PARAMETERS` if `options` is invalid.
2914    /// * error Returns `WRITE_NOT_PERMITTED` or `INSUFFICIENT_*`if the server
2915    ///         rejects the write request with a reason.
2916    /// * error Returns `FAILURE` if the server returns an error.
2917    pub fn r#write_characteristic(
2918        &self,
2919        mut handle: &Handle,
2920        mut value: &[u8],
2921        mut options: &WriteOptions,
2922    ) -> fidl::client::QueryResponseFut<
2923        RemoteServiceWriteCharacteristicResult,
2924        fidl::encoding::DefaultFuchsiaResourceDialect,
2925    > {
2926        RemoteServiceProxyInterface::r#write_characteristic(self, handle, value, options)
2927    }
2928
2929    /// Reads the value of the characteristic descriptor with `handle` and
2930    /// returns it in the reply.
2931    ///
2932    /// + request `handle` The descriptor handle to read.
2933    /// + request `options` Options that apply to the read.
2934    /// - response `value` The value of the descriptor.
2935    /// * error Returns `INVALID_HANDLE` if `handle` is invalid.
2936    /// * error Returns `INVALID_PARAMETERS` if `options` is invalid.
2937    /// * error Returns `READ_NOT_PERMITTED` or `INSUFFICIENT_*` if the server
2938    ///         rejects the read request.
2939    /// * error Returns `FAILURE` if the server returns an error.
2940    pub fn r#read_descriptor(
2941        &self,
2942        mut handle: &Handle,
2943        mut options: &ReadOptions,
2944    ) -> fidl::client::QueryResponseFut<
2945        RemoteServiceReadDescriptorResult,
2946        fidl::encoding::DefaultFuchsiaResourceDialect,
2947    > {
2948        RemoteServiceProxyInterface::r#read_descriptor(self, handle, options)
2949    }
2950
2951    /// Writes `value` to the characteristic descriptor with `handle`.
2952    /// It is not recommended to send additional writes while a write is already
2953    /// in progress (the server may receive simultaneous writes in any order).
2954    ///
2955    /// + request `handle` The descriptor handle to written to.
2956    /// + request `value` The value to be written.
2957    /// + request `options` Options that apply to the write.
2958    /// - response An empty response will be sent when a success response is
2959    ///            received from the server (or immediately if
2960    ///            `options.with_response` is false)
2961    /// * error Returns `INVALID_HANDLE` if `handle` is invalid or refers to an
2962    ///         internally reserved descriptor type (e.g. the Client
2963    ///         Characteristic Configuration descriptor).
2964    /// * error Returns `INVALID_PARAMETERS` if `options` is invalid.
2965    /// * error Returns `WRITE_NOT_PERMITTED` or `INSUFFICIENT_*` if the server
2966    ///         rejects the write with a reason.
2967    /// * error Returns `FAILURE` if the server returns an error.
2968    pub fn r#write_descriptor(
2969        &self,
2970        mut handle: &Handle,
2971        mut value: &[u8],
2972        mut options: &WriteOptions,
2973    ) -> fidl::client::QueryResponseFut<
2974        RemoteServiceWriteDescriptorResult,
2975        fidl::encoding::DefaultFuchsiaResourceDialect,
2976    > {
2977        RemoteServiceProxyInterface::r#write_descriptor(self, handle, value, options)
2978    }
2979
2980    /// Subscribe to notifications & indications from the characteristic with
2981    /// the given `handle`.
2982    ///
2983    /// Either notifications or indications will be enabled depending on
2984    /// characteristic properties. Indications will be preferred if they are
2985    /// supported. This operation fails if the characteristic does not have the
2986    /// "notify" or "indicate" property.
2987    ///
2988    /// A write request will be issued to configure the characteristic for
2989    /// notifications/indications if it contains a Client Characteristic
2990    /// Configuration descriptor. This method fails if an error occurs while
2991    /// writing to the descriptor.
2992    ///
2993    /// On success, the `notifier` protocol can be used to be notified when
2994    /// the peer sends a notification or indication. Indications are
2995    /// automatically confirmed. When the protocol is dropped, the subscription
2996    /// may end if no other local client is receiving notifications.
2997    ///
2998    /// + request `handle` the characteristic handle.
2999    /// + request `notifier` the protocol used for notifications.
3000    /// - response An empty response will be sent immediately if registration
3001    ///            succeeds.
3002    /// * error Returns a `FAILURE` if the characteristic does not support
3003    ///         notifications or indications.
3004    /// * error Returns a `INVALID_HANDLE` if `handle` is invalid.
3005    /// * error Returns a `WRITE_NOT_PERMITTED`  or `INSUFFICIENT_*`for a
3006    ///         descriptor write error.
3007    pub fn r#register_characteristic_notifier(
3008        &self,
3009        mut handle: &Handle,
3010        mut notifier: fidl::endpoints::ClientEnd<CharacteristicNotifierMarker>,
3011    ) -> fidl::client::QueryResponseFut<
3012        RemoteServiceRegisterCharacteristicNotifierResult,
3013        fidl::encoding::DefaultFuchsiaResourceDialect,
3014    > {
3015        RemoteServiceProxyInterface::r#register_characteristic_notifier(self, handle, notifier)
3016    }
3017}
3018
3019impl RemoteServiceProxyInterface for RemoteServiceProxy {
3020    type DiscoverCharacteristicsResponseFut = fidl::client::QueryResponseFut<
3021        Vec<Characteristic>,
3022        fidl::encoding::DefaultFuchsiaResourceDialect,
3023    >;
3024    fn r#discover_characteristics(&self) -> Self::DiscoverCharacteristicsResponseFut {
3025        fn _decode(
3026            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3027        ) -> Result<Vec<Characteristic>, fidl::Error> {
3028            let _response = fidl::client::decode_transaction_body::<
3029                RemoteServiceDiscoverCharacteristicsResponse,
3030                fidl::encoding::DefaultFuchsiaResourceDialect,
3031                0x6cd730f12e402543,
3032            >(_buf?)?;
3033            Ok(_response.characteristics)
3034        }
3035        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<Characteristic>>(
3036            (),
3037            0x6cd730f12e402543,
3038            fidl::encoding::DynamicFlags::empty(),
3039            _decode,
3040        )
3041    }
3042
3043    type ReadByTypeResponseFut = fidl::client::QueryResponseFut<
3044        RemoteServiceReadByTypeResult,
3045        fidl::encoding::DefaultFuchsiaResourceDialect,
3046    >;
3047    fn r#read_by_type(
3048        &self,
3049        mut uuid: &fidl_fuchsia_bluetooth::Uuid,
3050    ) -> Self::ReadByTypeResponseFut {
3051        fn _decode(
3052            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3053        ) -> Result<RemoteServiceReadByTypeResult, fidl::Error> {
3054            let _response = fidl::client::decode_transaction_body::<
3055                fidl::encoding::ResultType<RemoteServiceReadByTypeResponse, Error>,
3056                fidl::encoding::DefaultFuchsiaResourceDialect,
3057                0x739bb1e313162bbc,
3058            >(_buf?)?;
3059            Ok(_response.map(|x| x.results))
3060        }
3061        self.client
3062            .send_query_and_decode::<RemoteServiceReadByTypeRequest, RemoteServiceReadByTypeResult>(
3063                (uuid,),
3064                0x739bb1e313162bbc,
3065                fidl::encoding::DynamicFlags::empty(),
3066                _decode,
3067            )
3068    }
3069
3070    type ReadCharacteristicResponseFut = fidl::client::QueryResponseFut<
3071        RemoteServiceReadCharacteristicResult,
3072        fidl::encoding::DefaultFuchsiaResourceDialect,
3073    >;
3074    fn r#read_characteristic(
3075        &self,
3076        mut handle: &Handle,
3077        mut options: &ReadOptions,
3078    ) -> Self::ReadCharacteristicResponseFut {
3079        fn _decode(
3080            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3081        ) -> Result<RemoteServiceReadCharacteristicResult, fidl::Error> {
3082            let _response = fidl::client::decode_transaction_body::<
3083                fidl::encoding::ResultType<RemoteServiceReadCharacteristicResponse, Error>,
3084                fidl::encoding::DefaultFuchsiaResourceDialect,
3085                0x4d41757ed69a96cb,
3086            >(_buf?)?;
3087            Ok(_response.map(|x| x.value))
3088        }
3089        self.client.send_query_and_decode::<
3090            RemoteServiceReadCharacteristicRequest,
3091            RemoteServiceReadCharacteristicResult,
3092        >(
3093            (handle, options,),
3094            0x4d41757ed69a96cb,
3095            fidl::encoding::DynamicFlags::empty(),
3096            _decode,
3097        )
3098    }
3099
3100    type WriteCharacteristicResponseFut = fidl::client::QueryResponseFut<
3101        RemoteServiceWriteCharacteristicResult,
3102        fidl::encoding::DefaultFuchsiaResourceDialect,
3103    >;
3104    fn r#write_characteristic(
3105        &self,
3106        mut handle: &Handle,
3107        mut value: &[u8],
3108        mut options: &WriteOptions,
3109    ) -> Self::WriteCharacteristicResponseFut {
3110        fn _decode(
3111            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3112        ) -> Result<RemoteServiceWriteCharacteristicResult, fidl::Error> {
3113            let _response = fidl::client::decode_transaction_body::<
3114                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
3115                fidl::encoding::DefaultFuchsiaResourceDialect,
3116                0x7fc7511adecde8c,
3117            >(_buf?)?;
3118            Ok(_response.map(|x| x))
3119        }
3120        self.client.send_query_and_decode::<
3121            RemoteServiceWriteCharacteristicRequest,
3122            RemoteServiceWriteCharacteristicResult,
3123        >(
3124            (handle, value, options,),
3125            0x7fc7511adecde8c,
3126            fidl::encoding::DynamicFlags::empty(),
3127            _decode,
3128        )
3129    }
3130
3131    type ReadDescriptorResponseFut = fidl::client::QueryResponseFut<
3132        RemoteServiceReadDescriptorResult,
3133        fidl::encoding::DefaultFuchsiaResourceDialect,
3134    >;
3135    fn r#read_descriptor(
3136        &self,
3137        mut handle: &Handle,
3138        mut options: &ReadOptions,
3139    ) -> Self::ReadDescriptorResponseFut {
3140        fn _decode(
3141            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3142        ) -> Result<RemoteServiceReadDescriptorResult, fidl::Error> {
3143            let _response = fidl::client::decode_transaction_body::<
3144                fidl::encoding::ResultType<RemoteServiceReadDescriptorResponse, Error>,
3145                fidl::encoding::DefaultFuchsiaResourceDialect,
3146                0x7ed7ce00457dcec1,
3147            >(_buf?)?;
3148            Ok(_response.map(|x| x.value))
3149        }
3150        self.client.send_query_and_decode::<
3151            RemoteServiceReadDescriptorRequest,
3152            RemoteServiceReadDescriptorResult,
3153        >(
3154            (handle, options,),
3155            0x7ed7ce00457dcec1,
3156            fidl::encoding::DynamicFlags::empty(),
3157            _decode,
3158        )
3159    }
3160
3161    type WriteDescriptorResponseFut = fidl::client::QueryResponseFut<
3162        RemoteServiceWriteDescriptorResult,
3163        fidl::encoding::DefaultFuchsiaResourceDialect,
3164    >;
3165    fn r#write_descriptor(
3166        &self,
3167        mut handle: &Handle,
3168        mut value: &[u8],
3169        mut options: &WriteOptions,
3170    ) -> Self::WriteDescriptorResponseFut {
3171        fn _decode(
3172            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3173        ) -> Result<RemoteServiceWriteDescriptorResult, fidl::Error> {
3174            let _response = fidl::client::decode_transaction_body::<
3175                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
3176                fidl::encoding::DefaultFuchsiaResourceDialect,
3177                0x21d9106bfd6b7351,
3178            >(_buf?)?;
3179            Ok(_response.map(|x| x))
3180        }
3181        self.client.send_query_and_decode::<
3182            RemoteServiceWriteDescriptorRequest,
3183            RemoteServiceWriteDescriptorResult,
3184        >(
3185            (handle, value, options,),
3186            0x21d9106bfd6b7351,
3187            fidl::encoding::DynamicFlags::empty(),
3188            _decode,
3189        )
3190    }
3191
3192    type RegisterCharacteristicNotifierResponseFut = fidl::client::QueryResponseFut<
3193        RemoteServiceRegisterCharacteristicNotifierResult,
3194        fidl::encoding::DefaultFuchsiaResourceDialect,
3195    >;
3196    fn r#register_characteristic_notifier(
3197        &self,
3198        mut handle: &Handle,
3199        mut notifier: fidl::endpoints::ClientEnd<CharacteristicNotifierMarker>,
3200    ) -> Self::RegisterCharacteristicNotifierResponseFut {
3201        fn _decode(
3202            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3203        ) -> Result<RemoteServiceRegisterCharacteristicNotifierResult, fidl::Error> {
3204            let _response = fidl::client::decode_transaction_body::<
3205                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
3206                fidl::encoding::DefaultFuchsiaResourceDialect,
3207                0x35007a85245f5cc6,
3208            >(_buf?)?;
3209            Ok(_response.map(|x| x))
3210        }
3211        self.client.send_query_and_decode::<
3212            RemoteServiceRegisterCharacteristicNotifierRequest,
3213            RemoteServiceRegisterCharacteristicNotifierResult,
3214        >(
3215            (handle, notifier,),
3216            0x35007a85245f5cc6,
3217            fidl::encoding::DynamicFlags::empty(),
3218            _decode,
3219        )
3220    }
3221}
3222
3223pub struct RemoteServiceEventStream {
3224    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3225}
3226
3227impl std::marker::Unpin for RemoteServiceEventStream {}
3228
3229impl futures::stream::FusedStream for RemoteServiceEventStream {
3230    fn is_terminated(&self) -> bool {
3231        self.event_receiver.is_terminated()
3232    }
3233}
3234
3235impl futures::Stream for RemoteServiceEventStream {
3236    type Item = Result<RemoteServiceEvent, fidl::Error>;
3237
3238    fn poll_next(
3239        mut self: std::pin::Pin<&mut Self>,
3240        cx: &mut std::task::Context<'_>,
3241    ) -> std::task::Poll<Option<Self::Item>> {
3242        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3243            &mut self.event_receiver,
3244            cx
3245        )?) {
3246            Some(buf) => std::task::Poll::Ready(Some(RemoteServiceEvent::decode(buf))),
3247            None => std::task::Poll::Ready(None),
3248        }
3249    }
3250}
3251
3252#[derive(Debug)]
3253pub enum RemoteServiceEvent {}
3254
3255impl RemoteServiceEvent {
3256    /// Decodes a message buffer as a [`RemoteServiceEvent`].
3257    fn decode(
3258        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3259    ) -> Result<RemoteServiceEvent, fidl::Error> {
3260        let (bytes, _handles) = buf.split_mut();
3261        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3262        debug_assert_eq!(tx_header.tx_id, 0);
3263        match tx_header.ordinal {
3264            _ => Err(fidl::Error::UnknownOrdinal {
3265                ordinal: tx_header.ordinal,
3266                protocol_name: <RemoteServiceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3267            }),
3268        }
3269    }
3270}
3271
3272/// A Stream of incoming requests for fuchsia.bluetooth.gatt2/RemoteService.
3273pub struct RemoteServiceRequestStream {
3274    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3275    is_terminated: bool,
3276}
3277
3278impl std::marker::Unpin for RemoteServiceRequestStream {}
3279
3280impl futures::stream::FusedStream for RemoteServiceRequestStream {
3281    fn is_terminated(&self) -> bool {
3282        self.is_terminated
3283    }
3284}
3285
3286impl fidl::endpoints::RequestStream for RemoteServiceRequestStream {
3287    type Protocol = RemoteServiceMarker;
3288    type ControlHandle = RemoteServiceControlHandle;
3289
3290    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3291        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3292    }
3293
3294    fn control_handle(&self) -> Self::ControlHandle {
3295        RemoteServiceControlHandle { inner: self.inner.clone() }
3296    }
3297
3298    fn into_inner(
3299        self,
3300    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3301    {
3302        (self.inner, self.is_terminated)
3303    }
3304
3305    fn from_inner(
3306        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3307        is_terminated: bool,
3308    ) -> Self {
3309        Self { inner, is_terminated }
3310    }
3311}
3312
3313impl futures::Stream for RemoteServiceRequestStream {
3314    type Item = Result<RemoteServiceRequest, fidl::Error>;
3315
3316    fn poll_next(
3317        mut self: std::pin::Pin<&mut Self>,
3318        cx: &mut std::task::Context<'_>,
3319    ) -> std::task::Poll<Option<Self::Item>> {
3320        let this = &mut *self;
3321        if this.inner.check_shutdown(cx) {
3322            this.is_terminated = true;
3323            return std::task::Poll::Ready(None);
3324        }
3325        if this.is_terminated {
3326            panic!("polled RemoteServiceRequestStream after completion");
3327        }
3328        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3329            |bytes, handles| {
3330                match this.inner.channel().read_etc(cx, bytes, handles) {
3331                    std::task::Poll::Ready(Ok(())) => {}
3332                    std::task::Poll::Pending => return std::task::Poll::Pending,
3333                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3334                        this.is_terminated = true;
3335                        return std::task::Poll::Ready(None);
3336                    }
3337                    std::task::Poll::Ready(Err(e)) => {
3338                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3339                            e.into(),
3340                        ))));
3341                    }
3342                }
3343
3344                // A message has been received from the channel
3345                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3346
3347                std::task::Poll::Ready(Some(match header.ordinal {
3348                    0x6cd730f12e402543 => {
3349                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3350                        let mut req = fidl::new_empty!(
3351                            fidl::encoding::EmptyPayload,
3352                            fidl::encoding::DefaultFuchsiaResourceDialect
3353                        );
3354                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3355                        let control_handle =
3356                            RemoteServiceControlHandle { inner: this.inner.clone() };
3357                        Ok(RemoteServiceRequest::DiscoverCharacteristics {
3358                            responder: RemoteServiceDiscoverCharacteristicsResponder {
3359                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3360                                tx_id: header.tx_id,
3361                            },
3362                        })
3363                    }
3364                    0x739bb1e313162bbc => {
3365                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3366                        let mut req = fidl::new_empty!(
3367                            RemoteServiceReadByTypeRequest,
3368                            fidl::encoding::DefaultFuchsiaResourceDialect
3369                        );
3370                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RemoteServiceReadByTypeRequest>(&header, _body_bytes, handles, &mut req)?;
3371                        let control_handle =
3372                            RemoteServiceControlHandle { inner: this.inner.clone() };
3373                        Ok(RemoteServiceRequest::ReadByType {
3374                            uuid: req.uuid,
3375
3376                            responder: RemoteServiceReadByTypeResponder {
3377                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3378                                tx_id: header.tx_id,
3379                            },
3380                        })
3381                    }
3382                    0x4d41757ed69a96cb => {
3383                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3384                        let mut req = fidl::new_empty!(
3385                            RemoteServiceReadCharacteristicRequest,
3386                            fidl::encoding::DefaultFuchsiaResourceDialect
3387                        );
3388                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RemoteServiceReadCharacteristicRequest>(&header, _body_bytes, handles, &mut req)?;
3389                        let control_handle =
3390                            RemoteServiceControlHandle { inner: this.inner.clone() };
3391                        Ok(RemoteServiceRequest::ReadCharacteristic {
3392                            handle: req.handle,
3393                            options: req.options,
3394
3395                            responder: RemoteServiceReadCharacteristicResponder {
3396                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3397                                tx_id: header.tx_id,
3398                            },
3399                        })
3400                    }
3401                    0x7fc7511adecde8c => {
3402                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3403                        let mut req = fidl::new_empty!(
3404                            RemoteServiceWriteCharacteristicRequest,
3405                            fidl::encoding::DefaultFuchsiaResourceDialect
3406                        );
3407                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RemoteServiceWriteCharacteristicRequest>(&header, _body_bytes, handles, &mut req)?;
3408                        let control_handle =
3409                            RemoteServiceControlHandle { inner: this.inner.clone() };
3410                        Ok(RemoteServiceRequest::WriteCharacteristic {
3411                            handle: req.handle,
3412                            value: req.value,
3413                            options: req.options,
3414
3415                            responder: RemoteServiceWriteCharacteristicResponder {
3416                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3417                                tx_id: header.tx_id,
3418                            },
3419                        })
3420                    }
3421                    0x7ed7ce00457dcec1 => {
3422                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3423                        let mut req = fidl::new_empty!(
3424                            RemoteServiceReadDescriptorRequest,
3425                            fidl::encoding::DefaultFuchsiaResourceDialect
3426                        );
3427                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RemoteServiceReadDescriptorRequest>(&header, _body_bytes, handles, &mut req)?;
3428                        let control_handle =
3429                            RemoteServiceControlHandle { inner: this.inner.clone() };
3430                        Ok(RemoteServiceRequest::ReadDescriptor {
3431                            handle: req.handle,
3432                            options: req.options,
3433
3434                            responder: RemoteServiceReadDescriptorResponder {
3435                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3436                                tx_id: header.tx_id,
3437                            },
3438                        })
3439                    }
3440                    0x21d9106bfd6b7351 => {
3441                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3442                        let mut req = fidl::new_empty!(
3443                            RemoteServiceWriteDescriptorRequest,
3444                            fidl::encoding::DefaultFuchsiaResourceDialect
3445                        );
3446                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RemoteServiceWriteDescriptorRequest>(&header, _body_bytes, handles, &mut req)?;
3447                        let control_handle =
3448                            RemoteServiceControlHandle { inner: this.inner.clone() };
3449                        Ok(RemoteServiceRequest::WriteDescriptor {
3450                            handle: req.handle,
3451                            value: req.value,
3452                            options: req.options,
3453
3454                            responder: RemoteServiceWriteDescriptorResponder {
3455                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3456                                tx_id: header.tx_id,
3457                            },
3458                        })
3459                    }
3460                    0x35007a85245f5cc6 => {
3461                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3462                        let mut req = fidl::new_empty!(
3463                            RemoteServiceRegisterCharacteristicNotifierRequest,
3464                            fidl::encoding::DefaultFuchsiaResourceDialect
3465                        );
3466                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RemoteServiceRegisterCharacteristicNotifierRequest>(&header, _body_bytes, handles, &mut req)?;
3467                        let control_handle =
3468                            RemoteServiceControlHandle { inner: this.inner.clone() };
3469                        Ok(RemoteServiceRequest::RegisterCharacteristicNotifier {
3470                            handle: req.handle,
3471                            notifier: req.notifier,
3472
3473                            responder: RemoteServiceRegisterCharacteristicNotifierResponder {
3474                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3475                                tx_id: header.tx_id,
3476                            },
3477                        })
3478                    }
3479                    _ => Err(fidl::Error::UnknownOrdinal {
3480                        ordinal: header.ordinal,
3481                        protocol_name:
3482                            <RemoteServiceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3483                    }),
3484                }))
3485            },
3486        )
3487    }
3488}
3489
3490#[derive(Debug)]
3491pub enum RemoteServiceRequest {
3492    /// Returns the characteristics and characteristic descriptors that belong to
3493    /// this service.
3494    DiscoverCharacteristics { responder: RemoteServiceDiscoverCharacteristicsResponder },
3495    /// Reads characteristics and descriptors with the given `uuid`.
3496    ///
3497    /// This method is useful for reading values before discovery has completed,
3498    /// thereby reducing latency.
3499    ///
3500    /// + request `uuid` The UUID of the characteristics/descriptors to read.
3501    /// - response `results` The results of the read. May be empty if no
3502    ///            matching values are read. If reading a value results in a
3503    ///            permission error, the handle and error will be included.
3504    /// * error Returns `INVALID_PARAMETERS` if `uuid` refers to an internally
3505    ///         reserved descriptor type (e.g. the Client Characteristic
3506    ///         Configuration descriptor).
3507    /// * error Returns `TOO_MANY_RESULTS` if more results were read than can fit
3508    ///         in a FIDL response. Consider reading characteristics/descriptors
3509    ///         individually after performing discovery.
3510    /// * error Returns `FAILURE` if the server returns an error not specific to
3511    ///         a single result.
3512    ReadByType { uuid: fidl_fuchsia_bluetooth::Uuid, responder: RemoteServiceReadByTypeResponder },
3513    /// Reads the value of a characteristic with the given `handle`.
3514    ///
3515    /// + request `handle` The characteristic handle to read.
3516    /// + request `options` Options that apply to the read.
3517    /// - response `value` The value of the characteristic.
3518    /// * error Returns `INVALID_HANDLE` if `handle` is invalid.
3519    /// * error Returns `INVALID_PARAMETERS` if `options` is invalid.
3520    /// * error Returns `READ_NOT_PERMITTED` or `INSUFFICIENT_*` if the server
3521    ///         rejects the read request.
3522    /// * error Returns `FAILURE` if the server returns an error.
3523    ReadCharacteristic {
3524        handle: Handle,
3525        options: ReadOptions,
3526        responder: RemoteServiceReadCharacteristicResponder,
3527    },
3528    /// Writes `value` to the characteristic with `handle` using the provided
3529    /// `options`.
3530    ///
3531    /// It is not recommended to send additional writes while a write is already
3532    /// in progress (the server may receive simultaneous writes in any order).
3533    ///
3534    /// + request `handle` The characteristic to be written to.
3535    /// + request `value` The value to be written.
3536    /// + request `options` Options that apply to the write.
3537    /// - response An empty response will be sent when a success response is
3538    ///            received from the server (or immediately if
3539    ///            `options.with_response` is false)
3540    /// * error Returns `INVALID_HANDLE` if `handle` is invalid.
3541    /// * error Returns `INVALID_PARAMETERS` if `options` is invalid.
3542    /// * error Returns `WRITE_NOT_PERMITTED` or `INSUFFICIENT_*`if the server
3543    ///         rejects the write request with a reason.
3544    /// * error Returns `FAILURE` if the server returns an error.
3545    WriteCharacteristic {
3546        handle: Handle,
3547        value: Vec<u8>,
3548        options: WriteOptions,
3549        responder: RemoteServiceWriteCharacteristicResponder,
3550    },
3551    /// Reads the value of the characteristic descriptor with `handle` and
3552    /// returns it in the reply.
3553    ///
3554    /// + request `handle` The descriptor handle to read.
3555    /// + request `options` Options that apply to the read.
3556    /// - response `value` The value of the descriptor.
3557    /// * error Returns `INVALID_HANDLE` if `handle` is invalid.
3558    /// * error Returns `INVALID_PARAMETERS` if `options` is invalid.
3559    /// * error Returns `READ_NOT_PERMITTED` or `INSUFFICIENT_*` if the server
3560    ///         rejects the read request.
3561    /// * error Returns `FAILURE` if the server returns an error.
3562    ReadDescriptor {
3563        handle: Handle,
3564        options: ReadOptions,
3565        responder: RemoteServiceReadDescriptorResponder,
3566    },
3567    /// Writes `value` to the characteristic descriptor with `handle`.
3568    /// It is not recommended to send additional writes while a write is already
3569    /// in progress (the server may receive simultaneous writes in any order).
3570    ///
3571    /// + request `handle` The descriptor handle to written to.
3572    /// + request `value` The value to be written.
3573    /// + request `options` Options that apply to the write.
3574    /// - response An empty response will be sent when a success response is
3575    ///            received from the server (or immediately if
3576    ///            `options.with_response` is false)
3577    /// * error Returns `INVALID_HANDLE` if `handle` is invalid or refers to an
3578    ///         internally reserved descriptor type (e.g. the Client
3579    ///         Characteristic Configuration descriptor).
3580    /// * error Returns `INVALID_PARAMETERS` if `options` is invalid.
3581    /// * error Returns `WRITE_NOT_PERMITTED` or `INSUFFICIENT_*` if the server
3582    ///         rejects the write with a reason.
3583    /// * error Returns `FAILURE` if the server returns an error.
3584    WriteDescriptor {
3585        handle: Handle,
3586        value: Vec<u8>,
3587        options: WriteOptions,
3588        responder: RemoteServiceWriteDescriptorResponder,
3589    },
3590    /// Subscribe to notifications & indications from the characteristic with
3591    /// the given `handle`.
3592    ///
3593    /// Either notifications or indications will be enabled depending on
3594    /// characteristic properties. Indications will be preferred if they are
3595    /// supported. This operation fails if the characteristic does not have the
3596    /// "notify" or "indicate" property.
3597    ///
3598    /// A write request will be issued to configure the characteristic for
3599    /// notifications/indications if it contains a Client Characteristic
3600    /// Configuration descriptor. This method fails if an error occurs while
3601    /// writing to the descriptor.
3602    ///
3603    /// On success, the `notifier` protocol can be used to be notified when
3604    /// the peer sends a notification or indication. Indications are
3605    /// automatically confirmed. When the protocol is dropped, the subscription
3606    /// may end if no other local client is receiving notifications.
3607    ///
3608    /// + request `handle` the characteristic handle.
3609    /// + request `notifier` the protocol used for notifications.
3610    /// - response An empty response will be sent immediately if registration
3611    ///            succeeds.
3612    /// * error Returns a `FAILURE` if the characteristic does not support
3613    ///         notifications or indications.
3614    /// * error Returns a `INVALID_HANDLE` if `handle` is invalid.
3615    /// * error Returns a `WRITE_NOT_PERMITTED`  or `INSUFFICIENT_*`for a
3616    ///         descriptor write error.
3617    RegisterCharacteristicNotifier {
3618        handle: Handle,
3619        notifier: fidl::endpoints::ClientEnd<CharacteristicNotifierMarker>,
3620        responder: RemoteServiceRegisterCharacteristicNotifierResponder,
3621    },
3622}
3623
3624impl RemoteServiceRequest {
3625    #[allow(irrefutable_let_patterns)]
3626    pub fn into_discover_characteristics(
3627        self,
3628    ) -> Option<(RemoteServiceDiscoverCharacteristicsResponder)> {
3629        if let RemoteServiceRequest::DiscoverCharacteristics { responder } = self {
3630            Some((responder))
3631        } else {
3632            None
3633        }
3634    }
3635
3636    #[allow(irrefutable_let_patterns)]
3637    pub fn into_read_by_type(
3638        self,
3639    ) -> Option<(fidl_fuchsia_bluetooth::Uuid, RemoteServiceReadByTypeResponder)> {
3640        if let RemoteServiceRequest::ReadByType { uuid, responder } = self {
3641            Some((uuid, responder))
3642        } else {
3643            None
3644        }
3645    }
3646
3647    #[allow(irrefutable_let_patterns)]
3648    pub fn into_read_characteristic(
3649        self,
3650    ) -> Option<(Handle, ReadOptions, RemoteServiceReadCharacteristicResponder)> {
3651        if let RemoteServiceRequest::ReadCharacteristic { handle, options, responder } = self {
3652            Some((handle, options, responder))
3653        } else {
3654            None
3655        }
3656    }
3657
3658    #[allow(irrefutable_let_patterns)]
3659    pub fn into_write_characteristic(
3660        self,
3661    ) -> Option<(Handle, Vec<u8>, WriteOptions, RemoteServiceWriteCharacteristicResponder)> {
3662        if let RemoteServiceRequest::WriteCharacteristic { handle, value, options, responder } =
3663            self
3664        {
3665            Some((handle, value, options, responder))
3666        } else {
3667            None
3668        }
3669    }
3670
3671    #[allow(irrefutable_let_patterns)]
3672    pub fn into_read_descriptor(
3673        self,
3674    ) -> Option<(Handle, ReadOptions, RemoteServiceReadDescriptorResponder)> {
3675        if let RemoteServiceRequest::ReadDescriptor { handle, options, responder } = self {
3676            Some((handle, options, responder))
3677        } else {
3678            None
3679        }
3680    }
3681
3682    #[allow(irrefutable_let_patterns)]
3683    pub fn into_write_descriptor(
3684        self,
3685    ) -> Option<(Handle, Vec<u8>, WriteOptions, RemoteServiceWriteDescriptorResponder)> {
3686        if let RemoteServiceRequest::WriteDescriptor { handle, value, options, responder } = self {
3687            Some((handle, value, options, responder))
3688        } else {
3689            None
3690        }
3691    }
3692
3693    #[allow(irrefutable_let_patterns)]
3694    pub fn into_register_characteristic_notifier(
3695        self,
3696    ) -> Option<(
3697        Handle,
3698        fidl::endpoints::ClientEnd<CharacteristicNotifierMarker>,
3699        RemoteServiceRegisterCharacteristicNotifierResponder,
3700    )> {
3701        if let RemoteServiceRequest::RegisterCharacteristicNotifier {
3702            handle,
3703            notifier,
3704            responder,
3705        } = self
3706        {
3707            Some((handle, notifier, responder))
3708        } else {
3709            None
3710        }
3711    }
3712
3713    /// Name of the method defined in FIDL
3714    pub fn method_name(&self) -> &'static str {
3715        match *self {
3716            RemoteServiceRequest::DiscoverCharacteristics { .. } => "discover_characteristics",
3717            RemoteServiceRequest::ReadByType { .. } => "read_by_type",
3718            RemoteServiceRequest::ReadCharacteristic { .. } => "read_characteristic",
3719            RemoteServiceRequest::WriteCharacteristic { .. } => "write_characteristic",
3720            RemoteServiceRequest::ReadDescriptor { .. } => "read_descriptor",
3721            RemoteServiceRequest::WriteDescriptor { .. } => "write_descriptor",
3722            RemoteServiceRequest::RegisterCharacteristicNotifier { .. } => {
3723                "register_characteristic_notifier"
3724            }
3725        }
3726    }
3727}
3728
3729#[derive(Debug, Clone)]
3730pub struct RemoteServiceControlHandle {
3731    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3732}
3733
3734impl fidl::endpoints::ControlHandle for RemoteServiceControlHandle {
3735    fn shutdown(&self) {
3736        self.inner.shutdown()
3737    }
3738
3739    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3740        self.inner.shutdown_with_epitaph(status)
3741    }
3742
3743    fn is_closed(&self) -> bool {
3744        self.inner.channel().is_closed()
3745    }
3746    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3747        self.inner.channel().on_closed()
3748    }
3749
3750    #[cfg(target_os = "fuchsia")]
3751    fn signal_peer(
3752        &self,
3753        clear_mask: zx::Signals,
3754        set_mask: zx::Signals,
3755    ) -> Result<(), zx_status::Status> {
3756        use fidl::Peered;
3757        self.inner.channel().signal_peer(clear_mask, set_mask)
3758    }
3759}
3760
3761impl RemoteServiceControlHandle {}
3762
3763#[must_use = "FIDL methods require a response to be sent"]
3764#[derive(Debug)]
3765pub struct RemoteServiceDiscoverCharacteristicsResponder {
3766    control_handle: std::mem::ManuallyDrop<RemoteServiceControlHandle>,
3767    tx_id: u32,
3768}
3769
3770/// Set the the channel to be shutdown (see [`RemoteServiceControlHandle::shutdown`])
3771/// if the responder is dropped without sending a response, so that the client
3772/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3773impl std::ops::Drop for RemoteServiceDiscoverCharacteristicsResponder {
3774    fn drop(&mut self) {
3775        self.control_handle.shutdown();
3776        // Safety: drops once, never accessed again
3777        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3778    }
3779}
3780
3781impl fidl::endpoints::Responder for RemoteServiceDiscoverCharacteristicsResponder {
3782    type ControlHandle = RemoteServiceControlHandle;
3783
3784    fn control_handle(&self) -> &RemoteServiceControlHandle {
3785        &self.control_handle
3786    }
3787
3788    fn drop_without_shutdown(mut self) {
3789        // Safety: drops once, never accessed again due to mem::forget
3790        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3791        // Prevent Drop from running (which would shut down the channel)
3792        std::mem::forget(self);
3793    }
3794}
3795
3796impl RemoteServiceDiscoverCharacteristicsResponder {
3797    /// Sends a response to the FIDL transaction.
3798    ///
3799    /// Sets the channel to shutdown if an error occurs.
3800    pub fn send(self, mut characteristics: &[Characteristic]) -> Result<(), fidl::Error> {
3801        let _result = self.send_raw(characteristics);
3802        if _result.is_err() {
3803            self.control_handle.shutdown();
3804        }
3805        self.drop_without_shutdown();
3806        _result
3807    }
3808
3809    /// Similar to "send" but does not shutdown the channel if an error occurs.
3810    pub fn send_no_shutdown_on_err(
3811        self,
3812        mut characteristics: &[Characteristic],
3813    ) -> Result<(), fidl::Error> {
3814        let _result = self.send_raw(characteristics);
3815        self.drop_without_shutdown();
3816        _result
3817    }
3818
3819    fn send_raw(&self, mut characteristics: &[Characteristic]) -> Result<(), fidl::Error> {
3820        self.control_handle.inner.send::<RemoteServiceDiscoverCharacteristicsResponse>(
3821            (characteristics,),
3822            self.tx_id,
3823            0x6cd730f12e402543,
3824            fidl::encoding::DynamicFlags::empty(),
3825        )
3826    }
3827}
3828
3829#[must_use = "FIDL methods require a response to be sent"]
3830#[derive(Debug)]
3831pub struct RemoteServiceReadByTypeResponder {
3832    control_handle: std::mem::ManuallyDrop<RemoteServiceControlHandle>,
3833    tx_id: u32,
3834}
3835
3836/// Set the the channel to be shutdown (see [`RemoteServiceControlHandle::shutdown`])
3837/// if the responder is dropped without sending a response, so that the client
3838/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3839impl std::ops::Drop for RemoteServiceReadByTypeResponder {
3840    fn drop(&mut self) {
3841        self.control_handle.shutdown();
3842        // Safety: drops once, never accessed again
3843        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3844    }
3845}
3846
3847impl fidl::endpoints::Responder for RemoteServiceReadByTypeResponder {
3848    type ControlHandle = RemoteServiceControlHandle;
3849
3850    fn control_handle(&self) -> &RemoteServiceControlHandle {
3851        &self.control_handle
3852    }
3853
3854    fn drop_without_shutdown(mut self) {
3855        // Safety: drops once, never accessed again due to mem::forget
3856        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3857        // Prevent Drop from running (which would shut down the channel)
3858        std::mem::forget(self);
3859    }
3860}
3861
3862impl RemoteServiceReadByTypeResponder {
3863    /// Sends a response to the FIDL transaction.
3864    ///
3865    /// Sets the channel to shutdown if an error occurs.
3866    pub fn send(self, mut result: Result<&[ReadByTypeResult], Error>) -> Result<(), fidl::Error> {
3867        let _result = self.send_raw(result);
3868        if _result.is_err() {
3869            self.control_handle.shutdown();
3870        }
3871        self.drop_without_shutdown();
3872        _result
3873    }
3874
3875    /// Similar to "send" but does not shutdown the channel if an error occurs.
3876    pub fn send_no_shutdown_on_err(
3877        self,
3878        mut result: Result<&[ReadByTypeResult], Error>,
3879    ) -> Result<(), fidl::Error> {
3880        let _result = self.send_raw(result);
3881        self.drop_without_shutdown();
3882        _result
3883    }
3884
3885    fn send_raw(&self, mut result: Result<&[ReadByTypeResult], Error>) -> Result<(), fidl::Error> {
3886        self.control_handle
3887            .inner
3888            .send::<fidl::encoding::ResultType<RemoteServiceReadByTypeResponse, Error>>(
3889                result.map(|results| (results,)),
3890                self.tx_id,
3891                0x739bb1e313162bbc,
3892                fidl::encoding::DynamicFlags::empty(),
3893            )
3894    }
3895}
3896
3897#[must_use = "FIDL methods require a response to be sent"]
3898#[derive(Debug)]
3899pub struct RemoteServiceReadCharacteristicResponder {
3900    control_handle: std::mem::ManuallyDrop<RemoteServiceControlHandle>,
3901    tx_id: u32,
3902}
3903
3904/// Set the the channel to be shutdown (see [`RemoteServiceControlHandle::shutdown`])
3905/// if the responder is dropped without sending a response, so that the client
3906/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3907impl std::ops::Drop for RemoteServiceReadCharacteristicResponder {
3908    fn drop(&mut self) {
3909        self.control_handle.shutdown();
3910        // Safety: drops once, never accessed again
3911        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3912    }
3913}
3914
3915impl fidl::endpoints::Responder for RemoteServiceReadCharacteristicResponder {
3916    type ControlHandle = RemoteServiceControlHandle;
3917
3918    fn control_handle(&self) -> &RemoteServiceControlHandle {
3919        &self.control_handle
3920    }
3921
3922    fn drop_without_shutdown(mut self) {
3923        // Safety: drops once, never accessed again due to mem::forget
3924        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3925        // Prevent Drop from running (which would shut down the channel)
3926        std::mem::forget(self);
3927    }
3928}
3929
3930impl RemoteServiceReadCharacteristicResponder {
3931    /// Sends a response to the FIDL transaction.
3932    ///
3933    /// Sets the channel to shutdown if an error occurs.
3934    pub fn send(self, mut result: Result<&ReadValue, Error>) -> Result<(), fidl::Error> {
3935        let _result = self.send_raw(result);
3936        if _result.is_err() {
3937            self.control_handle.shutdown();
3938        }
3939        self.drop_without_shutdown();
3940        _result
3941    }
3942
3943    /// Similar to "send" but does not shutdown the channel if an error occurs.
3944    pub fn send_no_shutdown_on_err(
3945        self,
3946        mut result: Result<&ReadValue, Error>,
3947    ) -> Result<(), fidl::Error> {
3948        let _result = self.send_raw(result);
3949        self.drop_without_shutdown();
3950        _result
3951    }
3952
3953    fn send_raw(&self, mut result: Result<&ReadValue, Error>) -> Result<(), fidl::Error> {
3954        self.control_handle.inner.send::<fidl::encoding::ResultType<
3955            RemoteServiceReadCharacteristicResponse,
3956            Error,
3957        >>(
3958            result.map(|value| (value,)),
3959            self.tx_id,
3960            0x4d41757ed69a96cb,
3961            fidl::encoding::DynamicFlags::empty(),
3962        )
3963    }
3964}
3965
3966#[must_use = "FIDL methods require a response to be sent"]
3967#[derive(Debug)]
3968pub struct RemoteServiceWriteCharacteristicResponder {
3969    control_handle: std::mem::ManuallyDrop<RemoteServiceControlHandle>,
3970    tx_id: u32,
3971}
3972
3973/// Set the the channel to be shutdown (see [`RemoteServiceControlHandle::shutdown`])
3974/// if the responder is dropped without sending a response, so that the client
3975/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3976impl std::ops::Drop for RemoteServiceWriteCharacteristicResponder {
3977    fn drop(&mut self) {
3978        self.control_handle.shutdown();
3979        // Safety: drops once, never accessed again
3980        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3981    }
3982}
3983
3984impl fidl::endpoints::Responder for RemoteServiceWriteCharacteristicResponder {
3985    type ControlHandle = RemoteServiceControlHandle;
3986
3987    fn control_handle(&self) -> &RemoteServiceControlHandle {
3988        &self.control_handle
3989    }
3990
3991    fn drop_without_shutdown(mut self) {
3992        // Safety: drops once, never accessed again due to mem::forget
3993        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3994        // Prevent Drop from running (which would shut down the channel)
3995        std::mem::forget(self);
3996    }
3997}
3998
3999impl RemoteServiceWriteCharacteristicResponder {
4000    /// Sends a response to the FIDL transaction.
4001    ///
4002    /// Sets the channel to shutdown if an error occurs.
4003    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4004        let _result = self.send_raw(result);
4005        if _result.is_err() {
4006            self.control_handle.shutdown();
4007        }
4008        self.drop_without_shutdown();
4009        _result
4010    }
4011
4012    /// Similar to "send" but does not shutdown the channel if an error occurs.
4013    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4014        let _result = self.send_raw(result);
4015        self.drop_without_shutdown();
4016        _result
4017    }
4018
4019    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4020        self.control_handle
4021            .inner
4022            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
4023                result,
4024                self.tx_id,
4025                0x7fc7511adecde8c,
4026                fidl::encoding::DynamicFlags::empty(),
4027            )
4028    }
4029}
4030
4031#[must_use = "FIDL methods require a response to be sent"]
4032#[derive(Debug)]
4033pub struct RemoteServiceReadDescriptorResponder {
4034    control_handle: std::mem::ManuallyDrop<RemoteServiceControlHandle>,
4035    tx_id: u32,
4036}
4037
4038/// Set the the channel to be shutdown (see [`RemoteServiceControlHandle::shutdown`])
4039/// if the responder is dropped without sending a response, so that the client
4040/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4041impl std::ops::Drop for RemoteServiceReadDescriptorResponder {
4042    fn drop(&mut self) {
4043        self.control_handle.shutdown();
4044        // Safety: drops once, never accessed again
4045        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4046    }
4047}
4048
4049impl fidl::endpoints::Responder for RemoteServiceReadDescriptorResponder {
4050    type ControlHandle = RemoteServiceControlHandle;
4051
4052    fn control_handle(&self) -> &RemoteServiceControlHandle {
4053        &self.control_handle
4054    }
4055
4056    fn drop_without_shutdown(mut self) {
4057        // Safety: drops once, never accessed again due to mem::forget
4058        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4059        // Prevent Drop from running (which would shut down the channel)
4060        std::mem::forget(self);
4061    }
4062}
4063
4064impl RemoteServiceReadDescriptorResponder {
4065    /// Sends a response to the FIDL transaction.
4066    ///
4067    /// Sets the channel to shutdown if an error occurs.
4068    pub fn send(self, mut result: Result<&ReadValue, Error>) -> Result<(), fidl::Error> {
4069        let _result = self.send_raw(result);
4070        if _result.is_err() {
4071            self.control_handle.shutdown();
4072        }
4073        self.drop_without_shutdown();
4074        _result
4075    }
4076
4077    /// Similar to "send" but does not shutdown the channel if an error occurs.
4078    pub fn send_no_shutdown_on_err(
4079        self,
4080        mut result: Result<&ReadValue, Error>,
4081    ) -> Result<(), fidl::Error> {
4082        let _result = self.send_raw(result);
4083        self.drop_without_shutdown();
4084        _result
4085    }
4086
4087    fn send_raw(&self, mut result: Result<&ReadValue, Error>) -> Result<(), fidl::Error> {
4088        self.control_handle.inner.send::<fidl::encoding::ResultType<
4089            RemoteServiceReadDescriptorResponse,
4090            Error,
4091        >>(
4092            result.map(|value| (value,)),
4093            self.tx_id,
4094            0x7ed7ce00457dcec1,
4095            fidl::encoding::DynamicFlags::empty(),
4096        )
4097    }
4098}
4099
4100#[must_use = "FIDL methods require a response to be sent"]
4101#[derive(Debug)]
4102pub struct RemoteServiceWriteDescriptorResponder {
4103    control_handle: std::mem::ManuallyDrop<RemoteServiceControlHandle>,
4104    tx_id: u32,
4105}
4106
4107/// Set the the channel to be shutdown (see [`RemoteServiceControlHandle::shutdown`])
4108/// if the responder is dropped without sending a response, so that the client
4109/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4110impl std::ops::Drop for RemoteServiceWriteDescriptorResponder {
4111    fn drop(&mut self) {
4112        self.control_handle.shutdown();
4113        // Safety: drops once, never accessed again
4114        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4115    }
4116}
4117
4118impl fidl::endpoints::Responder for RemoteServiceWriteDescriptorResponder {
4119    type ControlHandle = RemoteServiceControlHandle;
4120
4121    fn control_handle(&self) -> &RemoteServiceControlHandle {
4122        &self.control_handle
4123    }
4124
4125    fn drop_without_shutdown(mut self) {
4126        // Safety: drops once, never accessed again due to mem::forget
4127        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4128        // Prevent Drop from running (which would shut down the channel)
4129        std::mem::forget(self);
4130    }
4131}
4132
4133impl RemoteServiceWriteDescriptorResponder {
4134    /// Sends a response to the FIDL transaction.
4135    ///
4136    /// Sets the channel to shutdown if an error occurs.
4137    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4138        let _result = self.send_raw(result);
4139        if _result.is_err() {
4140            self.control_handle.shutdown();
4141        }
4142        self.drop_without_shutdown();
4143        _result
4144    }
4145
4146    /// Similar to "send" but does not shutdown the channel if an error occurs.
4147    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4148        let _result = self.send_raw(result);
4149        self.drop_without_shutdown();
4150        _result
4151    }
4152
4153    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4154        self.control_handle
4155            .inner
4156            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
4157                result,
4158                self.tx_id,
4159                0x21d9106bfd6b7351,
4160                fidl::encoding::DynamicFlags::empty(),
4161            )
4162    }
4163}
4164
4165#[must_use = "FIDL methods require a response to be sent"]
4166#[derive(Debug)]
4167pub struct RemoteServiceRegisterCharacteristicNotifierResponder {
4168    control_handle: std::mem::ManuallyDrop<RemoteServiceControlHandle>,
4169    tx_id: u32,
4170}
4171
4172/// Set the the channel to be shutdown (see [`RemoteServiceControlHandle::shutdown`])
4173/// if the responder is dropped without sending a response, so that the client
4174/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4175impl std::ops::Drop for RemoteServiceRegisterCharacteristicNotifierResponder {
4176    fn drop(&mut self) {
4177        self.control_handle.shutdown();
4178        // Safety: drops once, never accessed again
4179        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4180    }
4181}
4182
4183impl fidl::endpoints::Responder for RemoteServiceRegisterCharacteristicNotifierResponder {
4184    type ControlHandle = RemoteServiceControlHandle;
4185
4186    fn control_handle(&self) -> &RemoteServiceControlHandle {
4187        &self.control_handle
4188    }
4189
4190    fn drop_without_shutdown(mut self) {
4191        // Safety: drops once, never accessed again due to mem::forget
4192        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4193        // Prevent Drop from running (which would shut down the channel)
4194        std::mem::forget(self);
4195    }
4196}
4197
4198impl RemoteServiceRegisterCharacteristicNotifierResponder {
4199    /// Sends a response to the FIDL transaction.
4200    ///
4201    /// Sets the channel to shutdown if an error occurs.
4202    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4203        let _result = self.send_raw(result);
4204        if _result.is_err() {
4205            self.control_handle.shutdown();
4206        }
4207        self.drop_without_shutdown();
4208        _result
4209    }
4210
4211    /// Similar to "send" but does not shutdown the channel if an error occurs.
4212    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4213        let _result = self.send_raw(result);
4214        self.drop_without_shutdown();
4215        _result
4216    }
4217
4218    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4219        self.control_handle
4220            .inner
4221            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
4222                result,
4223                self.tx_id,
4224                0x35007a85245f5cc6,
4225                fidl::encoding::DynamicFlags::empty(),
4226            )
4227    }
4228}
4229
4230#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4231pub struct Server_Marker;
4232
4233impl fidl::endpoints::ProtocolMarker for Server_Marker {
4234    type Proxy = Server_Proxy;
4235    type RequestStream = Server_RequestStream;
4236    #[cfg(target_os = "fuchsia")]
4237    type SynchronousProxy = Server_SynchronousProxy;
4238
4239    const DEBUG_NAME: &'static str = "fuchsia.bluetooth.gatt2.Server";
4240}
4241impl fidl::endpoints::DiscoverableProtocolMarker for Server_Marker {}
4242pub type ServerPublishServiceResult = Result<(), PublishServiceError>;
4243
4244pub trait Server_ProxyInterface: Send + Sync {
4245    type PublishServiceResponseFut: std::future::Future<Output = Result<ServerPublishServiceResult, fidl::Error>>
4246        + Send;
4247    fn r#publish_service(
4248        &self,
4249        info: &ServiceInfo,
4250        service: fidl::endpoints::ClientEnd<LocalServiceMarker>,
4251    ) -> Self::PublishServiceResponseFut;
4252}
4253#[derive(Debug)]
4254#[cfg(target_os = "fuchsia")]
4255pub struct Server_SynchronousProxy {
4256    client: fidl::client::sync::Client,
4257}
4258
4259#[cfg(target_os = "fuchsia")]
4260impl fidl::endpoints::SynchronousProxy for Server_SynchronousProxy {
4261    type Proxy = Server_Proxy;
4262    type Protocol = Server_Marker;
4263
4264    fn from_channel(inner: fidl::Channel) -> Self {
4265        Self::new(inner)
4266    }
4267
4268    fn into_channel(self) -> fidl::Channel {
4269        self.client.into_channel()
4270    }
4271
4272    fn as_channel(&self) -> &fidl::Channel {
4273        self.client.as_channel()
4274    }
4275}
4276
4277#[cfg(target_os = "fuchsia")]
4278impl Server_SynchronousProxy {
4279    pub fn new(channel: fidl::Channel) -> Self {
4280        let protocol_name = <Server_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4281        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
4282    }
4283
4284    pub fn into_channel(self) -> fidl::Channel {
4285        self.client.into_channel()
4286    }
4287
4288    /// Waits until an event arrives and returns it. It is safe for other
4289    /// threads to make concurrent requests while waiting for an event.
4290    pub fn wait_for_event(
4291        &self,
4292        deadline: zx::MonotonicInstant,
4293    ) -> Result<Server_Event, fidl::Error> {
4294        Server_Event::decode(self.client.wait_for_event(deadline)?)
4295    }
4296
4297    /// Publishes the given `service` so that it is available to all remote peers. Upon publication,
4298    /// the service is defined to have INITIAL_VALUE_CHANGED_CREDITS credits available for sending
4299    /// indications/notifications.
4300    ///
4301    /// The caller must assign distinct handles to the characteristics and descriptors listed in
4302    /// `info`. These identifiers will be used in requests sent to `service`.
4303    ///
4304    /// + request `info` Defines the structure of the GATT service. Includes characteristics and
4305    ///   descriptors that will be made available to peers, as well as the service handle, which is
4306    ///   required to be unique across all services published to this Server.
4307    /// + request `service` Provides the implementation of the service per the documented behavior
4308    ///   of a `LocalService`.
4309    /// - response An empty response indicates the service was successfully published.
4310    /// * error See `gatt2.PublishServiceError` for possible failure modes.
4311    pub fn r#publish_service(
4312        &self,
4313        mut info: &ServiceInfo,
4314        mut service: fidl::endpoints::ClientEnd<LocalServiceMarker>,
4315        ___deadline: zx::MonotonicInstant,
4316    ) -> Result<ServerPublishServiceResult, fidl::Error> {
4317        let _response =
4318            self.client.send_query::<ServerPublishServiceRequest, fidl::encoding::ResultType<
4319                fidl::encoding::EmptyStruct,
4320                PublishServiceError,
4321            >>(
4322                (info, service),
4323                0x3110442f2077bfe2,
4324                fidl::encoding::DynamicFlags::empty(),
4325                ___deadline,
4326            )?;
4327        Ok(_response.map(|x| x))
4328    }
4329}
4330
4331#[cfg(target_os = "fuchsia")]
4332impl From<Server_SynchronousProxy> for zx::NullableHandle {
4333    fn from(value: Server_SynchronousProxy) -> Self {
4334        value.into_channel().into()
4335    }
4336}
4337
4338#[cfg(target_os = "fuchsia")]
4339impl From<fidl::Channel> for Server_SynchronousProxy {
4340    fn from(value: fidl::Channel) -> Self {
4341        Self::new(value)
4342    }
4343}
4344
4345#[cfg(target_os = "fuchsia")]
4346impl fidl::endpoints::FromClient for Server_SynchronousProxy {
4347    type Protocol = Server_Marker;
4348
4349    fn from_client(value: fidl::endpoints::ClientEnd<Server_Marker>) -> Self {
4350        Self::new(value.into_channel())
4351    }
4352}
4353
4354#[derive(Debug, Clone)]
4355pub struct Server_Proxy {
4356    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4357}
4358
4359impl fidl::endpoints::Proxy for Server_Proxy {
4360    type Protocol = Server_Marker;
4361
4362    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4363        Self::new(inner)
4364    }
4365
4366    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4367        self.client.into_channel().map_err(|client| Self { client })
4368    }
4369
4370    fn as_channel(&self) -> &::fidl::AsyncChannel {
4371        self.client.as_channel()
4372    }
4373}
4374
4375impl Server_Proxy {
4376    /// Create a new Proxy for fuchsia.bluetooth.gatt2/Server.
4377    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4378        let protocol_name = <Server_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4379        Self { client: fidl::client::Client::new(channel, protocol_name) }
4380    }
4381
4382    /// Get a Stream of events from the remote end of the protocol.
4383    ///
4384    /// # Panics
4385    ///
4386    /// Panics if the event stream was already taken.
4387    pub fn take_event_stream(&self) -> Server_EventStream {
4388        Server_EventStream { event_receiver: self.client.take_event_receiver() }
4389    }
4390
4391    /// Publishes the given `service` so that it is available to all remote peers. Upon publication,
4392    /// the service is defined to have INITIAL_VALUE_CHANGED_CREDITS credits available for sending
4393    /// indications/notifications.
4394    ///
4395    /// The caller must assign distinct handles to the characteristics and descriptors listed in
4396    /// `info`. These identifiers will be used in requests sent to `service`.
4397    ///
4398    /// + request `info` Defines the structure of the GATT service. Includes characteristics and
4399    ///   descriptors that will be made available to peers, as well as the service handle, which is
4400    ///   required to be unique across all services published to this Server.
4401    /// + request `service` Provides the implementation of the service per the documented behavior
4402    ///   of a `LocalService`.
4403    /// - response An empty response indicates the service was successfully published.
4404    /// * error See `gatt2.PublishServiceError` for possible failure modes.
4405    pub fn r#publish_service(
4406        &self,
4407        mut info: &ServiceInfo,
4408        mut service: fidl::endpoints::ClientEnd<LocalServiceMarker>,
4409    ) -> fidl::client::QueryResponseFut<
4410        ServerPublishServiceResult,
4411        fidl::encoding::DefaultFuchsiaResourceDialect,
4412    > {
4413        Server_ProxyInterface::r#publish_service(self, info, service)
4414    }
4415}
4416
4417impl Server_ProxyInterface for Server_Proxy {
4418    type PublishServiceResponseFut = fidl::client::QueryResponseFut<
4419        ServerPublishServiceResult,
4420        fidl::encoding::DefaultFuchsiaResourceDialect,
4421    >;
4422    fn r#publish_service(
4423        &self,
4424        mut info: &ServiceInfo,
4425        mut service: fidl::endpoints::ClientEnd<LocalServiceMarker>,
4426    ) -> Self::PublishServiceResponseFut {
4427        fn _decode(
4428            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4429        ) -> Result<ServerPublishServiceResult, fidl::Error> {
4430            let _response = fidl::client::decode_transaction_body::<
4431                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PublishServiceError>,
4432                fidl::encoding::DefaultFuchsiaResourceDialect,
4433                0x3110442f2077bfe2,
4434            >(_buf?)?;
4435            Ok(_response.map(|x| x))
4436        }
4437        self.client
4438            .send_query_and_decode::<ServerPublishServiceRequest, ServerPublishServiceResult>(
4439                (info, service),
4440                0x3110442f2077bfe2,
4441                fidl::encoding::DynamicFlags::empty(),
4442                _decode,
4443            )
4444    }
4445}
4446
4447pub struct Server_EventStream {
4448    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4449}
4450
4451impl std::marker::Unpin for Server_EventStream {}
4452
4453impl futures::stream::FusedStream for Server_EventStream {
4454    fn is_terminated(&self) -> bool {
4455        self.event_receiver.is_terminated()
4456    }
4457}
4458
4459impl futures::Stream for Server_EventStream {
4460    type Item = Result<Server_Event, fidl::Error>;
4461
4462    fn poll_next(
4463        mut self: std::pin::Pin<&mut Self>,
4464        cx: &mut std::task::Context<'_>,
4465    ) -> std::task::Poll<Option<Self::Item>> {
4466        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4467            &mut self.event_receiver,
4468            cx
4469        )?) {
4470            Some(buf) => std::task::Poll::Ready(Some(Server_Event::decode(buf))),
4471            None => std::task::Poll::Ready(None),
4472        }
4473    }
4474}
4475
4476#[derive(Debug)]
4477pub enum Server_Event {}
4478
4479impl Server_Event {
4480    /// Decodes a message buffer as a [`Server_Event`].
4481    fn decode(
4482        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4483    ) -> Result<Server_Event, fidl::Error> {
4484        let (bytes, _handles) = buf.split_mut();
4485        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4486        debug_assert_eq!(tx_header.tx_id, 0);
4487        match tx_header.ordinal {
4488            _ => Err(fidl::Error::UnknownOrdinal {
4489                ordinal: tx_header.ordinal,
4490                protocol_name: <Server_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4491            }),
4492        }
4493    }
4494}
4495
4496/// A Stream of incoming requests for fuchsia.bluetooth.gatt2/Server.
4497pub struct Server_RequestStream {
4498    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4499    is_terminated: bool,
4500}
4501
4502impl std::marker::Unpin for Server_RequestStream {}
4503
4504impl futures::stream::FusedStream for Server_RequestStream {
4505    fn is_terminated(&self) -> bool {
4506        self.is_terminated
4507    }
4508}
4509
4510impl fidl::endpoints::RequestStream for Server_RequestStream {
4511    type Protocol = Server_Marker;
4512    type ControlHandle = Server_ControlHandle;
4513
4514    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4515        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4516    }
4517
4518    fn control_handle(&self) -> Self::ControlHandle {
4519        Server_ControlHandle { inner: self.inner.clone() }
4520    }
4521
4522    fn into_inner(
4523        self,
4524    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4525    {
4526        (self.inner, self.is_terminated)
4527    }
4528
4529    fn from_inner(
4530        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4531        is_terminated: bool,
4532    ) -> Self {
4533        Self { inner, is_terminated }
4534    }
4535}
4536
4537impl futures::Stream for Server_RequestStream {
4538    type Item = Result<Server_Request, fidl::Error>;
4539
4540    fn poll_next(
4541        mut self: std::pin::Pin<&mut Self>,
4542        cx: &mut std::task::Context<'_>,
4543    ) -> std::task::Poll<Option<Self::Item>> {
4544        let this = &mut *self;
4545        if this.inner.check_shutdown(cx) {
4546            this.is_terminated = true;
4547            return std::task::Poll::Ready(None);
4548        }
4549        if this.is_terminated {
4550            panic!("polled Server_RequestStream after completion");
4551        }
4552        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4553            |bytes, handles| {
4554                match this.inner.channel().read_etc(cx, bytes, handles) {
4555                    std::task::Poll::Ready(Ok(())) => {}
4556                    std::task::Poll::Pending => return std::task::Poll::Pending,
4557                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4558                        this.is_terminated = true;
4559                        return std::task::Poll::Ready(None);
4560                    }
4561                    std::task::Poll::Ready(Err(e)) => {
4562                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4563                            e.into(),
4564                        ))));
4565                    }
4566                }
4567
4568                // A message has been received from the channel
4569                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4570
4571                std::task::Poll::Ready(Some(match header.ordinal {
4572                    0x3110442f2077bfe2 => {
4573                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4574                        let mut req = fidl::new_empty!(
4575                            ServerPublishServiceRequest,
4576                            fidl::encoding::DefaultFuchsiaResourceDialect
4577                        );
4578                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ServerPublishServiceRequest>(&header, _body_bytes, handles, &mut req)?;
4579                        let control_handle = Server_ControlHandle { inner: this.inner.clone() };
4580                        Ok(Server_Request::PublishService {
4581                            info: req.info,
4582                            service: req.service,
4583
4584                            responder: Server_PublishServiceResponder {
4585                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4586                                tx_id: header.tx_id,
4587                            },
4588                        })
4589                    }
4590                    _ => Err(fidl::Error::UnknownOrdinal {
4591                        ordinal: header.ordinal,
4592                        protocol_name:
4593                            <Server_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4594                    }),
4595                }))
4596            },
4597        )
4598    }
4599}
4600
4601#[derive(Debug)]
4602pub enum Server_Request {
4603    /// Publishes the given `service` so that it is available to all remote peers. Upon publication,
4604    /// the service is defined to have INITIAL_VALUE_CHANGED_CREDITS credits available for sending
4605    /// indications/notifications.
4606    ///
4607    /// The caller must assign distinct handles to the characteristics and descriptors listed in
4608    /// `info`. These identifiers will be used in requests sent to `service`.
4609    ///
4610    /// + request `info` Defines the structure of the GATT service. Includes characteristics and
4611    ///   descriptors that will be made available to peers, as well as the service handle, which is
4612    ///   required to be unique across all services published to this Server.
4613    /// + request `service` Provides the implementation of the service per the documented behavior
4614    ///   of a `LocalService`.
4615    /// - response An empty response indicates the service was successfully published.
4616    /// * error See `gatt2.PublishServiceError` for possible failure modes.
4617    PublishService {
4618        info: ServiceInfo,
4619        service: fidl::endpoints::ClientEnd<LocalServiceMarker>,
4620        responder: Server_PublishServiceResponder,
4621    },
4622}
4623
4624impl Server_Request {
4625    #[allow(irrefutable_let_patterns)]
4626    pub fn into_publish_service(
4627        self,
4628    ) -> Option<(
4629        ServiceInfo,
4630        fidl::endpoints::ClientEnd<LocalServiceMarker>,
4631        Server_PublishServiceResponder,
4632    )> {
4633        if let Server_Request::PublishService { info, service, responder } = self {
4634            Some((info, service, responder))
4635        } else {
4636            None
4637        }
4638    }
4639
4640    /// Name of the method defined in FIDL
4641    pub fn method_name(&self) -> &'static str {
4642        match *self {
4643            Server_Request::PublishService { .. } => "publish_service",
4644        }
4645    }
4646}
4647
4648#[derive(Debug, Clone)]
4649pub struct Server_ControlHandle {
4650    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4651}
4652
4653impl fidl::endpoints::ControlHandle for Server_ControlHandle {
4654    fn shutdown(&self) {
4655        self.inner.shutdown()
4656    }
4657
4658    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4659        self.inner.shutdown_with_epitaph(status)
4660    }
4661
4662    fn is_closed(&self) -> bool {
4663        self.inner.channel().is_closed()
4664    }
4665    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4666        self.inner.channel().on_closed()
4667    }
4668
4669    #[cfg(target_os = "fuchsia")]
4670    fn signal_peer(
4671        &self,
4672        clear_mask: zx::Signals,
4673        set_mask: zx::Signals,
4674    ) -> Result<(), zx_status::Status> {
4675        use fidl::Peered;
4676        self.inner.channel().signal_peer(clear_mask, set_mask)
4677    }
4678}
4679
4680impl Server_ControlHandle {}
4681
4682#[must_use = "FIDL methods require a response to be sent"]
4683#[derive(Debug)]
4684pub struct Server_PublishServiceResponder {
4685    control_handle: std::mem::ManuallyDrop<Server_ControlHandle>,
4686    tx_id: u32,
4687}
4688
4689/// Set the the channel to be shutdown (see [`Server_ControlHandle::shutdown`])
4690/// if the responder is dropped without sending a response, so that the client
4691/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4692impl std::ops::Drop for Server_PublishServiceResponder {
4693    fn drop(&mut self) {
4694        self.control_handle.shutdown();
4695        // Safety: drops once, never accessed again
4696        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4697    }
4698}
4699
4700impl fidl::endpoints::Responder for Server_PublishServiceResponder {
4701    type ControlHandle = Server_ControlHandle;
4702
4703    fn control_handle(&self) -> &Server_ControlHandle {
4704        &self.control_handle
4705    }
4706
4707    fn drop_without_shutdown(mut self) {
4708        // Safety: drops once, never accessed again due to mem::forget
4709        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4710        // Prevent Drop from running (which would shut down the channel)
4711        std::mem::forget(self);
4712    }
4713}
4714
4715impl Server_PublishServiceResponder {
4716    /// Sends a response to the FIDL transaction.
4717    ///
4718    /// Sets the channel to shutdown if an error occurs.
4719    pub fn send(self, mut result: Result<(), PublishServiceError>) -> Result<(), fidl::Error> {
4720        let _result = self.send_raw(result);
4721        if _result.is_err() {
4722            self.control_handle.shutdown();
4723        }
4724        self.drop_without_shutdown();
4725        _result
4726    }
4727
4728    /// Similar to "send" but does not shutdown the channel if an error occurs.
4729    pub fn send_no_shutdown_on_err(
4730        self,
4731        mut result: Result<(), PublishServiceError>,
4732    ) -> Result<(), fidl::Error> {
4733        let _result = self.send_raw(result);
4734        self.drop_without_shutdown();
4735        _result
4736    }
4737
4738    fn send_raw(&self, mut result: Result<(), PublishServiceError>) -> Result<(), fidl::Error> {
4739        self.control_handle.inner.send::<fidl::encoding::ResultType<
4740            fidl::encoding::EmptyStruct,
4741            PublishServiceError,
4742        >>(
4743            result,
4744            self.tx_id,
4745            0x3110442f2077bfe2,
4746            fidl::encoding::DynamicFlags::empty(),
4747        )
4748    }
4749}
4750
4751mod internal {
4752    use super::*;
4753
4754    impl fidl::encoding::ResourceTypeMarker for ClientConnectToServiceRequest {
4755        type Borrowed<'a> = &'a mut Self;
4756        fn take_or_borrow<'a>(
4757            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4758        ) -> Self::Borrowed<'a> {
4759            value
4760        }
4761    }
4762
4763    unsafe impl fidl::encoding::TypeMarker for ClientConnectToServiceRequest {
4764        type Owned = Self;
4765
4766        #[inline(always)]
4767        fn inline_align(_context: fidl::encoding::Context) -> usize {
4768            8
4769        }
4770
4771        #[inline(always)]
4772        fn inline_size(_context: fidl::encoding::Context) -> usize {
4773            16
4774        }
4775    }
4776
4777    unsafe impl
4778        fidl::encoding::Encode<
4779            ClientConnectToServiceRequest,
4780            fidl::encoding::DefaultFuchsiaResourceDialect,
4781        > for &mut ClientConnectToServiceRequest
4782    {
4783        #[inline]
4784        unsafe fn encode(
4785            self,
4786            encoder: &mut fidl::encoding::Encoder<
4787                '_,
4788                fidl::encoding::DefaultFuchsiaResourceDialect,
4789            >,
4790            offset: usize,
4791            _depth: fidl::encoding::Depth,
4792        ) -> fidl::Result<()> {
4793            encoder.debug_check_bounds::<ClientConnectToServiceRequest>(offset);
4794            // Delegate to tuple encoding.
4795            fidl::encoding::Encode::<ClientConnectToServiceRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
4796                (
4797                    <ServiceHandle as fidl::encoding::ValueTypeMarker>::borrow(&self.handle),
4798                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RemoteServiceMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.service),
4799                ),
4800                encoder, offset, _depth
4801            )
4802        }
4803    }
4804    unsafe impl<
4805        T0: fidl::encoding::Encode<ServiceHandle, fidl::encoding::DefaultFuchsiaResourceDialect>,
4806        T1: fidl::encoding::Encode<
4807                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RemoteServiceMarker>>,
4808                fidl::encoding::DefaultFuchsiaResourceDialect,
4809            >,
4810    >
4811        fidl::encoding::Encode<
4812            ClientConnectToServiceRequest,
4813            fidl::encoding::DefaultFuchsiaResourceDialect,
4814        > for (T0, T1)
4815    {
4816        #[inline]
4817        unsafe fn encode(
4818            self,
4819            encoder: &mut fidl::encoding::Encoder<
4820                '_,
4821                fidl::encoding::DefaultFuchsiaResourceDialect,
4822            >,
4823            offset: usize,
4824            depth: fidl::encoding::Depth,
4825        ) -> fidl::Result<()> {
4826            encoder.debug_check_bounds::<ClientConnectToServiceRequest>(offset);
4827            // Zero out padding regions. There's no need to apply masks
4828            // because the unmasked parts will be overwritten by fields.
4829            unsafe {
4830                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
4831                (ptr as *mut u64).write_unaligned(0);
4832            }
4833            // Write the fields.
4834            self.0.encode(encoder, offset + 0, depth)?;
4835            self.1.encode(encoder, offset + 8, depth)?;
4836            Ok(())
4837        }
4838    }
4839
4840    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4841        for ClientConnectToServiceRequest
4842    {
4843        #[inline(always)]
4844        fn new_empty() -> Self {
4845            Self {
4846                handle: fidl::new_empty!(
4847                    ServiceHandle,
4848                    fidl::encoding::DefaultFuchsiaResourceDialect
4849                ),
4850                service: fidl::new_empty!(
4851                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RemoteServiceMarker>>,
4852                    fidl::encoding::DefaultFuchsiaResourceDialect
4853                ),
4854            }
4855        }
4856
4857        #[inline]
4858        unsafe fn decode(
4859            &mut self,
4860            decoder: &mut fidl::encoding::Decoder<
4861                '_,
4862                fidl::encoding::DefaultFuchsiaResourceDialect,
4863            >,
4864            offset: usize,
4865            _depth: fidl::encoding::Depth,
4866        ) -> fidl::Result<()> {
4867            decoder.debug_check_bounds::<Self>(offset);
4868            // Verify that padding bytes are zero.
4869            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
4870            let padval = unsafe { (ptr as *const u64).read_unaligned() };
4871            let mask = 0xffffffff00000000u64;
4872            let maskedval = padval & mask;
4873            if maskedval != 0 {
4874                return Err(fidl::Error::NonZeroPadding {
4875                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
4876                });
4877            }
4878            fidl::decode!(
4879                ServiceHandle,
4880                fidl::encoding::DefaultFuchsiaResourceDialect,
4881                &mut self.handle,
4882                decoder,
4883                offset + 0,
4884                _depth
4885            )?;
4886            fidl::decode!(
4887                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RemoteServiceMarker>>,
4888                fidl::encoding::DefaultFuchsiaResourceDialect,
4889                &mut self.service,
4890                decoder,
4891                offset + 8,
4892                _depth
4893            )?;
4894            Ok(())
4895        }
4896    }
4897
4898    impl fidl::encoding::ResourceTypeMarker for LocalServiceOnIndicateValueRequest {
4899        type Borrowed<'a> = &'a mut Self;
4900        fn take_or_borrow<'a>(
4901            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4902        ) -> Self::Borrowed<'a> {
4903            value
4904        }
4905    }
4906
4907    unsafe impl fidl::encoding::TypeMarker for LocalServiceOnIndicateValueRequest {
4908        type Owned = Self;
4909
4910        #[inline(always)]
4911        fn inline_align(_context: fidl::encoding::Context) -> usize {
4912            8
4913        }
4914
4915        #[inline(always)]
4916        fn inline_size(_context: fidl::encoding::Context) -> usize {
4917            24
4918        }
4919    }
4920
4921    unsafe impl
4922        fidl::encoding::Encode<
4923            LocalServiceOnIndicateValueRequest,
4924            fidl::encoding::DefaultFuchsiaResourceDialect,
4925        > for &mut LocalServiceOnIndicateValueRequest
4926    {
4927        #[inline]
4928        unsafe fn encode(
4929            self,
4930            encoder: &mut fidl::encoding::Encoder<
4931                '_,
4932                fidl::encoding::DefaultFuchsiaResourceDialect,
4933            >,
4934            offset: usize,
4935            _depth: fidl::encoding::Depth,
4936        ) -> fidl::Result<()> {
4937            encoder.debug_check_bounds::<LocalServiceOnIndicateValueRequest>(offset);
4938            // Delegate to tuple encoding.
4939            fidl::encoding::Encode::<
4940                LocalServiceOnIndicateValueRequest,
4941                fidl::encoding::DefaultFuchsiaResourceDialect,
4942            >::encode(
4943                (
4944                    <ValueChangedParameters as fidl::encoding::ValueTypeMarker>::borrow(
4945                        &self.update,
4946                    ),
4947                    <fidl::encoding::HandleType<
4948                        fidl::EventPair,
4949                        { fidl::ObjectType::EVENTPAIR.into_raw() },
4950                        2147483648,
4951                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4952                        &mut self.confirmation,
4953                    ),
4954                ),
4955                encoder,
4956                offset,
4957                _depth,
4958            )
4959        }
4960    }
4961    unsafe impl<
4962        T0: fidl::encoding::Encode<
4963                ValueChangedParameters,
4964                fidl::encoding::DefaultFuchsiaResourceDialect,
4965            >,
4966        T1: fidl::encoding::Encode<
4967                fidl::encoding::HandleType<
4968                    fidl::EventPair,
4969                    { fidl::ObjectType::EVENTPAIR.into_raw() },
4970                    2147483648,
4971                >,
4972                fidl::encoding::DefaultFuchsiaResourceDialect,
4973            >,
4974    >
4975        fidl::encoding::Encode<
4976            LocalServiceOnIndicateValueRequest,
4977            fidl::encoding::DefaultFuchsiaResourceDialect,
4978        > for (T0, T1)
4979    {
4980        #[inline]
4981        unsafe fn encode(
4982            self,
4983            encoder: &mut fidl::encoding::Encoder<
4984                '_,
4985                fidl::encoding::DefaultFuchsiaResourceDialect,
4986            >,
4987            offset: usize,
4988            depth: fidl::encoding::Depth,
4989        ) -> fidl::Result<()> {
4990            encoder.debug_check_bounds::<LocalServiceOnIndicateValueRequest>(offset);
4991            // Zero out padding regions. There's no need to apply masks
4992            // because the unmasked parts will be overwritten by fields.
4993            unsafe {
4994                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
4995                (ptr as *mut u64).write_unaligned(0);
4996            }
4997            // Write the fields.
4998            self.0.encode(encoder, offset + 0, depth)?;
4999            self.1.encode(encoder, offset + 16, depth)?;
5000            Ok(())
5001        }
5002    }
5003
5004    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5005        for LocalServiceOnIndicateValueRequest
5006    {
5007        #[inline(always)]
5008        fn new_empty() -> Self {
5009            Self {
5010                update: fidl::new_empty!(
5011                    ValueChangedParameters,
5012                    fidl::encoding::DefaultFuchsiaResourceDialect
5013                ),
5014                confirmation: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
5015            }
5016        }
5017
5018        #[inline]
5019        unsafe fn decode(
5020            &mut self,
5021            decoder: &mut fidl::encoding::Decoder<
5022                '_,
5023                fidl::encoding::DefaultFuchsiaResourceDialect,
5024            >,
5025            offset: usize,
5026            _depth: fidl::encoding::Depth,
5027        ) -> fidl::Result<()> {
5028            decoder.debug_check_bounds::<Self>(offset);
5029            // Verify that padding bytes are zero.
5030            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
5031            let padval = unsafe { (ptr as *const u64).read_unaligned() };
5032            let mask = 0xffffffff00000000u64;
5033            let maskedval = padval & mask;
5034            if maskedval != 0 {
5035                return Err(fidl::Error::NonZeroPadding {
5036                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
5037                });
5038            }
5039            fidl::decode!(
5040                ValueChangedParameters,
5041                fidl::encoding::DefaultFuchsiaResourceDialect,
5042                &mut self.update,
5043                decoder,
5044                offset + 0,
5045                _depth
5046            )?;
5047            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.confirmation, decoder, offset + 16, _depth)?;
5048            Ok(())
5049        }
5050    }
5051
5052    impl fidl::encoding::ResourceTypeMarker for RemoteServiceRegisterCharacteristicNotifierRequest {
5053        type Borrowed<'a> = &'a mut Self;
5054        fn take_or_borrow<'a>(
5055            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5056        ) -> Self::Borrowed<'a> {
5057            value
5058        }
5059    }
5060
5061    unsafe impl fidl::encoding::TypeMarker for RemoteServiceRegisterCharacteristicNotifierRequest {
5062        type Owned = Self;
5063
5064        #[inline(always)]
5065        fn inline_align(_context: fidl::encoding::Context) -> usize {
5066            8
5067        }
5068
5069        #[inline(always)]
5070        fn inline_size(_context: fidl::encoding::Context) -> usize {
5071            16
5072        }
5073    }
5074
5075    unsafe impl
5076        fidl::encoding::Encode<
5077            RemoteServiceRegisterCharacteristicNotifierRequest,
5078            fidl::encoding::DefaultFuchsiaResourceDialect,
5079        > for &mut RemoteServiceRegisterCharacteristicNotifierRequest
5080    {
5081        #[inline]
5082        unsafe fn encode(
5083            self,
5084            encoder: &mut fidl::encoding::Encoder<
5085                '_,
5086                fidl::encoding::DefaultFuchsiaResourceDialect,
5087            >,
5088            offset: usize,
5089            _depth: fidl::encoding::Depth,
5090        ) -> fidl::Result<()> {
5091            encoder
5092                .debug_check_bounds::<RemoteServiceRegisterCharacteristicNotifierRequest>(offset);
5093            // Delegate to tuple encoding.
5094            fidl::encoding::Encode::<
5095                RemoteServiceRegisterCharacteristicNotifierRequest,
5096                fidl::encoding::DefaultFuchsiaResourceDialect,
5097            >::encode(
5098                (
5099                    <Handle as fidl::encoding::ValueTypeMarker>::borrow(&self.handle),
5100                    <fidl::encoding::Endpoint<
5101                        fidl::endpoints::ClientEnd<CharacteristicNotifierMarker>,
5102                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
5103                        &mut self.notifier
5104                    ),
5105                ),
5106                encoder,
5107                offset,
5108                _depth,
5109            )
5110        }
5111    }
5112    unsafe impl<
5113        T0: fidl::encoding::Encode<Handle, fidl::encoding::DefaultFuchsiaResourceDialect>,
5114        T1: fidl::encoding::Encode<
5115                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<CharacteristicNotifierMarker>>,
5116                fidl::encoding::DefaultFuchsiaResourceDialect,
5117            >,
5118    >
5119        fidl::encoding::Encode<
5120            RemoteServiceRegisterCharacteristicNotifierRequest,
5121            fidl::encoding::DefaultFuchsiaResourceDialect,
5122        > for (T0, T1)
5123    {
5124        #[inline]
5125        unsafe fn encode(
5126            self,
5127            encoder: &mut fidl::encoding::Encoder<
5128                '_,
5129                fidl::encoding::DefaultFuchsiaResourceDialect,
5130            >,
5131            offset: usize,
5132            depth: fidl::encoding::Depth,
5133        ) -> fidl::Result<()> {
5134            encoder
5135                .debug_check_bounds::<RemoteServiceRegisterCharacteristicNotifierRequest>(offset);
5136            // Zero out padding regions. There's no need to apply masks
5137            // because the unmasked parts will be overwritten by fields.
5138            unsafe {
5139                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
5140                (ptr as *mut u64).write_unaligned(0);
5141            }
5142            // Write the fields.
5143            self.0.encode(encoder, offset + 0, depth)?;
5144            self.1.encode(encoder, offset + 8, depth)?;
5145            Ok(())
5146        }
5147    }
5148
5149    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5150        for RemoteServiceRegisterCharacteristicNotifierRequest
5151    {
5152        #[inline(always)]
5153        fn new_empty() -> Self {
5154            Self {
5155                handle: fidl::new_empty!(Handle, fidl::encoding::DefaultFuchsiaResourceDialect),
5156                notifier: fidl::new_empty!(
5157                    fidl::encoding::Endpoint<
5158                        fidl::endpoints::ClientEnd<CharacteristicNotifierMarker>,
5159                    >,
5160                    fidl::encoding::DefaultFuchsiaResourceDialect
5161                ),
5162            }
5163        }
5164
5165        #[inline]
5166        unsafe fn decode(
5167            &mut self,
5168            decoder: &mut fidl::encoding::Decoder<
5169                '_,
5170                fidl::encoding::DefaultFuchsiaResourceDialect,
5171            >,
5172            offset: usize,
5173            _depth: fidl::encoding::Depth,
5174        ) -> fidl::Result<()> {
5175            decoder.debug_check_bounds::<Self>(offset);
5176            // Verify that padding bytes are zero.
5177            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
5178            let padval = unsafe { (ptr as *const u64).read_unaligned() };
5179            let mask = 0xffffffff00000000u64;
5180            let maskedval = padval & mask;
5181            if maskedval != 0 {
5182                return Err(fidl::Error::NonZeroPadding {
5183                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
5184                });
5185            }
5186            fidl::decode!(
5187                Handle,
5188                fidl::encoding::DefaultFuchsiaResourceDialect,
5189                &mut self.handle,
5190                decoder,
5191                offset + 0,
5192                _depth
5193            )?;
5194            fidl::decode!(
5195                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<CharacteristicNotifierMarker>>,
5196                fidl::encoding::DefaultFuchsiaResourceDialect,
5197                &mut self.notifier,
5198                decoder,
5199                offset + 8,
5200                _depth
5201            )?;
5202            Ok(())
5203        }
5204    }
5205
5206    impl fidl::encoding::ResourceTypeMarker for ServerPublishServiceRequest {
5207        type Borrowed<'a> = &'a mut Self;
5208        fn take_or_borrow<'a>(
5209            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5210        ) -> Self::Borrowed<'a> {
5211            value
5212        }
5213    }
5214
5215    unsafe impl fidl::encoding::TypeMarker for ServerPublishServiceRequest {
5216        type Owned = Self;
5217
5218        #[inline(always)]
5219        fn inline_align(_context: fidl::encoding::Context) -> usize {
5220            8
5221        }
5222
5223        #[inline(always)]
5224        fn inline_size(_context: fidl::encoding::Context) -> usize {
5225            24
5226        }
5227    }
5228
5229    unsafe impl
5230        fidl::encoding::Encode<
5231            ServerPublishServiceRequest,
5232            fidl::encoding::DefaultFuchsiaResourceDialect,
5233        > for &mut ServerPublishServiceRequest
5234    {
5235        #[inline]
5236        unsafe fn encode(
5237            self,
5238            encoder: &mut fidl::encoding::Encoder<
5239                '_,
5240                fidl::encoding::DefaultFuchsiaResourceDialect,
5241            >,
5242            offset: usize,
5243            _depth: fidl::encoding::Depth,
5244        ) -> fidl::Result<()> {
5245            encoder.debug_check_bounds::<ServerPublishServiceRequest>(offset);
5246            // Delegate to tuple encoding.
5247            fidl::encoding::Encode::<ServerPublishServiceRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
5248                (
5249                    <ServiceInfo as fidl::encoding::ValueTypeMarker>::borrow(&self.info),
5250                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<LocalServiceMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.service),
5251                ),
5252                encoder, offset, _depth
5253            )
5254        }
5255    }
5256    unsafe impl<
5257        T0: fidl::encoding::Encode<ServiceInfo, fidl::encoding::DefaultFuchsiaResourceDialect>,
5258        T1: fidl::encoding::Encode<
5259                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<LocalServiceMarker>>,
5260                fidl::encoding::DefaultFuchsiaResourceDialect,
5261            >,
5262    >
5263        fidl::encoding::Encode<
5264            ServerPublishServiceRequest,
5265            fidl::encoding::DefaultFuchsiaResourceDialect,
5266        > for (T0, T1)
5267    {
5268        #[inline]
5269        unsafe fn encode(
5270            self,
5271            encoder: &mut fidl::encoding::Encoder<
5272                '_,
5273                fidl::encoding::DefaultFuchsiaResourceDialect,
5274            >,
5275            offset: usize,
5276            depth: fidl::encoding::Depth,
5277        ) -> fidl::Result<()> {
5278            encoder.debug_check_bounds::<ServerPublishServiceRequest>(offset);
5279            // Zero out padding regions. There's no need to apply masks
5280            // because the unmasked parts will be overwritten by fields.
5281            unsafe {
5282                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
5283                (ptr as *mut u64).write_unaligned(0);
5284            }
5285            // Write the fields.
5286            self.0.encode(encoder, offset + 0, depth)?;
5287            self.1.encode(encoder, offset + 16, depth)?;
5288            Ok(())
5289        }
5290    }
5291
5292    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5293        for ServerPublishServiceRequest
5294    {
5295        #[inline(always)]
5296        fn new_empty() -> Self {
5297            Self {
5298                info: fidl::new_empty!(ServiceInfo, fidl::encoding::DefaultFuchsiaResourceDialect),
5299                service: fidl::new_empty!(
5300                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<LocalServiceMarker>>,
5301                    fidl::encoding::DefaultFuchsiaResourceDialect
5302                ),
5303            }
5304        }
5305
5306        #[inline]
5307        unsafe fn decode(
5308            &mut self,
5309            decoder: &mut fidl::encoding::Decoder<
5310                '_,
5311                fidl::encoding::DefaultFuchsiaResourceDialect,
5312            >,
5313            offset: usize,
5314            _depth: fidl::encoding::Depth,
5315        ) -> fidl::Result<()> {
5316            decoder.debug_check_bounds::<Self>(offset);
5317            // Verify that padding bytes are zero.
5318            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
5319            let padval = unsafe { (ptr as *const u64).read_unaligned() };
5320            let mask = 0xffffffff00000000u64;
5321            let maskedval = padval & mask;
5322            if maskedval != 0 {
5323                return Err(fidl::Error::NonZeroPadding {
5324                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
5325                });
5326            }
5327            fidl::decode!(
5328                ServiceInfo,
5329                fidl::encoding::DefaultFuchsiaResourceDialect,
5330                &mut self.info,
5331                decoder,
5332                offset + 0,
5333                _depth
5334            )?;
5335            fidl::decode!(
5336                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<LocalServiceMarker>>,
5337                fidl::encoding::DefaultFuchsiaResourceDialect,
5338                &mut self.service,
5339                decoder,
5340                offset + 16,
5341                _depth
5342            )?;
5343            Ok(())
5344        }
5345    }
5346}