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