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 { Some(()) } else { None }
1716    }
1717    #[allow(irrefutable_let_patterns)]
1718    pub fn into_on_notify_value(self) -> Option<ValueChangedParameters> {
1719        if let LocalServiceEvent::OnNotifyValue { payload } = self { Some((payload)) } else { None }
1720    }
1721    #[allow(irrefutable_let_patterns)]
1722    pub fn into_on_indicate_value(self) -> Option<(ValueChangedParameters, fidl::EventPair)> {
1723        if let LocalServiceEvent::OnIndicateValue { update, confirmation } = self {
1724            Some((update, confirmation))
1725        } else {
1726            None
1727        }
1728    }
1729
1730    /// Decodes a message buffer as a [`LocalServiceEvent`].
1731    fn decode(
1732        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1733    ) -> Result<LocalServiceEvent, fidl::Error> {
1734        let (bytes, _handles) = buf.split_mut();
1735        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1736        debug_assert_eq!(tx_header.tx_id, 0);
1737        match tx_header.ordinal {
1738            0x106d36281c3cfb66 => {
1739                let mut out = fidl::new_empty!(
1740                    fidl::encoding::EmptyPayload,
1741                    fidl::encoding::DefaultFuchsiaResourceDialect
1742                );
1743                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
1744                Ok((LocalServiceEvent::OnSuppressDiscovery {}))
1745            }
1746            0x190c1c528bfd0068 => {
1747                let mut out = fidl::new_empty!(
1748                    ValueChangedParameters,
1749                    fidl::encoding::DefaultFuchsiaResourceDialect
1750                );
1751                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ValueChangedParameters>(&tx_header, _body_bytes, _handles, &mut out)?;
1752                Ok((LocalServiceEvent::OnNotifyValue { payload: out }))
1753            }
1754            0x59431c3653ac531f => {
1755                let mut out = fidl::new_empty!(
1756                    LocalServiceOnIndicateValueRequest,
1757                    fidl::encoding::DefaultFuchsiaResourceDialect
1758                );
1759                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LocalServiceOnIndicateValueRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
1760                Ok((LocalServiceEvent::OnIndicateValue {
1761                    update: out.update,
1762                    confirmation: out.confirmation,
1763                }))
1764            }
1765            _ => Err(fidl::Error::UnknownOrdinal {
1766                ordinal: tx_header.ordinal,
1767                protocol_name: <LocalServiceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1768            }),
1769        }
1770    }
1771}
1772
1773/// A Stream of incoming requests for fuchsia.bluetooth.gatt2/LocalService.
1774pub struct LocalServiceRequestStream {
1775    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1776    is_terminated: bool,
1777}
1778
1779impl std::marker::Unpin for LocalServiceRequestStream {}
1780
1781impl futures::stream::FusedStream for LocalServiceRequestStream {
1782    fn is_terminated(&self) -> bool {
1783        self.is_terminated
1784    }
1785}
1786
1787impl fidl::endpoints::RequestStream for LocalServiceRequestStream {
1788    type Protocol = LocalServiceMarker;
1789    type ControlHandle = LocalServiceControlHandle;
1790
1791    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1792        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1793    }
1794
1795    fn control_handle(&self) -> Self::ControlHandle {
1796        LocalServiceControlHandle { inner: self.inner.clone() }
1797    }
1798
1799    fn into_inner(
1800        self,
1801    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1802    {
1803        (self.inner, self.is_terminated)
1804    }
1805
1806    fn from_inner(
1807        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1808        is_terminated: bool,
1809    ) -> Self {
1810        Self { inner, is_terminated }
1811    }
1812}
1813
1814impl futures::Stream for LocalServiceRequestStream {
1815    type Item = Result<LocalServiceRequest, fidl::Error>;
1816
1817    fn poll_next(
1818        mut self: std::pin::Pin<&mut Self>,
1819        cx: &mut std::task::Context<'_>,
1820    ) -> std::task::Poll<Option<Self::Item>> {
1821        let this = &mut *self;
1822        if this.inner.check_shutdown(cx) {
1823            this.is_terminated = true;
1824            return std::task::Poll::Ready(None);
1825        }
1826        if this.is_terminated {
1827            panic!("polled LocalServiceRequestStream after completion");
1828        }
1829        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1830            |bytes, handles| {
1831                match this.inner.channel().read_etc(cx, bytes, handles) {
1832                    std::task::Poll::Ready(Ok(())) => {}
1833                    std::task::Poll::Pending => return std::task::Poll::Pending,
1834                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1835                        this.is_terminated = true;
1836                        return std::task::Poll::Ready(None);
1837                    }
1838                    std::task::Poll::Ready(Err(e)) => {
1839                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1840                            e.into(),
1841                        ))));
1842                    }
1843                }
1844
1845                // A message has been received from the channel
1846                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1847
1848                std::task::Poll::Ready(Some(match header.ordinal {
1849                    0x431101fcd8d9ef15 => {
1850                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1851                        let mut req = fidl::new_empty!(
1852                            LocalServiceCharacteristicConfigurationRequest,
1853                            fidl::encoding::DefaultFuchsiaResourceDialect
1854                        );
1855                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LocalServiceCharacteristicConfigurationRequest>(&header, _body_bytes, handles, &mut req)?;
1856                        let control_handle =
1857                            LocalServiceControlHandle { inner: this.inner.clone() };
1858                        Ok(LocalServiceRequest::CharacteristicConfiguration {
1859                            peer_id: req.peer_id,
1860                            handle: req.handle,
1861                            notify: req.notify,
1862                            indicate: req.indicate,
1863
1864                            responder: LocalServiceCharacteristicConfigurationResponder {
1865                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1866                                tx_id: header.tx_id,
1867                            },
1868                        })
1869                    }
1870                    0x49e11d396625d104 => {
1871                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1872                        let mut req = fidl::new_empty!(
1873                            LocalServiceReadValueRequest,
1874                            fidl::encoding::DefaultFuchsiaResourceDialect
1875                        );
1876                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LocalServiceReadValueRequest>(&header, _body_bytes, handles, &mut req)?;
1877                        let control_handle =
1878                            LocalServiceControlHandle { inner: this.inner.clone() };
1879                        Ok(LocalServiceRequest::ReadValue {
1880                            peer_id: req.peer_id,
1881                            handle: req.handle,
1882                            offset: req.offset,
1883
1884                            responder: LocalServiceReadValueResponder {
1885                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1886                                tx_id: header.tx_id,
1887                            },
1888                        })
1889                    }
1890                    0x7d6ae631baf18260 => {
1891                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1892                        let mut req = fidl::new_empty!(
1893                            LocalServiceWriteValueRequest,
1894                            fidl::encoding::DefaultFuchsiaResourceDialect
1895                        );
1896                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LocalServiceWriteValueRequest>(&header, _body_bytes, handles, &mut req)?;
1897                        let control_handle =
1898                            LocalServiceControlHandle { inner: this.inner.clone() };
1899                        Ok(LocalServiceRequest::WriteValue {
1900                            payload: req,
1901                            responder: LocalServiceWriteValueResponder {
1902                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1903                                tx_id: header.tx_id,
1904                            },
1905                        })
1906                    }
1907                    0x7e362177a04108b8 => {
1908                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1909                        let mut req = fidl::new_empty!(
1910                            LocalServicePeerUpdateRequest,
1911                            fidl::encoding::DefaultFuchsiaResourceDialect
1912                        );
1913                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LocalServicePeerUpdateRequest>(&header, _body_bytes, handles, &mut req)?;
1914                        let control_handle =
1915                            LocalServiceControlHandle { inner: this.inner.clone() };
1916                        Ok(LocalServiceRequest::PeerUpdate {
1917                            payload: req,
1918                            responder: LocalServicePeerUpdateResponder {
1919                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1920                                tx_id: header.tx_id,
1921                            },
1922                        })
1923                    }
1924                    0x7cf0931548318566 => {
1925                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1926                        let mut req = fidl::new_empty!(
1927                            LocalServiceValueChangedCreditRequest,
1928                            fidl::encoding::DefaultFuchsiaResourceDialect
1929                        );
1930                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LocalServiceValueChangedCreditRequest>(&header, _body_bytes, handles, &mut req)?;
1931                        let control_handle =
1932                            LocalServiceControlHandle { inner: this.inner.clone() };
1933                        Ok(LocalServiceRequest::ValueChangedCredit {
1934                            additional_credit: req.additional_credit,
1935
1936                            control_handle,
1937                        })
1938                    }
1939                    _ => Err(fidl::Error::UnknownOrdinal {
1940                        ordinal: header.ordinal,
1941                        protocol_name:
1942                            <LocalServiceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1943                    }),
1944                }))
1945            },
1946        )
1947    }
1948}
1949
1950/// Interface for serving a local GATT service. Closing the server_end of this protocol causes the
1951/// GATT service to be removed from the local GATT database. Similarly, closure of the client_end
1952/// of this protocol means the Bluetooth stack has removed this service from its GATT database.
1953#[derive(Debug)]
1954pub enum LocalServiceRequest {
1955    /// This notifies the current configuration of a particular characteristic/descriptor for a
1956    /// particular peer. It will be called when the peer GATT client changes the configuration.
1957    ///
1958    /// The Bluetooth stack maintains the state of each peer's configuration across reconnections.
1959    /// As such, this method will also be called when a peer connects for each characteristic with
1960    /// the initial, persisted state of the newly-connected peer's configuration. However, clients
1961    /// should not rely on this state being persisted indefinitely by the Bluetooth stack.
1962    ///
1963    /// + request `peer_id` The PeerId of the GATT client associated with this particular CCC.
1964    /// + request `handle` The handle of the characteristic associated with the `notify` and
1965    ///  `indicate` parameters.
1966    /// + request `notify` True if the client has enabled notifications, false otherwise.
1967    /// + request `indicate` True if the client has enabled indications, false otherwise.
1968    /// - response empty Returns nothing to acknowledge the characteristic configuration.
1969    CharacteristicConfiguration {
1970        peer_id: fidl_fuchsia_bluetooth::PeerId,
1971        handle: Handle,
1972        notify: bool,
1973        indicate: bool,
1974        responder: LocalServiceCharacteristicConfigurationResponder,
1975    },
1976    /// Called when a peer requests to read the value of a characteristic or descriptor. It is
1977    /// guaranteed that the peer satisfies the permssions associated with this attribute.
1978    ///
1979    /// + request `peer_id` The PeerId of the GATT client making the read request.
1980    /// + request `handle` The handle of the requested descriptor/characteristic.
1981    /// + request `offset` The offset at which to start reading the requested value.
1982    /// - response `value` The value of the characteristic.
1983    /// * error See `gatt2.Error` documentation for possible errors.
1984    ReadValue {
1985        peer_id: fidl_fuchsia_bluetooth::PeerId,
1986        handle: Handle,
1987        offset: i32,
1988        responder: LocalServiceReadValueResponder,
1989    },
1990    /// Called when a peer issues a request to write the value of a characteristic or descriptor. It
1991    /// is guaranteed that the peer satisfies the permissions associated with this attribute.
1992    ///
1993    /// + request `peer_id` The PeerId of the GATT client making the write request. Always present.
1994    /// + request `handle` The handle of the requested descriptor/characteristic. Always present.
1995    /// + request `offset` The offset at which to start writing the value. If the offset is 0, any
1996    ///   existing value should be overwritten by the new value. Otherwise, the existing value from
1997    ///   offset:(offset + len(value)) should be changed to `value`. Always present.
1998    /// + request `value` The new value for the descriptor/characteristic. Always present, but may
1999    ///   be the empty string.
2000    /// - response  The implementation must send an empty response once the value has been updated
2001    ///   as confirmation.
2002    /// * error See `gatt2.Error` documentation for possible errors.
2003    WriteValue {
2004        payload: LocalServiceWriteValueRequest,
2005        responder: LocalServiceWriteValueResponder,
2006    },
2007    /// Called to provide GATT information specific to a peer. PeerUpdate will not be called unless
2008    /// the prior invocation received a response. As such, the implementation can simply ignore the
2009    /// first invocation if they are not interested in any PeerUpdate fields.
2010    ///
2011    /// A PeerUpdate will be made before propagating any other interaction from the peer to the
2012    /// LocalService (Write/ReadValue, CharacteristicConfiguration) on a best-effort basis, as long
2013    /// as all preceding PeerUpdates were acknowledged.
2014    ///
2015    /// Not currently sent. Comment on https://fxbug.dev/42178509 to request support
2016    ///
2017    /// + request `peer_id` The PeerId the update pertains to. Always present.
2018    /// + request `mtu` The maximum number of bytes that fit in a notification/indication to this
2019    ///   peer. Any bytes past this limit are silently truncated. Most clients need not concern
2020    ///   themselves with this unless they are using notifications/indications for high throughput.
2021    ///   Optional.
2022    /// - response An empty response to acknowledge that the update was received.
2023    PeerUpdate {
2024        payload: LocalServicePeerUpdateRequest,
2025        responder: LocalServicePeerUpdateResponder,
2026    },
2027    /// Add credit for sending indications/notifications. Implementors are defined to start out with
2028    /// INITIAL_VALUE_CHANGED_CREDITS credits before this method is called. Implementors must keep
2029    /// track of the available credit they have. The implementor can send exactly one OnNotifyValue
2030    /// or OnIndicateValue event for each credit. Note that `ValueChangedCredit` will only be called
2031    /// if at least one indication/notification has been sent since the prior call.
2032    ValueChangedCredit { additional_credit: u8, control_handle: LocalServiceControlHandle },
2033}
2034
2035impl LocalServiceRequest {
2036    #[allow(irrefutable_let_patterns)]
2037    pub fn into_characteristic_configuration(
2038        self,
2039    ) -> Option<(
2040        fidl_fuchsia_bluetooth::PeerId,
2041        Handle,
2042        bool,
2043        bool,
2044        LocalServiceCharacteristicConfigurationResponder,
2045    )> {
2046        if let LocalServiceRequest::CharacteristicConfiguration {
2047            peer_id,
2048            handle,
2049            notify,
2050            indicate,
2051            responder,
2052        } = self
2053        {
2054            Some((peer_id, handle, notify, indicate, responder))
2055        } else {
2056            None
2057        }
2058    }
2059
2060    #[allow(irrefutable_let_patterns)]
2061    pub fn into_read_value(
2062        self,
2063    ) -> Option<(fidl_fuchsia_bluetooth::PeerId, Handle, i32, LocalServiceReadValueResponder)> {
2064        if let LocalServiceRequest::ReadValue { peer_id, handle, offset, responder } = self {
2065            Some((peer_id, handle, offset, responder))
2066        } else {
2067            None
2068        }
2069    }
2070
2071    #[allow(irrefutable_let_patterns)]
2072    pub fn into_write_value(
2073        self,
2074    ) -> Option<(LocalServiceWriteValueRequest, LocalServiceWriteValueResponder)> {
2075        if let LocalServiceRequest::WriteValue { payload, responder } = self {
2076            Some((payload, responder))
2077        } else {
2078            None
2079        }
2080    }
2081
2082    #[allow(irrefutable_let_patterns)]
2083    pub fn into_peer_update(
2084        self,
2085    ) -> Option<(LocalServicePeerUpdateRequest, LocalServicePeerUpdateResponder)> {
2086        if let LocalServiceRequest::PeerUpdate { payload, responder } = self {
2087            Some((payload, responder))
2088        } else {
2089            None
2090        }
2091    }
2092
2093    #[allow(irrefutable_let_patterns)]
2094    pub fn into_value_changed_credit(self) -> Option<(u8, LocalServiceControlHandle)> {
2095        if let LocalServiceRequest::ValueChangedCredit { additional_credit, control_handle } = self
2096        {
2097            Some((additional_credit, control_handle))
2098        } else {
2099            None
2100        }
2101    }
2102
2103    /// Name of the method defined in FIDL
2104    pub fn method_name(&self) -> &'static str {
2105        match *self {
2106            LocalServiceRequest::CharacteristicConfiguration { .. } => {
2107                "characteristic_configuration"
2108            }
2109            LocalServiceRequest::ReadValue { .. } => "read_value",
2110            LocalServiceRequest::WriteValue { .. } => "write_value",
2111            LocalServiceRequest::PeerUpdate { .. } => "peer_update",
2112            LocalServiceRequest::ValueChangedCredit { .. } => "value_changed_credit",
2113        }
2114    }
2115}
2116
2117#[derive(Debug, Clone)]
2118pub struct LocalServiceControlHandle {
2119    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2120}
2121
2122impl fidl::endpoints::ControlHandle for LocalServiceControlHandle {
2123    fn shutdown(&self) {
2124        self.inner.shutdown()
2125    }
2126    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2127        self.inner.shutdown_with_epitaph(status)
2128    }
2129
2130    fn is_closed(&self) -> bool {
2131        self.inner.channel().is_closed()
2132    }
2133    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2134        self.inner.channel().on_closed()
2135    }
2136
2137    #[cfg(target_os = "fuchsia")]
2138    fn signal_peer(
2139        &self,
2140        clear_mask: zx::Signals,
2141        set_mask: zx::Signals,
2142    ) -> Result<(), zx_status::Status> {
2143        use fidl::Peered;
2144        self.inner.channel().signal_peer(clear_mask, set_mask)
2145    }
2146}
2147
2148impl LocalServiceControlHandle {
2149    pub fn send_on_suppress_discovery(&self) -> Result<(), fidl::Error> {
2150        self.inner.send::<fidl::encoding::EmptyPayload>(
2151            (),
2152            0,
2153            0x106d36281c3cfb66,
2154            fidl::encoding::DynamicFlags::empty(),
2155        )
2156    }
2157
2158    pub fn send_on_notify_value(
2159        &self,
2160        mut payload: &ValueChangedParameters,
2161    ) -> Result<(), fidl::Error> {
2162        self.inner.send::<ValueChangedParameters>(
2163            payload,
2164            0,
2165            0x190c1c528bfd0068,
2166            fidl::encoding::DynamicFlags::empty(),
2167        )
2168    }
2169
2170    pub fn send_on_indicate_value(
2171        &self,
2172        mut update: &ValueChangedParameters,
2173        mut confirmation: fidl::EventPair,
2174    ) -> Result<(), fidl::Error> {
2175        self.inner.send::<LocalServiceOnIndicateValueRequest>(
2176            (update, confirmation),
2177            0,
2178            0x59431c3653ac531f,
2179            fidl::encoding::DynamicFlags::empty(),
2180        )
2181    }
2182}
2183
2184#[must_use = "FIDL methods require a response to be sent"]
2185#[derive(Debug)]
2186pub struct LocalServiceCharacteristicConfigurationResponder {
2187    control_handle: std::mem::ManuallyDrop<LocalServiceControlHandle>,
2188    tx_id: u32,
2189}
2190
2191/// Set the the channel to be shutdown (see [`LocalServiceControlHandle::shutdown`])
2192/// if the responder is dropped without sending a response, so that the client
2193/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2194impl std::ops::Drop for LocalServiceCharacteristicConfigurationResponder {
2195    fn drop(&mut self) {
2196        self.control_handle.shutdown();
2197        // Safety: drops once, never accessed again
2198        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2199    }
2200}
2201
2202impl fidl::endpoints::Responder for LocalServiceCharacteristicConfigurationResponder {
2203    type ControlHandle = LocalServiceControlHandle;
2204
2205    fn control_handle(&self) -> &LocalServiceControlHandle {
2206        &self.control_handle
2207    }
2208
2209    fn drop_without_shutdown(mut self) {
2210        // Safety: drops once, never accessed again due to mem::forget
2211        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2212        // Prevent Drop from running (which would shut down the channel)
2213        std::mem::forget(self);
2214    }
2215}
2216
2217impl LocalServiceCharacteristicConfigurationResponder {
2218    /// Sends a response to the FIDL transaction.
2219    ///
2220    /// Sets the channel to shutdown if an error occurs.
2221    pub fn send(self) -> Result<(), fidl::Error> {
2222        let _result = self.send_raw();
2223        if _result.is_err() {
2224            self.control_handle.shutdown();
2225        }
2226        self.drop_without_shutdown();
2227        _result
2228    }
2229
2230    /// Similar to "send" but does not shutdown the channel if an error occurs.
2231    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
2232        let _result = self.send_raw();
2233        self.drop_without_shutdown();
2234        _result
2235    }
2236
2237    fn send_raw(&self) -> Result<(), fidl::Error> {
2238        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
2239            (),
2240            self.tx_id,
2241            0x431101fcd8d9ef15,
2242            fidl::encoding::DynamicFlags::empty(),
2243        )
2244    }
2245}
2246
2247#[must_use = "FIDL methods require a response to be sent"]
2248#[derive(Debug)]
2249pub struct LocalServiceReadValueResponder {
2250    control_handle: std::mem::ManuallyDrop<LocalServiceControlHandle>,
2251    tx_id: u32,
2252}
2253
2254/// Set the the channel to be shutdown (see [`LocalServiceControlHandle::shutdown`])
2255/// if the responder is dropped without sending a response, so that the client
2256/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2257impl std::ops::Drop for LocalServiceReadValueResponder {
2258    fn drop(&mut self) {
2259        self.control_handle.shutdown();
2260        // Safety: drops once, never accessed again
2261        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2262    }
2263}
2264
2265impl fidl::endpoints::Responder for LocalServiceReadValueResponder {
2266    type ControlHandle = LocalServiceControlHandle;
2267
2268    fn control_handle(&self) -> &LocalServiceControlHandle {
2269        &self.control_handle
2270    }
2271
2272    fn drop_without_shutdown(mut self) {
2273        // Safety: drops once, never accessed again due to mem::forget
2274        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2275        // Prevent Drop from running (which would shut down the channel)
2276        std::mem::forget(self);
2277    }
2278}
2279
2280impl LocalServiceReadValueResponder {
2281    /// Sends a response to the FIDL transaction.
2282    ///
2283    /// Sets the channel to shutdown if an error occurs.
2284    pub fn send(self, mut result: Result<&[u8], Error>) -> Result<(), fidl::Error> {
2285        let _result = self.send_raw(result);
2286        if _result.is_err() {
2287            self.control_handle.shutdown();
2288        }
2289        self.drop_without_shutdown();
2290        _result
2291    }
2292
2293    /// Similar to "send" but does not shutdown the channel if an error occurs.
2294    pub fn send_no_shutdown_on_err(
2295        self,
2296        mut result: Result<&[u8], Error>,
2297    ) -> Result<(), fidl::Error> {
2298        let _result = self.send_raw(result);
2299        self.drop_without_shutdown();
2300        _result
2301    }
2302
2303    fn send_raw(&self, mut result: Result<&[u8], Error>) -> Result<(), fidl::Error> {
2304        self.control_handle
2305            .inner
2306            .send::<fidl::encoding::ResultType<LocalServiceReadValueResponse, Error>>(
2307                result.map(|value| (value,)),
2308                self.tx_id,
2309                0x49e11d396625d104,
2310                fidl::encoding::DynamicFlags::empty(),
2311            )
2312    }
2313}
2314
2315#[must_use = "FIDL methods require a response to be sent"]
2316#[derive(Debug)]
2317pub struct LocalServiceWriteValueResponder {
2318    control_handle: std::mem::ManuallyDrop<LocalServiceControlHandle>,
2319    tx_id: u32,
2320}
2321
2322/// Set the the channel to be shutdown (see [`LocalServiceControlHandle::shutdown`])
2323/// if the responder is dropped without sending a response, so that the client
2324/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2325impl std::ops::Drop for LocalServiceWriteValueResponder {
2326    fn drop(&mut self) {
2327        self.control_handle.shutdown();
2328        // Safety: drops once, never accessed again
2329        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2330    }
2331}
2332
2333impl fidl::endpoints::Responder for LocalServiceWriteValueResponder {
2334    type ControlHandle = LocalServiceControlHandle;
2335
2336    fn control_handle(&self) -> &LocalServiceControlHandle {
2337        &self.control_handle
2338    }
2339
2340    fn drop_without_shutdown(mut self) {
2341        // Safety: drops once, never accessed again due to mem::forget
2342        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2343        // Prevent Drop from running (which would shut down the channel)
2344        std::mem::forget(self);
2345    }
2346}
2347
2348impl LocalServiceWriteValueResponder {
2349    /// Sends a response to the FIDL transaction.
2350    ///
2351    /// Sets the channel to shutdown if an error occurs.
2352    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2353        let _result = self.send_raw(result);
2354        if _result.is_err() {
2355            self.control_handle.shutdown();
2356        }
2357        self.drop_without_shutdown();
2358        _result
2359    }
2360
2361    /// Similar to "send" but does not shutdown the channel if an error occurs.
2362    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2363        let _result = self.send_raw(result);
2364        self.drop_without_shutdown();
2365        _result
2366    }
2367
2368    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2369        self.control_handle
2370            .inner
2371            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
2372                result,
2373                self.tx_id,
2374                0x7d6ae631baf18260,
2375                fidl::encoding::DynamicFlags::empty(),
2376            )
2377    }
2378}
2379
2380#[must_use = "FIDL methods require a response to be sent"]
2381#[derive(Debug)]
2382pub struct LocalServicePeerUpdateResponder {
2383    control_handle: std::mem::ManuallyDrop<LocalServiceControlHandle>,
2384    tx_id: u32,
2385}
2386
2387/// Set the the channel to be shutdown (see [`LocalServiceControlHandle::shutdown`])
2388/// if the responder is dropped without sending a response, so that the client
2389/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2390impl std::ops::Drop for LocalServicePeerUpdateResponder {
2391    fn drop(&mut self) {
2392        self.control_handle.shutdown();
2393        // Safety: drops once, never accessed again
2394        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2395    }
2396}
2397
2398impl fidl::endpoints::Responder for LocalServicePeerUpdateResponder {
2399    type ControlHandle = LocalServiceControlHandle;
2400
2401    fn control_handle(&self) -> &LocalServiceControlHandle {
2402        &self.control_handle
2403    }
2404
2405    fn drop_without_shutdown(mut self) {
2406        // Safety: drops once, never accessed again due to mem::forget
2407        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2408        // Prevent Drop from running (which would shut down the channel)
2409        std::mem::forget(self);
2410    }
2411}
2412
2413impl LocalServicePeerUpdateResponder {
2414    /// Sends a response to the FIDL transaction.
2415    ///
2416    /// Sets the channel to shutdown if an error occurs.
2417    pub fn send(self) -> Result<(), fidl::Error> {
2418        let _result = self.send_raw();
2419        if _result.is_err() {
2420            self.control_handle.shutdown();
2421        }
2422        self.drop_without_shutdown();
2423        _result
2424    }
2425
2426    /// Similar to "send" but does not shutdown the channel if an error occurs.
2427    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
2428        let _result = self.send_raw();
2429        self.drop_without_shutdown();
2430        _result
2431    }
2432
2433    fn send_raw(&self) -> Result<(), fidl::Error> {
2434        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
2435            (),
2436            self.tx_id,
2437            0x7e362177a04108b8,
2438            fidl::encoding::DynamicFlags::empty(),
2439        )
2440    }
2441}
2442
2443#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2444pub struct RemoteServiceMarker;
2445
2446impl fidl::endpoints::ProtocolMarker for RemoteServiceMarker {
2447    type Proxy = RemoteServiceProxy;
2448    type RequestStream = RemoteServiceRequestStream;
2449    #[cfg(target_os = "fuchsia")]
2450    type SynchronousProxy = RemoteServiceSynchronousProxy;
2451
2452    const DEBUG_NAME: &'static str = "(anonymous) RemoteService";
2453}
2454pub type RemoteServiceReadByTypeResult = Result<Vec<ReadByTypeResult>, Error>;
2455pub type RemoteServiceReadCharacteristicResult = Result<ReadValue, Error>;
2456pub type RemoteServiceWriteCharacteristicResult = Result<(), Error>;
2457pub type RemoteServiceReadDescriptorResult = Result<ReadValue, Error>;
2458pub type RemoteServiceWriteDescriptorResult = Result<(), Error>;
2459pub type RemoteServiceRegisterCharacteristicNotifierResult = Result<(), Error>;
2460
2461pub trait RemoteServiceProxyInterface: Send + Sync {
2462    type DiscoverCharacteristicsResponseFut: std::future::Future<Output = Result<Vec<Characteristic>, fidl::Error>>
2463        + Send;
2464    fn r#discover_characteristics(&self) -> Self::DiscoverCharacteristicsResponseFut;
2465    type ReadByTypeResponseFut: std::future::Future<Output = Result<RemoteServiceReadByTypeResult, fidl::Error>>
2466        + Send;
2467    fn r#read_by_type(&self, uuid: &fidl_fuchsia_bluetooth::Uuid) -> Self::ReadByTypeResponseFut;
2468    type ReadCharacteristicResponseFut: std::future::Future<Output = Result<RemoteServiceReadCharacteristicResult, fidl::Error>>
2469        + Send;
2470    fn r#read_characteristic(
2471        &self,
2472        handle: &Handle,
2473        options: &ReadOptions,
2474    ) -> Self::ReadCharacteristicResponseFut;
2475    type WriteCharacteristicResponseFut: std::future::Future<Output = Result<RemoteServiceWriteCharacteristicResult, fidl::Error>>
2476        + Send;
2477    fn r#write_characteristic(
2478        &self,
2479        handle: &Handle,
2480        value: &[u8],
2481        options: &WriteOptions,
2482    ) -> Self::WriteCharacteristicResponseFut;
2483    type ReadDescriptorResponseFut: std::future::Future<Output = Result<RemoteServiceReadDescriptorResult, fidl::Error>>
2484        + Send;
2485    fn r#read_descriptor(
2486        &self,
2487        handle: &Handle,
2488        options: &ReadOptions,
2489    ) -> Self::ReadDescriptorResponseFut;
2490    type WriteDescriptorResponseFut: std::future::Future<Output = Result<RemoteServiceWriteDescriptorResult, fidl::Error>>
2491        + Send;
2492    fn r#write_descriptor(
2493        &self,
2494        handle: &Handle,
2495        value: &[u8],
2496        options: &WriteOptions,
2497    ) -> Self::WriteDescriptorResponseFut;
2498    type RegisterCharacteristicNotifierResponseFut: std::future::Future<
2499            Output = Result<RemoteServiceRegisterCharacteristicNotifierResult, fidl::Error>,
2500        > + Send;
2501    fn r#register_characteristic_notifier(
2502        &self,
2503        handle: &Handle,
2504        notifier: fidl::endpoints::ClientEnd<CharacteristicNotifierMarker>,
2505    ) -> Self::RegisterCharacteristicNotifierResponseFut;
2506}
2507#[derive(Debug)]
2508#[cfg(target_os = "fuchsia")]
2509pub struct RemoteServiceSynchronousProxy {
2510    client: fidl::client::sync::Client,
2511}
2512
2513#[cfg(target_os = "fuchsia")]
2514impl fidl::endpoints::SynchronousProxy for RemoteServiceSynchronousProxy {
2515    type Proxy = RemoteServiceProxy;
2516    type Protocol = RemoteServiceMarker;
2517
2518    fn from_channel(inner: fidl::Channel) -> Self {
2519        Self::new(inner)
2520    }
2521
2522    fn into_channel(self) -> fidl::Channel {
2523        self.client.into_channel()
2524    }
2525
2526    fn as_channel(&self) -> &fidl::Channel {
2527        self.client.as_channel()
2528    }
2529}
2530
2531#[cfg(target_os = "fuchsia")]
2532impl RemoteServiceSynchronousProxy {
2533    pub fn new(channel: fidl::Channel) -> Self {
2534        let protocol_name = <RemoteServiceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2535        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
2536    }
2537
2538    pub fn into_channel(self) -> fidl::Channel {
2539        self.client.into_channel()
2540    }
2541
2542    /// Waits until an event arrives and returns it. It is safe for other
2543    /// threads to make concurrent requests while waiting for an event.
2544    pub fn wait_for_event(
2545        &self,
2546        deadline: zx::MonotonicInstant,
2547    ) -> Result<RemoteServiceEvent, fidl::Error> {
2548        RemoteServiceEvent::decode(self.client.wait_for_event(deadline)?)
2549    }
2550
2551    /// Returns the characteristics and characteristic descriptors that belong to
2552    /// this service.
2553    pub fn r#discover_characteristics(
2554        &self,
2555        ___deadline: zx::MonotonicInstant,
2556    ) -> Result<Vec<Characteristic>, fidl::Error> {
2557        let _response = self.client.send_query::<
2558            fidl::encoding::EmptyPayload,
2559            RemoteServiceDiscoverCharacteristicsResponse,
2560        >(
2561            (),
2562            0x6cd730f12e402543,
2563            fidl::encoding::DynamicFlags::empty(),
2564            ___deadline,
2565        )?;
2566        Ok(_response.characteristics)
2567    }
2568
2569    /// Reads characteristics and descriptors with the given `uuid`.
2570    ///
2571    /// This method is useful for reading values before discovery has completed,
2572    /// thereby reducing latency.
2573    ///
2574    /// + request `uuid` The UUID of the characteristics/descriptors to read.
2575    /// - response `results` The results of the read. May be empty if no
2576    ///            matching values are read. If reading a value results in a
2577    ///            permission error, the handle and error will be included.
2578    /// * error Returns `INVALID_PARAMETERS` if `uuid` refers to an internally
2579    ///         reserved descriptor type (e.g. the Client Characteristic
2580    ///         Configuration descriptor).
2581    /// * error Returns `TOO_MANY_RESULTS` if more results were read than can fit
2582    ///         in a FIDL response. Consider reading characteristics/descriptors
2583    ///         individually after performing discovery.
2584    /// * error Returns `FAILURE` if the server returns an error not specific to
2585    ///         a single result.
2586    pub fn r#read_by_type(
2587        &self,
2588        mut uuid: &fidl_fuchsia_bluetooth::Uuid,
2589        ___deadline: zx::MonotonicInstant,
2590    ) -> Result<RemoteServiceReadByTypeResult, fidl::Error> {
2591        let _response = self.client.send_query::<
2592            RemoteServiceReadByTypeRequest,
2593            fidl::encoding::ResultType<RemoteServiceReadByTypeResponse, Error>,
2594        >(
2595            (uuid,),
2596            0x739bb1e313162bbc,
2597            fidl::encoding::DynamicFlags::empty(),
2598            ___deadline,
2599        )?;
2600        Ok(_response.map(|x| x.results))
2601    }
2602
2603    /// Reads the value of a characteristic with the given `handle`.
2604    ///
2605    /// + request `handle` The characteristic handle to read.
2606    /// + request `options` Options that apply to the read.
2607    /// - response `value` The value of the characteristic.
2608    /// * error Returns `INVALID_HANDLE` if `handle` is invalid.
2609    /// * error Returns `INVALID_PARAMETERS` if `options` is invalid.
2610    /// * error Returns `READ_NOT_PERMITTED` or `INSUFFICIENT_*` if the server
2611    ///         rejects the read request.
2612    /// * error Returns `FAILURE` if the server returns an error.
2613    pub fn r#read_characteristic(
2614        &self,
2615        mut handle: &Handle,
2616        mut options: &ReadOptions,
2617        ___deadline: zx::MonotonicInstant,
2618    ) -> Result<RemoteServiceReadCharacteristicResult, fidl::Error> {
2619        let _response = self.client.send_query::<
2620            RemoteServiceReadCharacteristicRequest,
2621            fidl::encoding::ResultType<RemoteServiceReadCharacteristicResponse, Error>,
2622        >(
2623            (handle, options,),
2624            0x4d41757ed69a96cb,
2625            fidl::encoding::DynamicFlags::empty(),
2626            ___deadline,
2627        )?;
2628        Ok(_response.map(|x| x.value))
2629    }
2630
2631    /// Writes `value` to the characteristic with `handle` using the provided
2632    /// `options`.
2633    ///
2634    /// It is not recommended to send additional writes while a write is already
2635    /// in progress (the server may receive simultaneous writes in any order).
2636    ///
2637    /// + request `handle` The characteristic to be written to.
2638    /// + request `value` The value to be written.
2639    /// + request `options` Options that apply to the write.
2640    /// - response An empty response will be sent when a success response is
2641    ///            received from the server (or immediately if
2642    ///            `options.with_response` is false)
2643    /// * error Returns `INVALID_HANDLE` if `handle` is invalid.
2644    /// * error Returns `INVALID_PARAMETERS` if `options` is invalid.
2645    /// * error Returns `WRITE_NOT_PERMITTED` or `INSUFFICIENT_*`if the server
2646    ///         rejects the write request with a reason.
2647    /// * error Returns `FAILURE` if the server returns an error.
2648    pub fn r#write_characteristic(
2649        &self,
2650        mut handle: &Handle,
2651        mut value: &[u8],
2652        mut options: &WriteOptions,
2653        ___deadline: zx::MonotonicInstant,
2654    ) -> Result<RemoteServiceWriteCharacteristicResult, fidl::Error> {
2655        let _response = self.client.send_query::<
2656            RemoteServiceWriteCharacteristicRequest,
2657            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
2658        >(
2659            (handle, value, options,),
2660            0x7fc7511adecde8c,
2661            fidl::encoding::DynamicFlags::empty(),
2662            ___deadline,
2663        )?;
2664        Ok(_response.map(|x| x))
2665    }
2666
2667    /// Reads the value of the characteristic descriptor with `handle` and
2668    /// returns it in the reply.
2669    ///
2670    /// + request `handle` The descriptor handle to read.
2671    /// + request `options` Options that apply to the read.
2672    /// - response `value` The value of the descriptor.
2673    /// * error Returns `INVALID_HANDLE` if `handle` is invalid.
2674    /// * error Returns `INVALID_PARAMETERS` if `options` is invalid.
2675    /// * error Returns `READ_NOT_PERMITTED` or `INSUFFICIENT_*` if the server
2676    ///         rejects the read request.
2677    /// * error Returns `FAILURE` if the server returns an error.
2678    pub fn r#read_descriptor(
2679        &self,
2680        mut handle: &Handle,
2681        mut options: &ReadOptions,
2682        ___deadline: zx::MonotonicInstant,
2683    ) -> Result<RemoteServiceReadDescriptorResult, fidl::Error> {
2684        let _response = self.client.send_query::<
2685            RemoteServiceReadDescriptorRequest,
2686            fidl::encoding::ResultType<RemoteServiceReadDescriptorResponse, Error>,
2687        >(
2688            (handle, options,),
2689            0x7ed7ce00457dcec1,
2690            fidl::encoding::DynamicFlags::empty(),
2691            ___deadline,
2692        )?;
2693        Ok(_response.map(|x| x.value))
2694    }
2695
2696    /// Writes `value` to the characteristic descriptor with `handle`.
2697    /// It is not recommended to send additional writes while a write is already
2698    /// in progress (the server may receive simultaneous writes in any order).
2699    ///
2700    /// + request `handle` The descriptor handle to written to.
2701    /// + request `value` The value to be written.
2702    /// + request `options` Options that apply to the write.
2703    /// - response An empty response will be sent when a success response is
2704    ///            received from the server (or immediately if
2705    ///            `options.with_response` is false)
2706    /// * error Returns `INVALID_HANDLE` if `handle` is invalid or refers to an
2707    ///         internally reserved descriptor type (e.g. the Client
2708    ///         Characteristic Configuration descriptor).
2709    /// * error Returns `INVALID_PARAMETERS` if `options` is invalid.
2710    /// * error Returns `WRITE_NOT_PERMITTED` or `INSUFFICIENT_*` if the server
2711    ///         rejects the write with a reason.
2712    /// * error Returns `FAILURE` if the server returns an error.
2713    pub fn r#write_descriptor(
2714        &self,
2715        mut handle: &Handle,
2716        mut value: &[u8],
2717        mut options: &WriteOptions,
2718        ___deadline: zx::MonotonicInstant,
2719    ) -> Result<RemoteServiceWriteDescriptorResult, fidl::Error> {
2720        let _response = self.client.send_query::<
2721            RemoteServiceWriteDescriptorRequest,
2722            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
2723        >(
2724            (handle, value, options,),
2725            0x21d9106bfd6b7351,
2726            fidl::encoding::DynamicFlags::empty(),
2727            ___deadline,
2728        )?;
2729        Ok(_response.map(|x| x))
2730    }
2731
2732    /// Subscribe to notifications & indications from the characteristic with
2733    /// the given `handle`.
2734    ///
2735    /// Either notifications or indications will be enabled depending on
2736    /// characteristic properties. Indications will be preferred if they are
2737    /// supported. This operation fails if the characteristic does not have the
2738    /// "notify" or "indicate" property.
2739    ///
2740    /// A write request will be issued to configure the characteristic for
2741    /// notifications/indications if it contains a Client Characteristic
2742    /// Configuration descriptor. This method fails if an error occurs while
2743    /// writing to the descriptor.
2744    ///
2745    /// On success, the `notifier` protocol can be used to be notified when
2746    /// the peer sends a notification or indication. Indications are
2747    /// automatically confirmed. When the protocol is dropped, the subscription
2748    /// may end if no other local client is receiving notifications.
2749    ///
2750    /// + request `handle` the characteristic handle.
2751    /// + request `notifier` the protocol used for notifications.
2752    /// - response An empty response will be sent immediately if registration
2753    ///            succeeds.
2754    /// * error Returns a `FAILURE` if the characteristic does not support
2755    ///         notifications or indications.
2756    /// * error Returns a `INVALID_HANDLE` if `handle` is invalid.
2757    /// * error Returns a `WRITE_NOT_PERMITTED`  or `INSUFFICIENT_*`for a
2758    ///         descriptor write error.
2759    pub fn r#register_characteristic_notifier(
2760        &self,
2761        mut handle: &Handle,
2762        mut notifier: fidl::endpoints::ClientEnd<CharacteristicNotifierMarker>,
2763        ___deadline: zx::MonotonicInstant,
2764    ) -> Result<RemoteServiceRegisterCharacteristicNotifierResult, fidl::Error> {
2765        let _response = self.client.send_query::<
2766            RemoteServiceRegisterCharacteristicNotifierRequest,
2767            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
2768        >(
2769            (handle, notifier,),
2770            0x35007a85245f5cc6,
2771            fidl::encoding::DynamicFlags::empty(),
2772            ___deadline,
2773        )?;
2774        Ok(_response.map(|x| x))
2775    }
2776}
2777
2778#[cfg(target_os = "fuchsia")]
2779impl From<RemoteServiceSynchronousProxy> for zx::Handle {
2780    fn from(value: RemoteServiceSynchronousProxy) -> Self {
2781        value.into_channel().into()
2782    }
2783}
2784
2785#[cfg(target_os = "fuchsia")]
2786impl From<fidl::Channel> for RemoteServiceSynchronousProxy {
2787    fn from(value: fidl::Channel) -> Self {
2788        Self::new(value)
2789    }
2790}
2791
2792#[cfg(target_os = "fuchsia")]
2793impl fidl::endpoints::FromClient for RemoteServiceSynchronousProxy {
2794    type Protocol = RemoteServiceMarker;
2795
2796    fn from_client(value: fidl::endpoints::ClientEnd<RemoteServiceMarker>) -> Self {
2797        Self::new(value.into_channel())
2798    }
2799}
2800
2801#[derive(Debug, Clone)]
2802pub struct RemoteServiceProxy {
2803    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2804}
2805
2806impl fidl::endpoints::Proxy for RemoteServiceProxy {
2807    type Protocol = RemoteServiceMarker;
2808
2809    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2810        Self::new(inner)
2811    }
2812
2813    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2814        self.client.into_channel().map_err(|client| Self { client })
2815    }
2816
2817    fn as_channel(&self) -> &::fidl::AsyncChannel {
2818        self.client.as_channel()
2819    }
2820}
2821
2822impl RemoteServiceProxy {
2823    /// Create a new Proxy for fuchsia.bluetooth.gatt2/RemoteService.
2824    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2825        let protocol_name = <RemoteServiceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2826        Self { client: fidl::client::Client::new(channel, protocol_name) }
2827    }
2828
2829    /// Get a Stream of events from the remote end of the protocol.
2830    ///
2831    /// # Panics
2832    ///
2833    /// Panics if the event stream was already taken.
2834    pub fn take_event_stream(&self) -> RemoteServiceEventStream {
2835        RemoteServiceEventStream { event_receiver: self.client.take_event_receiver() }
2836    }
2837
2838    /// Returns the characteristics and characteristic descriptors that belong to
2839    /// this service.
2840    pub fn r#discover_characteristics(
2841        &self,
2842    ) -> fidl::client::QueryResponseFut<
2843        Vec<Characteristic>,
2844        fidl::encoding::DefaultFuchsiaResourceDialect,
2845    > {
2846        RemoteServiceProxyInterface::r#discover_characteristics(self)
2847    }
2848
2849    /// Reads characteristics and descriptors with the given `uuid`.
2850    ///
2851    /// This method is useful for reading values before discovery has completed,
2852    /// thereby reducing latency.
2853    ///
2854    /// + request `uuid` The UUID of the characteristics/descriptors to read.
2855    /// - response `results` The results of the read. May be empty if no
2856    ///            matching values are read. If reading a value results in a
2857    ///            permission error, the handle and error will be included.
2858    /// * error Returns `INVALID_PARAMETERS` if `uuid` refers to an internally
2859    ///         reserved descriptor type (e.g. the Client Characteristic
2860    ///         Configuration descriptor).
2861    /// * error Returns `TOO_MANY_RESULTS` if more results were read than can fit
2862    ///         in a FIDL response. Consider reading characteristics/descriptors
2863    ///         individually after performing discovery.
2864    /// * error Returns `FAILURE` if the server returns an error not specific to
2865    ///         a single result.
2866    pub fn r#read_by_type(
2867        &self,
2868        mut uuid: &fidl_fuchsia_bluetooth::Uuid,
2869    ) -> fidl::client::QueryResponseFut<
2870        RemoteServiceReadByTypeResult,
2871        fidl::encoding::DefaultFuchsiaResourceDialect,
2872    > {
2873        RemoteServiceProxyInterface::r#read_by_type(self, uuid)
2874    }
2875
2876    /// Reads the value of a characteristic with the given `handle`.
2877    ///
2878    /// + request `handle` The characteristic handle to read.
2879    /// + request `options` Options that apply to the read.
2880    /// - response `value` The value of the characteristic.
2881    /// * error Returns `INVALID_HANDLE` if `handle` is invalid.
2882    /// * error Returns `INVALID_PARAMETERS` if `options` is invalid.
2883    /// * error Returns `READ_NOT_PERMITTED` or `INSUFFICIENT_*` if the server
2884    ///         rejects the read request.
2885    /// * error Returns `FAILURE` if the server returns an error.
2886    pub fn r#read_characteristic(
2887        &self,
2888        mut handle: &Handle,
2889        mut options: &ReadOptions,
2890    ) -> fidl::client::QueryResponseFut<
2891        RemoteServiceReadCharacteristicResult,
2892        fidl::encoding::DefaultFuchsiaResourceDialect,
2893    > {
2894        RemoteServiceProxyInterface::r#read_characteristic(self, handle, options)
2895    }
2896
2897    /// Writes `value` to the characteristic with `handle` using the provided
2898    /// `options`.
2899    ///
2900    /// It is not recommended to send additional writes while a write is already
2901    /// in progress (the server may receive simultaneous writes in any order).
2902    ///
2903    /// + request `handle` The characteristic to be written to.
2904    /// + request `value` The value to be written.
2905    /// + request `options` Options that apply to the write.
2906    /// - response An empty response will be sent when a success response is
2907    ///            received from the server (or immediately if
2908    ///            `options.with_response` is false)
2909    /// * error Returns `INVALID_HANDLE` if `handle` is invalid.
2910    /// * error Returns `INVALID_PARAMETERS` if `options` is invalid.
2911    /// * error Returns `WRITE_NOT_PERMITTED` or `INSUFFICIENT_*`if the server
2912    ///         rejects the write request with a reason.
2913    /// * error Returns `FAILURE` if the server returns an error.
2914    pub fn r#write_characteristic(
2915        &self,
2916        mut handle: &Handle,
2917        mut value: &[u8],
2918        mut options: &WriteOptions,
2919    ) -> fidl::client::QueryResponseFut<
2920        RemoteServiceWriteCharacteristicResult,
2921        fidl::encoding::DefaultFuchsiaResourceDialect,
2922    > {
2923        RemoteServiceProxyInterface::r#write_characteristic(self, handle, value, options)
2924    }
2925
2926    /// Reads the value of the characteristic descriptor with `handle` and
2927    /// returns it in the reply.
2928    ///
2929    /// + request `handle` The descriptor handle to read.
2930    /// + request `options` Options that apply to the read.
2931    /// - response `value` The value of the descriptor.
2932    /// * error Returns `INVALID_HANDLE` if `handle` is invalid.
2933    /// * error Returns `INVALID_PARAMETERS` if `options` is invalid.
2934    /// * error Returns `READ_NOT_PERMITTED` or `INSUFFICIENT_*` if the server
2935    ///         rejects the read request.
2936    /// * error Returns `FAILURE` if the server returns an error.
2937    pub fn r#read_descriptor(
2938        &self,
2939        mut handle: &Handle,
2940        mut options: &ReadOptions,
2941    ) -> fidl::client::QueryResponseFut<
2942        RemoteServiceReadDescriptorResult,
2943        fidl::encoding::DefaultFuchsiaResourceDialect,
2944    > {
2945        RemoteServiceProxyInterface::r#read_descriptor(self, handle, options)
2946    }
2947
2948    /// Writes `value` to the characteristic descriptor with `handle`.
2949    /// It is not recommended to send additional writes while a write is already
2950    /// in progress (the server may receive simultaneous writes in any order).
2951    ///
2952    /// + request `handle` The descriptor handle to written to.
2953    /// + request `value` The value to be written.
2954    /// + request `options` Options that apply to the write.
2955    /// - response An empty response will be sent when a success response is
2956    ///            received from the server (or immediately if
2957    ///            `options.with_response` is false)
2958    /// * error Returns `INVALID_HANDLE` if `handle` is invalid or refers to an
2959    ///         internally reserved descriptor type (e.g. the Client
2960    ///         Characteristic Configuration descriptor).
2961    /// * error Returns `INVALID_PARAMETERS` if `options` is invalid.
2962    /// * error Returns `WRITE_NOT_PERMITTED` or `INSUFFICIENT_*` if the server
2963    ///         rejects the write with a reason.
2964    /// * error Returns `FAILURE` if the server returns an error.
2965    pub fn r#write_descriptor(
2966        &self,
2967        mut handle: &Handle,
2968        mut value: &[u8],
2969        mut options: &WriteOptions,
2970    ) -> fidl::client::QueryResponseFut<
2971        RemoteServiceWriteDescriptorResult,
2972        fidl::encoding::DefaultFuchsiaResourceDialect,
2973    > {
2974        RemoteServiceProxyInterface::r#write_descriptor(self, handle, value, options)
2975    }
2976
2977    /// Subscribe to notifications & indications from the characteristic with
2978    /// the given `handle`.
2979    ///
2980    /// Either notifications or indications will be enabled depending on
2981    /// characteristic properties. Indications will be preferred if they are
2982    /// supported. This operation fails if the characteristic does not have the
2983    /// "notify" or "indicate" property.
2984    ///
2985    /// A write request will be issued to configure the characteristic for
2986    /// notifications/indications if it contains a Client Characteristic
2987    /// Configuration descriptor. This method fails if an error occurs while
2988    /// writing to the descriptor.
2989    ///
2990    /// On success, the `notifier` protocol can be used to be notified when
2991    /// the peer sends a notification or indication. Indications are
2992    /// automatically confirmed. When the protocol is dropped, the subscription
2993    /// may end if no other local client is receiving notifications.
2994    ///
2995    /// + request `handle` the characteristic handle.
2996    /// + request `notifier` the protocol used for notifications.
2997    /// - response An empty response will be sent immediately if registration
2998    ///            succeeds.
2999    /// * error Returns a `FAILURE` if the characteristic does not support
3000    ///         notifications or indications.
3001    /// * error Returns a `INVALID_HANDLE` if `handle` is invalid.
3002    /// * error Returns a `WRITE_NOT_PERMITTED`  or `INSUFFICIENT_*`for a
3003    ///         descriptor write error.
3004    pub fn r#register_characteristic_notifier(
3005        &self,
3006        mut handle: &Handle,
3007        mut notifier: fidl::endpoints::ClientEnd<CharacteristicNotifierMarker>,
3008    ) -> fidl::client::QueryResponseFut<
3009        RemoteServiceRegisterCharacteristicNotifierResult,
3010        fidl::encoding::DefaultFuchsiaResourceDialect,
3011    > {
3012        RemoteServiceProxyInterface::r#register_characteristic_notifier(self, handle, notifier)
3013    }
3014}
3015
3016impl RemoteServiceProxyInterface for RemoteServiceProxy {
3017    type DiscoverCharacteristicsResponseFut = fidl::client::QueryResponseFut<
3018        Vec<Characteristic>,
3019        fidl::encoding::DefaultFuchsiaResourceDialect,
3020    >;
3021    fn r#discover_characteristics(&self) -> Self::DiscoverCharacteristicsResponseFut {
3022        fn _decode(
3023            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3024        ) -> Result<Vec<Characteristic>, fidl::Error> {
3025            let _response = fidl::client::decode_transaction_body::<
3026                RemoteServiceDiscoverCharacteristicsResponse,
3027                fidl::encoding::DefaultFuchsiaResourceDialect,
3028                0x6cd730f12e402543,
3029            >(_buf?)?;
3030            Ok(_response.characteristics)
3031        }
3032        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<Characteristic>>(
3033            (),
3034            0x6cd730f12e402543,
3035            fidl::encoding::DynamicFlags::empty(),
3036            _decode,
3037        )
3038    }
3039
3040    type ReadByTypeResponseFut = fidl::client::QueryResponseFut<
3041        RemoteServiceReadByTypeResult,
3042        fidl::encoding::DefaultFuchsiaResourceDialect,
3043    >;
3044    fn r#read_by_type(
3045        &self,
3046        mut uuid: &fidl_fuchsia_bluetooth::Uuid,
3047    ) -> Self::ReadByTypeResponseFut {
3048        fn _decode(
3049            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3050        ) -> Result<RemoteServiceReadByTypeResult, fidl::Error> {
3051            let _response = fidl::client::decode_transaction_body::<
3052                fidl::encoding::ResultType<RemoteServiceReadByTypeResponse, Error>,
3053                fidl::encoding::DefaultFuchsiaResourceDialect,
3054                0x739bb1e313162bbc,
3055            >(_buf?)?;
3056            Ok(_response.map(|x| x.results))
3057        }
3058        self.client
3059            .send_query_and_decode::<RemoteServiceReadByTypeRequest, RemoteServiceReadByTypeResult>(
3060                (uuid,),
3061                0x739bb1e313162bbc,
3062                fidl::encoding::DynamicFlags::empty(),
3063                _decode,
3064            )
3065    }
3066
3067    type ReadCharacteristicResponseFut = fidl::client::QueryResponseFut<
3068        RemoteServiceReadCharacteristicResult,
3069        fidl::encoding::DefaultFuchsiaResourceDialect,
3070    >;
3071    fn r#read_characteristic(
3072        &self,
3073        mut handle: &Handle,
3074        mut options: &ReadOptions,
3075    ) -> Self::ReadCharacteristicResponseFut {
3076        fn _decode(
3077            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3078        ) -> Result<RemoteServiceReadCharacteristicResult, fidl::Error> {
3079            let _response = fidl::client::decode_transaction_body::<
3080                fidl::encoding::ResultType<RemoteServiceReadCharacteristicResponse, Error>,
3081                fidl::encoding::DefaultFuchsiaResourceDialect,
3082                0x4d41757ed69a96cb,
3083            >(_buf?)?;
3084            Ok(_response.map(|x| x.value))
3085        }
3086        self.client.send_query_and_decode::<
3087            RemoteServiceReadCharacteristicRequest,
3088            RemoteServiceReadCharacteristicResult,
3089        >(
3090            (handle, options,),
3091            0x4d41757ed69a96cb,
3092            fidl::encoding::DynamicFlags::empty(),
3093            _decode,
3094        )
3095    }
3096
3097    type WriteCharacteristicResponseFut = fidl::client::QueryResponseFut<
3098        RemoteServiceWriteCharacteristicResult,
3099        fidl::encoding::DefaultFuchsiaResourceDialect,
3100    >;
3101    fn r#write_characteristic(
3102        &self,
3103        mut handle: &Handle,
3104        mut value: &[u8],
3105        mut options: &WriteOptions,
3106    ) -> Self::WriteCharacteristicResponseFut {
3107        fn _decode(
3108            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3109        ) -> Result<RemoteServiceWriteCharacteristicResult, fidl::Error> {
3110            let _response = fidl::client::decode_transaction_body::<
3111                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
3112                fidl::encoding::DefaultFuchsiaResourceDialect,
3113                0x7fc7511adecde8c,
3114            >(_buf?)?;
3115            Ok(_response.map(|x| x))
3116        }
3117        self.client.send_query_and_decode::<
3118            RemoteServiceWriteCharacteristicRequest,
3119            RemoteServiceWriteCharacteristicResult,
3120        >(
3121            (handle, value, options,),
3122            0x7fc7511adecde8c,
3123            fidl::encoding::DynamicFlags::empty(),
3124            _decode,
3125        )
3126    }
3127
3128    type ReadDescriptorResponseFut = fidl::client::QueryResponseFut<
3129        RemoteServiceReadDescriptorResult,
3130        fidl::encoding::DefaultFuchsiaResourceDialect,
3131    >;
3132    fn r#read_descriptor(
3133        &self,
3134        mut handle: &Handle,
3135        mut options: &ReadOptions,
3136    ) -> Self::ReadDescriptorResponseFut {
3137        fn _decode(
3138            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3139        ) -> Result<RemoteServiceReadDescriptorResult, fidl::Error> {
3140            let _response = fidl::client::decode_transaction_body::<
3141                fidl::encoding::ResultType<RemoteServiceReadDescriptorResponse, Error>,
3142                fidl::encoding::DefaultFuchsiaResourceDialect,
3143                0x7ed7ce00457dcec1,
3144            >(_buf?)?;
3145            Ok(_response.map(|x| x.value))
3146        }
3147        self.client.send_query_and_decode::<
3148            RemoteServiceReadDescriptorRequest,
3149            RemoteServiceReadDescriptorResult,
3150        >(
3151            (handle, options,),
3152            0x7ed7ce00457dcec1,
3153            fidl::encoding::DynamicFlags::empty(),
3154            _decode,
3155        )
3156    }
3157
3158    type WriteDescriptorResponseFut = fidl::client::QueryResponseFut<
3159        RemoteServiceWriteDescriptorResult,
3160        fidl::encoding::DefaultFuchsiaResourceDialect,
3161    >;
3162    fn r#write_descriptor(
3163        &self,
3164        mut handle: &Handle,
3165        mut value: &[u8],
3166        mut options: &WriteOptions,
3167    ) -> Self::WriteDescriptorResponseFut {
3168        fn _decode(
3169            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3170        ) -> Result<RemoteServiceWriteDescriptorResult, fidl::Error> {
3171            let _response = fidl::client::decode_transaction_body::<
3172                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
3173                fidl::encoding::DefaultFuchsiaResourceDialect,
3174                0x21d9106bfd6b7351,
3175            >(_buf?)?;
3176            Ok(_response.map(|x| x))
3177        }
3178        self.client.send_query_and_decode::<
3179            RemoteServiceWriteDescriptorRequest,
3180            RemoteServiceWriteDescriptorResult,
3181        >(
3182            (handle, value, options,),
3183            0x21d9106bfd6b7351,
3184            fidl::encoding::DynamicFlags::empty(),
3185            _decode,
3186        )
3187    }
3188
3189    type RegisterCharacteristicNotifierResponseFut = fidl::client::QueryResponseFut<
3190        RemoteServiceRegisterCharacteristicNotifierResult,
3191        fidl::encoding::DefaultFuchsiaResourceDialect,
3192    >;
3193    fn r#register_characteristic_notifier(
3194        &self,
3195        mut handle: &Handle,
3196        mut notifier: fidl::endpoints::ClientEnd<CharacteristicNotifierMarker>,
3197    ) -> Self::RegisterCharacteristicNotifierResponseFut {
3198        fn _decode(
3199            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3200        ) -> Result<RemoteServiceRegisterCharacteristicNotifierResult, fidl::Error> {
3201            let _response = fidl::client::decode_transaction_body::<
3202                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
3203                fidl::encoding::DefaultFuchsiaResourceDialect,
3204                0x35007a85245f5cc6,
3205            >(_buf?)?;
3206            Ok(_response.map(|x| x))
3207        }
3208        self.client.send_query_and_decode::<
3209            RemoteServiceRegisterCharacteristicNotifierRequest,
3210            RemoteServiceRegisterCharacteristicNotifierResult,
3211        >(
3212            (handle, notifier,),
3213            0x35007a85245f5cc6,
3214            fidl::encoding::DynamicFlags::empty(),
3215            _decode,
3216        )
3217    }
3218}
3219
3220pub struct RemoteServiceEventStream {
3221    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3222}
3223
3224impl std::marker::Unpin for RemoteServiceEventStream {}
3225
3226impl futures::stream::FusedStream for RemoteServiceEventStream {
3227    fn is_terminated(&self) -> bool {
3228        self.event_receiver.is_terminated()
3229    }
3230}
3231
3232impl futures::Stream for RemoteServiceEventStream {
3233    type Item = Result<RemoteServiceEvent, fidl::Error>;
3234
3235    fn poll_next(
3236        mut self: std::pin::Pin<&mut Self>,
3237        cx: &mut std::task::Context<'_>,
3238    ) -> std::task::Poll<Option<Self::Item>> {
3239        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3240            &mut self.event_receiver,
3241            cx
3242        )?) {
3243            Some(buf) => std::task::Poll::Ready(Some(RemoteServiceEvent::decode(buf))),
3244            None => std::task::Poll::Ready(None),
3245        }
3246    }
3247}
3248
3249#[derive(Debug)]
3250pub enum RemoteServiceEvent {}
3251
3252impl RemoteServiceEvent {
3253    /// Decodes a message buffer as a [`RemoteServiceEvent`].
3254    fn decode(
3255        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3256    ) -> Result<RemoteServiceEvent, fidl::Error> {
3257        let (bytes, _handles) = buf.split_mut();
3258        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3259        debug_assert_eq!(tx_header.tx_id, 0);
3260        match tx_header.ordinal {
3261            _ => Err(fidl::Error::UnknownOrdinal {
3262                ordinal: tx_header.ordinal,
3263                protocol_name: <RemoteServiceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3264            }),
3265        }
3266    }
3267}
3268
3269/// A Stream of incoming requests for fuchsia.bluetooth.gatt2/RemoteService.
3270pub struct RemoteServiceRequestStream {
3271    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3272    is_terminated: bool,
3273}
3274
3275impl std::marker::Unpin for RemoteServiceRequestStream {}
3276
3277impl futures::stream::FusedStream for RemoteServiceRequestStream {
3278    fn is_terminated(&self) -> bool {
3279        self.is_terminated
3280    }
3281}
3282
3283impl fidl::endpoints::RequestStream for RemoteServiceRequestStream {
3284    type Protocol = RemoteServiceMarker;
3285    type ControlHandle = RemoteServiceControlHandle;
3286
3287    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3288        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3289    }
3290
3291    fn control_handle(&self) -> Self::ControlHandle {
3292        RemoteServiceControlHandle { inner: self.inner.clone() }
3293    }
3294
3295    fn into_inner(
3296        self,
3297    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3298    {
3299        (self.inner, self.is_terminated)
3300    }
3301
3302    fn from_inner(
3303        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3304        is_terminated: bool,
3305    ) -> Self {
3306        Self { inner, is_terminated }
3307    }
3308}
3309
3310impl futures::Stream for RemoteServiceRequestStream {
3311    type Item = Result<RemoteServiceRequest, fidl::Error>;
3312
3313    fn poll_next(
3314        mut self: std::pin::Pin<&mut Self>,
3315        cx: &mut std::task::Context<'_>,
3316    ) -> std::task::Poll<Option<Self::Item>> {
3317        let this = &mut *self;
3318        if this.inner.check_shutdown(cx) {
3319            this.is_terminated = true;
3320            return std::task::Poll::Ready(None);
3321        }
3322        if this.is_terminated {
3323            panic!("polled RemoteServiceRequestStream after completion");
3324        }
3325        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3326            |bytes, handles| {
3327                match this.inner.channel().read_etc(cx, bytes, handles) {
3328                    std::task::Poll::Ready(Ok(())) => {}
3329                    std::task::Poll::Pending => return std::task::Poll::Pending,
3330                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3331                        this.is_terminated = true;
3332                        return std::task::Poll::Ready(None);
3333                    }
3334                    std::task::Poll::Ready(Err(e)) => {
3335                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3336                            e.into(),
3337                        ))));
3338                    }
3339                }
3340
3341                // A message has been received from the channel
3342                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3343
3344                std::task::Poll::Ready(Some(match header.ordinal {
3345                    0x6cd730f12e402543 => {
3346                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3347                        let mut req = fidl::new_empty!(
3348                            fidl::encoding::EmptyPayload,
3349                            fidl::encoding::DefaultFuchsiaResourceDialect
3350                        );
3351                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3352                        let control_handle =
3353                            RemoteServiceControlHandle { inner: this.inner.clone() };
3354                        Ok(RemoteServiceRequest::DiscoverCharacteristics {
3355                            responder: RemoteServiceDiscoverCharacteristicsResponder {
3356                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3357                                tx_id: header.tx_id,
3358                            },
3359                        })
3360                    }
3361                    0x739bb1e313162bbc => {
3362                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3363                        let mut req = fidl::new_empty!(
3364                            RemoteServiceReadByTypeRequest,
3365                            fidl::encoding::DefaultFuchsiaResourceDialect
3366                        );
3367                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RemoteServiceReadByTypeRequest>(&header, _body_bytes, handles, &mut req)?;
3368                        let control_handle =
3369                            RemoteServiceControlHandle { inner: this.inner.clone() };
3370                        Ok(RemoteServiceRequest::ReadByType {
3371                            uuid: req.uuid,
3372
3373                            responder: RemoteServiceReadByTypeResponder {
3374                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3375                                tx_id: header.tx_id,
3376                            },
3377                        })
3378                    }
3379                    0x4d41757ed69a96cb => {
3380                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3381                        let mut req = fidl::new_empty!(
3382                            RemoteServiceReadCharacteristicRequest,
3383                            fidl::encoding::DefaultFuchsiaResourceDialect
3384                        );
3385                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RemoteServiceReadCharacteristicRequest>(&header, _body_bytes, handles, &mut req)?;
3386                        let control_handle =
3387                            RemoteServiceControlHandle { inner: this.inner.clone() };
3388                        Ok(RemoteServiceRequest::ReadCharacteristic {
3389                            handle: req.handle,
3390                            options: req.options,
3391
3392                            responder: RemoteServiceReadCharacteristicResponder {
3393                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3394                                tx_id: header.tx_id,
3395                            },
3396                        })
3397                    }
3398                    0x7fc7511adecde8c => {
3399                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3400                        let mut req = fidl::new_empty!(
3401                            RemoteServiceWriteCharacteristicRequest,
3402                            fidl::encoding::DefaultFuchsiaResourceDialect
3403                        );
3404                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RemoteServiceWriteCharacteristicRequest>(&header, _body_bytes, handles, &mut req)?;
3405                        let control_handle =
3406                            RemoteServiceControlHandle { inner: this.inner.clone() };
3407                        Ok(RemoteServiceRequest::WriteCharacteristic {
3408                            handle: req.handle,
3409                            value: req.value,
3410                            options: req.options,
3411
3412                            responder: RemoteServiceWriteCharacteristicResponder {
3413                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3414                                tx_id: header.tx_id,
3415                            },
3416                        })
3417                    }
3418                    0x7ed7ce00457dcec1 => {
3419                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3420                        let mut req = fidl::new_empty!(
3421                            RemoteServiceReadDescriptorRequest,
3422                            fidl::encoding::DefaultFuchsiaResourceDialect
3423                        );
3424                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RemoteServiceReadDescriptorRequest>(&header, _body_bytes, handles, &mut req)?;
3425                        let control_handle =
3426                            RemoteServiceControlHandle { inner: this.inner.clone() };
3427                        Ok(RemoteServiceRequest::ReadDescriptor {
3428                            handle: req.handle,
3429                            options: req.options,
3430
3431                            responder: RemoteServiceReadDescriptorResponder {
3432                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3433                                tx_id: header.tx_id,
3434                            },
3435                        })
3436                    }
3437                    0x21d9106bfd6b7351 => {
3438                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3439                        let mut req = fidl::new_empty!(
3440                            RemoteServiceWriteDescriptorRequest,
3441                            fidl::encoding::DefaultFuchsiaResourceDialect
3442                        );
3443                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RemoteServiceWriteDescriptorRequest>(&header, _body_bytes, handles, &mut req)?;
3444                        let control_handle =
3445                            RemoteServiceControlHandle { inner: this.inner.clone() };
3446                        Ok(RemoteServiceRequest::WriteDescriptor {
3447                            handle: req.handle,
3448                            value: req.value,
3449                            options: req.options,
3450
3451                            responder: RemoteServiceWriteDescriptorResponder {
3452                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3453                                tx_id: header.tx_id,
3454                            },
3455                        })
3456                    }
3457                    0x35007a85245f5cc6 => {
3458                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3459                        let mut req = fidl::new_empty!(
3460                            RemoteServiceRegisterCharacteristicNotifierRequest,
3461                            fidl::encoding::DefaultFuchsiaResourceDialect
3462                        );
3463                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RemoteServiceRegisterCharacteristicNotifierRequest>(&header, _body_bytes, handles, &mut req)?;
3464                        let control_handle =
3465                            RemoteServiceControlHandle { inner: this.inner.clone() };
3466                        Ok(RemoteServiceRequest::RegisterCharacteristicNotifier {
3467                            handle: req.handle,
3468                            notifier: req.notifier,
3469
3470                            responder: RemoteServiceRegisterCharacteristicNotifierResponder {
3471                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3472                                tx_id: header.tx_id,
3473                            },
3474                        })
3475                    }
3476                    _ => Err(fidl::Error::UnknownOrdinal {
3477                        ordinal: header.ordinal,
3478                        protocol_name:
3479                            <RemoteServiceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3480                    }),
3481                }))
3482            },
3483        )
3484    }
3485}
3486
3487#[derive(Debug)]
3488pub enum RemoteServiceRequest {
3489    /// Returns the characteristics and characteristic descriptors that belong to
3490    /// this service.
3491    DiscoverCharacteristics { responder: RemoteServiceDiscoverCharacteristicsResponder },
3492    /// Reads characteristics and descriptors with the given `uuid`.
3493    ///
3494    /// This method is useful for reading values before discovery has completed,
3495    /// thereby reducing latency.
3496    ///
3497    /// + request `uuid` The UUID of the characteristics/descriptors to read.
3498    /// - response `results` The results of the read. May be empty if no
3499    ///            matching values are read. If reading a value results in a
3500    ///            permission error, the handle and error will be included.
3501    /// * error Returns `INVALID_PARAMETERS` if `uuid` refers to an internally
3502    ///         reserved descriptor type (e.g. the Client Characteristic
3503    ///         Configuration descriptor).
3504    /// * error Returns `TOO_MANY_RESULTS` if more results were read than can fit
3505    ///         in a FIDL response. Consider reading characteristics/descriptors
3506    ///         individually after performing discovery.
3507    /// * error Returns `FAILURE` if the server returns an error not specific to
3508    ///         a single result.
3509    ReadByType { uuid: fidl_fuchsia_bluetooth::Uuid, responder: RemoteServiceReadByTypeResponder },
3510    /// Reads the value of a characteristic with the given `handle`.
3511    ///
3512    /// + request `handle` The characteristic handle to read.
3513    /// + request `options` Options that apply to the read.
3514    /// - response `value` The value of the characteristic.
3515    /// * error Returns `INVALID_HANDLE` if `handle` is invalid.
3516    /// * error Returns `INVALID_PARAMETERS` if `options` is invalid.
3517    /// * error Returns `READ_NOT_PERMITTED` or `INSUFFICIENT_*` if the server
3518    ///         rejects the read request.
3519    /// * error Returns `FAILURE` if the server returns an error.
3520    ReadCharacteristic {
3521        handle: Handle,
3522        options: ReadOptions,
3523        responder: RemoteServiceReadCharacteristicResponder,
3524    },
3525    /// Writes `value` to the characteristic with `handle` using the provided
3526    /// `options`.
3527    ///
3528    /// It is not recommended to send additional writes while a write is already
3529    /// in progress (the server may receive simultaneous writes in any order).
3530    ///
3531    /// + request `handle` The characteristic to be written to.
3532    /// + request `value` The value to be written.
3533    /// + request `options` Options that apply to the write.
3534    /// - response An empty response will be sent when a success response is
3535    ///            received from the server (or immediately if
3536    ///            `options.with_response` is false)
3537    /// * error Returns `INVALID_HANDLE` if `handle` is invalid.
3538    /// * error Returns `INVALID_PARAMETERS` if `options` is invalid.
3539    /// * error Returns `WRITE_NOT_PERMITTED` or `INSUFFICIENT_*`if the server
3540    ///         rejects the write request with a reason.
3541    /// * error Returns `FAILURE` if the server returns an error.
3542    WriteCharacteristic {
3543        handle: Handle,
3544        value: Vec<u8>,
3545        options: WriteOptions,
3546        responder: RemoteServiceWriteCharacteristicResponder,
3547    },
3548    /// Reads the value of the characteristic descriptor with `handle` and
3549    /// returns it in the reply.
3550    ///
3551    /// + request `handle` The descriptor handle to read.
3552    /// + request `options` Options that apply to the read.
3553    /// - response `value` The value of the descriptor.
3554    /// * error Returns `INVALID_HANDLE` if `handle` is invalid.
3555    /// * error Returns `INVALID_PARAMETERS` if `options` is invalid.
3556    /// * error Returns `READ_NOT_PERMITTED` or `INSUFFICIENT_*` if the server
3557    ///         rejects the read request.
3558    /// * error Returns `FAILURE` if the server returns an error.
3559    ReadDescriptor {
3560        handle: Handle,
3561        options: ReadOptions,
3562        responder: RemoteServiceReadDescriptorResponder,
3563    },
3564    /// Writes `value` to the characteristic descriptor with `handle`.
3565    /// It is not recommended to send additional writes while a write is already
3566    /// in progress (the server may receive simultaneous writes in any order).
3567    ///
3568    /// + request `handle` The descriptor handle to written to.
3569    /// + request `value` The value to be written.
3570    /// + request `options` Options that apply to the write.
3571    /// - response An empty response will be sent when a success response is
3572    ///            received from the server (or immediately if
3573    ///            `options.with_response` is false)
3574    /// * error Returns `INVALID_HANDLE` if `handle` is invalid or refers to an
3575    ///         internally reserved descriptor type (e.g. the Client
3576    ///         Characteristic Configuration descriptor).
3577    /// * error Returns `INVALID_PARAMETERS` if `options` is invalid.
3578    /// * error Returns `WRITE_NOT_PERMITTED` or `INSUFFICIENT_*` if the server
3579    ///         rejects the write with a reason.
3580    /// * error Returns `FAILURE` if the server returns an error.
3581    WriteDescriptor {
3582        handle: Handle,
3583        value: Vec<u8>,
3584        options: WriteOptions,
3585        responder: RemoteServiceWriteDescriptorResponder,
3586    },
3587    /// Subscribe to notifications & indications from the characteristic with
3588    /// the given `handle`.
3589    ///
3590    /// Either notifications or indications will be enabled depending on
3591    /// characteristic properties. Indications will be preferred if they are
3592    /// supported. This operation fails if the characteristic does not have the
3593    /// "notify" or "indicate" property.
3594    ///
3595    /// A write request will be issued to configure the characteristic for
3596    /// notifications/indications if it contains a Client Characteristic
3597    /// Configuration descriptor. This method fails if an error occurs while
3598    /// writing to the descriptor.
3599    ///
3600    /// On success, the `notifier` protocol can be used to be notified when
3601    /// the peer sends a notification or indication. Indications are
3602    /// automatically confirmed. When the protocol is dropped, the subscription
3603    /// may end if no other local client is receiving notifications.
3604    ///
3605    /// + request `handle` the characteristic handle.
3606    /// + request `notifier` the protocol used for notifications.
3607    /// - response An empty response will be sent immediately if registration
3608    ///            succeeds.
3609    /// * error Returns a `FAILURE` if the characteristic does not support
3610    ///         notifications or indications.
3611    /// * error Returns a `INVALID_HANDLE` if `handle` is invalid.
3612    /// * error Returns a `WRITE_NOT_PERMITTED`  or `INSUFFICIENT_*`for a
3613    ///         descriptor write error.
3614    RegisterCharacteristicNotifier {
3615        handle: Handle,
3616        notifier: fidl::endpoints::ClientEnd<CharacteristicNotifierMarker>,
3617        responder: RemoteServiceRegisterCharacteristicNotifierResponder,
3618    },
3619}
3620
3621impl RemoteServiceRequest {
3622    #[allow(irrefutable_let_patterns)]
3623    pub fn into_discover_characteristics(
3624        self,
3625    ) -> Option<(RemoteServiceDiscoverCharacteristicsResponder)> {
3626        if let RemoteServiceRequest::DiscoverCharacteristics { responder } = self {
3627            Some((responder))
3628        } else {
3629            None
3630        }
3631    }
3632
3633    #[allow(irrefutable_let_patterns)]
3634    pub fn into_read_by_type(
3635        self,
3636    ) -> Option<(fidl_fuchsia_bluetooth::Uuid, RemoteServiceReadByTypeResponder)> {
3637        if let RemoteServiceRequest::ReadByType { uuid, responder } = self {
3638            Some((uuid, responder))
3639        } else {
3640            None
3641        }
3642    }
3643
3644    #[allow(irrefutable_let_patterns)]
3645    pub fn into_read_characteristic(
3646        self,
3647    ) -> Option<(Handle, ReadOptions, RemoteServiceReadCharacteristicResponder)> {
3648        if let RemoteServiceRequest::ReadCharacteristic { handle, options, responder } = self {
3649            Some((handle, options, responder))
3650        } else {
3651            None
3652        }
3653    }
3654
3655    #[allow(irrefutable_let_patterns)]
3656    pub fn into_write_characteristic(
3657        self,
3658    ) -> Option<(Handle, Vec<u8>, WriteOptions, RemoteServiceWriteCharacteristicResponder)> {
3659        if let RemoteServiceRequest::WriteCharacteristic { handle, value, options, responder } =
3660            self
3661        {
3662            Some((handle, value, options, responder))
3663        } else {
3664            None
3665        }
3666    }
3667
3668    #[allow(irrefutable_let_patterns)]
3669    pub fn into_read_descriptor(
3670        self,
3671    ) -> Option<(Handle, ReadOptions, RemoteServiceReadDescriptorResponder)> {
3672        if let RemoteServiceRequest::ReadDescriptor { handle, options, responder } = self {
3673            Some((handle, options, responder))
3674        } else {
3675            None
3676        }
3677    }
3678
3679    #[allow(irrefutable_let_patterns)]
3680    pub fn into_write_descriptor(
3681        self,
3682    ) -> Option<(Handle, Vec<u8>, WriteOptions, RemoteServiceWriteDescriptorResponder)> {
3683        if let RemoteServiceRequest::WriteDescriptor { handle, value, options, responder } = self {
3684            Some((handle, value, options, responder))
3685        } else {
3686            None
3687        }
3688    }
3689
3690    #[allow(irrefutable_let_patterns)]
3691    pub fn into_register_characteristic_notifier(
3692        self,
3693    ) -> Option<(
3694        Handle,
3695        fidl::endpoints::ClientEnd<CharacteristicNotifierMarker>,
3696        RemoteServiceRegisterCharacteristicNotifierResponder,
3697    )> {
3698        if let RemoteServiceRequest::RegisterCharacteristicNotifier {
3699            handle,
3700            notifier,
3701            responder,
3702        } = self
3703        {
3704            Some((handle, notifier, responder))
3705        } else {
3706            None
3707        }
3708    }
3709
3710    /// Name of the method defined in FIDL
3711    pub fn method_name(&self) -> &'static str {
3712        match *self {
3713            RemoteServiceRequest::DiscoverCharacteristics { .. } => "discover_characteristics",
3714            RemoteServiceRequest::ReadByType { .. } => "read_by_type",
3715            RemoteServiceRequest::ReadCharacteristic { .. } => "read_characteristic",
3716            RemoteServiceRequest::WriteCharacteristic { .. } => "write_characteristic",
3717            RemoteServiceRequest::ReadDescriptor { .. } => "read_descriptor",
3718            RemoteServiceRequest::WriteDescriptor { .. } => "write_descriptor",
3719            RemoteServiceRequest::RegisterCharacteristicNotifier { .. } => {
3720                "register_characteristic_notifier"
3721            }
3722        }
3723    }
3724}
3725
3726#[derive(Debug, Clone)]
3727pub struct RemoteServiceControlHandle {
3728    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3729}
3730
3731impl fidl::endpoints::ControlHandle for RemoteServiceControlHandle {
3732    fn shutdown(&self) {
3733        self.inner.shutdown()
3734    }
3735    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3736        self.inner.shutdown_with_epitaph(status)
3737    }
3738
3739    fn is_closed(&self) -> bool {
3740        self.inner.channel().is_closed()
3741    }
3742    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3743        self.inner.channel().on_closed()
3744    }
3745
3746    #[cfg(target_os = "fuchsia")]
3747    fn signal_peer(
3748        &self,
3749        clear_mask: zx::Signals,
3750        set_mask: zx::Signals,
3751    ) -> Result<(), zx_status::Status> {
3752        use fidl::Peered;
3753        self.inner.channel().signal_peer(clear_mask, set_mask)
3754    }
3755}
3756
3757impl RemoteServiceControlHandle {}
3758
3759#[must_use = "FIDL methods require a response to be sent"]
3760#[derive(Debug)]
3761pub struct RemoteServiceDiscoverCharacteristicsResponder {
3762    control_handle: std::mem::ManuallyDrop<RemoteServiceControlHandle>,
3763    tx_id: u32,
3764}
3765
3766/// Set the the channel to be shutdown (see [`RemoteServiceControlHandle::shutdown`])
3767/// if the responder is dropped without sending a response, so that the client
3768/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3769impl std::ops::Drop for RemoteServiceDiscoverCharacteristicsResponder {
3770    fn drop(&mut self) {
3771        self.control_handle.shutdown();
3772        // Safety: drops once, never accessed again
3773        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3774    }
3775}
3776
3777impl fidl::endpoints::Responder for RemoteServiceDiscoverCharacteristicsResponder {
3778    type ControlHandle = RemoteServiceControlHandle;
3779
3780    fn control_handle(&self) -> &RemoteServiceControlHandle {
3781        &self.control_handle
3782    }
3783
3784    fn drop_without_shutdown(mut self) {
3785        // Safety: drops once, never accessed again due to mem::forget
3786        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3787        // Prevent Drop from running (which would shut down the channel)
3788        std::mem::forget(self);
3789    }
3790}
3791
3792impl RemoteServiceDiscoverCharacteristicsResponder {
3793    /// Sends a response to the FIDL transaction.
3794    ///
3795    /// Sets the channel to shutdown if an error occurs.
3796    pub fn send(self, mut characteristics: &[Characteristic]) -> Result<(), fidl::Error> {
3797        let _result = self.send_raw(characteristics);
3798        if _result.is_err() {
3799            self.control_handle.shutdown();
3800        }
3801        self.drop_without_shutdown();
3802        _result
3803    }
3804
3805    /// Similar to "send" but does not shutdown the channel if an error occurs.
3806    pub fn send_no_shutdown_on_err(
3807        self,
3808        mut characteristics: &[Characteristic],
3809    ) -> Result<(), fidl::Error> {
3810        let _result = self.send_raw(characteristics);
3811        self.drop_without_shutdown();
3812        _result
3813    }
3814
3815    fn send_raw(&self, mut characteristics: &[Characteristic]) -> Result<(), fidl::Error> {
3816        self.control_handle.inner.send::<RemoteServiceDiscoverCharacteristicsResponse>(
3817            (characteristics,),
3818            self.tx_id,
3819            0x6cd730f12e402543,
3820            fidl::encoding::DynamicFlags::empty(),
3821        )
3822    }
3823}
3824
3825#[must_use = "FIDL methods require a response to be sent"]
3826#[derive(Debug)]
3827pub struct RemoteServiceReadByTypeResponder {
3828    control_handle: std::mem::ManuallyDrop<RemoteServiceControlHandle>,
3829    tx_id: u32,
3830}
3831
3832/// Set the the channel to be shutdown (see [`RemoteServiceControlHandle::shutdown`])
3833/// if the responder is dropped without sending a response, so that the client
3834/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3835impl std::ops::Drop for RemoteServiceReadByTypeResponder {
3836    fn drop(&mut self) {
3837        self.control_handle.shutdown();
3838        // Safety: drops once, never accessed again
3839        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3840    }
3841}
3842
3843impl fidl::endpoints::Responder for RemoteServiceReadByTypeResponder {
3844    type ControlHandle = RemoteServiceControlHandle;
3845
3846    fn control_handle(&self) -> &RemoteServiceControlHandle {
3847        &self.control_handle
3848    }
3849
3850    fn drop_without_shutdown(mut self) {
3851        // Safety: drops once, never accessed again due to mem::forget
3852        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3853        // Prevent Drop from running (which would shut down the channel)
3854        std::mem::forget(self);
3855    }
3856}
3857
3858impl RemoteServiceReadByTypeResponder {
3859    /// Sends a response to the FIDL transaction.
3860    ///
3861    /// Sets the channel to shutdown if an error occurs.
3862    pub fn send(self, mut result: Result<&[ReadByTypeResult], Error>) -> Result<(), fidl::Error> {
3863        let _result = self.send_raw(result);
3864        if _result.is_err() {
3865            self.control_handle.shutdown();
3866        }
3867        self.drop_without_shutdown();
3868        _result
3869    }
3870
3871    /// Similar to "send" but does not shutdown the channel if an error occurs.
3872    pub fn send_no_shutdown_on_err(
3873        self,
3874        mut result: Result<&[ReadByTypeResult], Error>,
3875    ) -> Result<(), fidl::Error> {
3876        let _result = self.send_raw(result);
3877        self.drop_without_shutdown();
3878        _result
3879    }
3880
3881    fn send_raw(&self, mut result: Result<&[ReadByTypeResult], Error>) -> Result<(), fidl::Error> {
3882        self.control_handle
3883            .inner
3884            .send::<fidl::encoding::ResultType<RemoteServiceReadByTypeResponse, Error>>(
3885                result.map(|results| (results,)),
3886                self.tx_id,
3887                0x739bb1e313162bbc,
3888                fidl::encoding::DynamicFlags::empty(),
3889            )
3890    }
3891}
3892
3893#[must_use = "FIDL methods require a response to be sent"]
3894#[derive(Debug)]
3895pub struct RemoteServiceReadCharacteristicResponder {
3896    control_handle: std::mem::ManuallyDrop<RemoteServiceControlHandle>,
3897    tx_id: u32,
3898}
3899
3900/// Set the the channel to be shutdown (see [`RemoteServiceControlHandle::shutdown`])
3901/// if the responder is dropped without sending a response, so that the client
3902/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3903impl std::ops::Drop for RemoteServiceReadCharacteristicResponder {
3904    fn drop(&mut self) {
3905        self.control_handle.shutdown();
3906        // Safety: drops once, never accessed again
3907        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3908    }
3909}
3910
3911impl fidl::endpoints::Responder for RemoteServiceReadCharacteristicResponder {
3912    type ControlHandle = RemoteServiceControlHandle;
3913
3914    fn control_handle(&self) -> &RemoteServiceControlHandle {
3915        &self.control_handle
3916    }
3917
3918    fn drop_without_shutdown(mut self) {
3919        // Safety: drops once, never accessed again due to mem::forget
3920        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3921        // Prevent Drop from running (which would shut down the channel)
3922        std::mem::forget(self);
3923    }
3924}
3925
3926impl RemoteServiceReadCharacteristicResponder {
3927    /// Sends a response to the FIDL transaction.
3928    ///
3929    /// Sets the channel to shutdown if an error occurs.
3930    pub fn send(self, mut result: Result<&ReadValue, Error>) -> Result<(), fidl::Error> {
3931        let _result = self.send_raw(result);
3932        if _result.is_err() {
3933            self.control_handle.shutdown();
3934        }
3935        self.drop_without_shutdown();
3936        _result
3937    }
3938
3939    /// Similar to "send" but does not shutdown the channel if an error occurs.
3940    pub fn send_no_shutdown_on_err(
3941        self,
3942        mut result: Result<&ReadValue, Error>,
3943    ) -> Result<(), fidl::Error> {
3944        let _result = self.send_raw(result);
3945        self.drop_without_shutdown();
3946        _result
3947    }
3948
3949    fn send_raw(&self, mut result: Result<&ReadValue, Error>) -> Result<(), fidl::Error> {
3950        self.control_handle.inner.send::<fidl::encoding::ResultType<
3951            RemoteServiceReadCharacteristicResponse,
3952            Error,
3953        >>(
3954            result.map(|value| (value,)),
3955            self.tx_id,
3956            0x4d41757ed69a96cb,
3957            fidl::encoding::DynamicFlags::empty(),
3958        )
3959    }
3960}
3961
3962#[must_use = "FIDL methods require a response to be sent"]
3963#[derive(Debug)]
3964pub struct RemoteServiceWriteCharacteristicResponder {
3965    control_handle: std::mem::ManuallyDrop<RemoteServiceControlHandle>,
3966    tx_id: u32,
3967}
3968
3969/// Set the the channel to be shutdown (see [`RemoteServiceControlHandle::shutdown`])
3970/// if the responder is dropped without sending a response, so that the client
3971/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3972impl std::ops::Drop for RemoteServiceWriteCharacteristicResponder {
3973    fn drop(&mut self) {
3974        self.control_handle.shutdown();
3975        // Safety: drops once, never accessed again
3976        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3977    }
3978}
3979
3980impl fidl::endpoints::Responder for RemoteServiceWriteCharacteristicResponder {
3981    type ControlHandle = RemoteServiceControlHandle;
3982
3983    fn control_handle(&self) -> &RemoteServiceControlHandle {
3984        &self.control_handle
3985    }
3986
3987    fn drop_without_shutdown(mut self) {
3988        // Safety: drops once, never accessed again due to mem::forget
3989        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3990        // Prevent Drop from running (which would shut down the channel)
3991        std::mem::forget(self);
3992    }
3993}
3994
3995impl RemoteServiceWriteCharacteristicResponder {
3996    /// Sends a response to the FIDL transaction.
3997    ///
3998    /// Sets the channel to shutdown if an error occurs.
3999    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4000        let _result = self.send_raw(result);
4001        if _result.is_err() {
4002            self.control_handle.shutdown();
4003        }
4004        self.drop_without_shutdown();
4005        _result
4006    }
4007
4008    /// Similar to "send" but does not shutdown the channel if an error occurs.
4009    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4010        let _result = self.send_raw(result);
4011        self.drop_without_shutdown();
4012        _result
4013    }
4014
4015    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4016        self.control_handle
4017            .inner
4018            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
4019                result,
4020                self.tx_id,
4021                0x7fc7511adecde8c,
4022                fidl::encoding::DynamicFlags::empty(),
4023            )
4024    }
4025}
4026
4027#[must_use = "FIDL methods require a response to be sent"]
4028#[derive(Debug)]
4029pub struct RemoteServiceReadDescriptorResponder {
4030    control_handle: std::mem::ManuallyDrop<RemoteServiceControlHandle>,
4031    tx_id: u32,
4032}
4033
4034/// Set the the channel to be shutdown (see [`RemoteServiceControlHandle::shutdown`])
4035/// if the responder is dropped without sending a response, so that the client
4036/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4037impl std::ops::Drop for RemoteServiceReadDescriptorResponder {
4038    fn drop(&mut self) {
4039        self.control_handle.shutdown();
4040        // Safety: drops once, never accessed again
4041        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4042    }
4043}
4044
4045impl fidl::endpoints::Responder for RemoteServiceReadDescriptorResponder {
4046    type ControlHandle = RemoteServiceControlHandle;
4047
4048    fn control_handle(&self) -> &RemoteServiceControlHandle {
4049        &self.control_handle
4050    }
4051
4052    fn drop_without_shutdown(mut self) {
4053        // Safety: drops once, never accessed again due to mem::forget
4054        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4055        // Prevent Drop from running (which would shut down the channel)
4056        std::mem::forget(self);
4057    }
4058}
4059
4060impl RemoteServiceReadDescriptorResponder {
4061    /// Sends a response to the FIDL transaction.
4062    ///
4063    /// Sets the channel to shutdown if an error occurs.
4064    pub fn send(self, mut result: Result<&ReadValue, Error>) -> Result<(), fidl::Error> {
4065        let _result = self.send_raw(result);
4066        if _result.is_err() {
4067            self.control_handle.shutdown();
4068        }
4069        self.drop_without_shutdown();
4070        _result
4071    }
4072
4073    /// Similar to "send" but does not shutdown the channel if an error occurs.
4074    pub fn send_no_shutdown_on_err(
4075        self,
4076        mut result: Result<&ReadValue, Error>,
4077    ) -> Result<(), fidl::Error> {
4078        let _result = self.send_raw(result);
4079        self.drop_without_shutdown();
4080        _result
4081    }
4082
4083    fn send_raw(&self, mut result: Result<&ReadValue, Error>) -> Result<(), fidl::Error> {
4084        self.control_handle.inner.send::<fidl::encoding::ResultType<
4085            RemoteServiceReadDescriptorResponse,
4086            Error,
4087        >>(
4088            result.map(|value| (value,)),
4089            self.tx_id,
4090            0x7ed7ce00457dcec1,
4091            fidl::encoding::DynamicFlags::empty(),
4092        )
4093    }
4094}
4095
4096#[must_use = "FIDL methods require a response to be sent"]
4097#[derive(Debug)]
4098pub struct RemoteServiceWriteDescriptorResponder {
4099    control_handle: std::mem::ManuallyDrop<RemoteServiceControlHandle>,
4100    tx_id: u32,
4101}
4102
4103/// Set the the channel to be shutdown (see [`RemoteServiceControlHandle::shutdown`])
4104/// if the responder is dropped without sending a response, so that the client
4105/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4106impl std::ops::Drop for RemoteServiceWriteDescriptorResponder {
4107    fn drop(&mut self) {
4108        self.control_handle.shutdown();
4109        // Safety: drops once, never accessed again
4110        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4111    }
4112}
4113
4114impl fidl::endpoints::Responder for RemoteServiceWriteDescriptorResponder {
4115    type ControlHandle = RemoteServiceControlHandle;
4116
4117    fn control_handle(&self) -> &RemoteServiceControlHandle {
4118        &self.control_handle
4119    }
4120
4121    fn drop_without_shutdown(mut self) {
4122        // Safety: drops once, never accessed again due to mem::forget
4123        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4124        // Prevent Drop from running (which would shut down the channel)
4125        std::mem::forget(self);
4126    }
4127}
4128
4129impl RemoteServiceWriteDescriptorResponder {
4130    /// Sends a response to the FIDL transaction.
4131    ///
4132    /// Sets the channel to shutdown if an error occurs.
4133    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4134        let _result = self.send_raw(result);
4135        if _result.is_err() {
4136            self.control_handle.shutdown();
4137        }
4138        self.drop_without_shutdown();
4139        _result
4140    }
4141
4142    /// Similar to "send" but does not shutdown the channel if an error occurs.
4143    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4144        let _result = self.send_raw(result);
4145        self.drop_without_shutdown();
4146        _result
4147    }
4148
4149    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4150        self.control_handle
4151            .inner
4152            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
4153                result,
4154                self.tx_id,
4155                0x21d9106bfd6b7351,
4156                fidl::encoding::DynamicFlags::empty(),
4157            )
4158    }
4159}
4160
4161#[must_use = "FIDL methods require a response to be sent"]
4162#[derive(Debug)]
4163pub struct RemoteServiceRegisterCharacteristicNotifierResponder {
4164    control_handle: std::mem::ManuallyDrop<RemoteServiceControlHandle>,
4165    tx_id: u32,
4166}
4167
4168/// Set the the channel to be shutdown (see [`RemoteServiceControlHandle::shutdown`])
4169/// if the responder is dropped without sending a response, so that the client
4170/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4171impl std::ops::Drop for RemoteServiceRegisterCharacteristicNotifierResponder {
4172    fn drop(&mut self) {
4173        self.control_handle.shutdown();
4174        // Safety: drops once, never accessed again
4175        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4176    }
4177}
4178
4179impl fidl::endpoints::Responder for RemoteServiceRegisterCharacteristicNotifierResponder {
4180    type ControlHandle = RemoteServiceControlHandle;
4181
4182    fn control_handle(&self) -> &RemoteServiceControlHandle {
4183        &self.control_handle
4184    }
4185
4186    fn drop_without_shutdown(mut self) {
4187        // Safety: drops once, never accessed again due to mem::forget
4188        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4189        // Prevent Drop from running (which would shut down the channel)
4190        std::mem::forget(self);
4191    }
4192}
4193
4194impl RemoteServiceRegisterCharacteristicNotifierResponder {
4195    /// Sends a response to the FIDL transaction.
4196    ///
4197    /// Sets the channel to shutdown if an error occurs.
4198    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4199        let _result = self.send_raw(result);
4200        if _result.is_err() {
4201            self.control_handle.shutdown();
4202        }
4203        self.drop_without_shutdown();
4204        _result
4205    }
4206
4207    /// Similar to "send" but does not shutdown the channel if an error occurs.
4208    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4209        let _result = self.send_raw(result);
4210        self.drop_without_shutdown();
4211        _result
4212    }
4213
4214    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4215        self.control_handle
4216            .inner
4217            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
4218                result,
4219                self.tx_id,
4220                0x35007a85245f5cc6,
4221                fidl::encoding::DynamicFlags::empty(),
4222            )
4223    }
4224}
4225
4226#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4227pub struct Server_Marker;
4228
4229impl fidl::endpoints::ProtocolMarker for Server_Marker {
4230    type Proxy = Server_Proxy;
4231    type RequestStream = Server_RequestStream;
4232    #[cfg(target_os = "fuchsia")]
4233    type SynchronousProxy = Server_SynchronousProxy;
4234
4235    const DEBUG_NAME: &'static str = "fuchsia.bluetooth.gatt2.Server";
4236}
4237impl fidl::endpoints::DiscoverableProtocolMarker for Server_Marker {}
4238pub type ServerPublishServiceResult = Result<(), PublishServiceError>;
4239
4240pub trait Server_ProxyInterface: Send + Sync {
4241    type PublishServiceResponseFut: std::future::Future<Output = Result<ServerPublishServiceResult, fidl::Error>>
4242        + Send;
4243    fn r#publish_service(
4244        &self,
4245        info: &ServiceInfo,
4246        service: fidl::endpoints::ClientEnd<LocalServiceMarker>,
4247    ) -> Self::PublishServiceResponseFut;
4248}
4249#[derive(Debug)]
4250#[cfg(target_os = "fuchsia")]
4251pub struct Server_SynchronousProxy {
4252    client: fidl::client::sync::Client,
4253}
4254
4255#[cfg(target_os = "fuchsia")]
4256impl fidl::endpoints::SynchronousProxy for Server_SynchronousProxy {
4257    type Proxy = Server_Proxy;
4258    type Protocol = Server_Marker;
4259
4260    fn from_channel(inner: fidl::Channel) -> Self {
4261        Self::new(inner)
4262    }
4263
4264    fn into_channel(self) -> fidl::Channel {
4265        self.client.into_channel()
4266    }
4267
4268    fn as_channel(&self) -> &fidl::Channel {
4269        self.client.as_channel()
4270    }
4271}
4272
4273#[cfg(target_os = "fuchsia")]
4274impl Server_SynchronousProxy {
4275    pub fn new(channel: fidl::Channel) -> Self {
4276        let protocol_name = <Server_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4277        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
4278    }
4279
4280    pub fn into_channel(self) -> fidl::Channel {
4281        self.client.into_channel()
4282    }
4283
4284    /// Waits until an event arrives and returns it. It is safe for other
4285    /// threads to make concurrent requests while waiting for an event.
4286    pub fn wait_for_event(
4287        &self,
4288        deadline: zx::MonotonicInstant,
4289    ) -> Result<Server_Event, fidl::Error> {
4290        Server_Event::decode(self.client.wait_for_event(deadline)?)
4291    }
4292
4293    /// Publishes the given `service` so that it is available to all remote peers. Upon publication,
4294    /// the service is defined to have INITIAL_VALUE_CHANGED_CREDITS credits available for sending
4295    /// indications/notifications.
4296    ///
4297    /// The caller must assign distinct handles to the characteristics and descriptors listed in
4298    /// `info`. These identifiers will be used in requests sent to `service`.
4299    ///
4300    /// + request `info` Defines the structure of the GATT service. Includes characteristics and
4301    ///   descriptors that will be made available to peers, as well as the service handle, which is
4302    ///   required to be unique across all services published to this Server.
4303    /// + request `service` Provides the implementation of the service per the documented behavior
4304    ///   of a `LocalService`.
4305    /// - response An empty response indicates the service was successfully published.
4306    /// * error See `gatt2.PublishServiceError` for possible failure modes.
4307    pub fn r#publish_service(
4308        &self,
4309        mut info: &ServiceInfo,
4310        mut service: fidl::endpoints::ClientEnd<LocalServiceMarker>,
4311        ___deadline: zx::MonotonicInstant,
4312    ) -> Result<ServerPublishServiceResult, fidl::Error> {
4313        let _response =
4314            self.client.send_query::<ServerPublishServiceRequest, fidl::encoding::ResultType<
4315                fidl::encoding::EmptyStruct,
4316                PublishServiceError,
4317            >>(
4318                (info, service),
4319                0x3110442f2077bfe2,
4320                fidl::encoding::DynamicFlags::empty(),
4321                ___deadline,
4322            )?;
4323        Ok(_response.map(|x| x))
4324    }
4325}
4326
4327#[cfg(target_os = "fuchsia")]
4328impl From<Server_SynchronousProxy> for zx::Handle {
4329    fn from(value: Server_SynchronousProxy) -> Self {
4330        value.into_channel().into()
4331    }
4332}
4333
4334#[cfg(target_os = "fuchsia")]
4335impl From<fidl::Channel> for Server_SynchronousProxy {
4336    fn from(value: fidl::Channel) -> Self {
4337        Self::new(value)
4338    }
4339}
4340
4341#[cfg(target_os = "fuchsia")]
4342impl fidl::endpoints::FromClient for Server_SynchronousProxy {
4343    type Protocol = Server_Marker;
4344
4345    fn from_client(value: fidl::endpoints::ClientEnd<Server_Marker>) -> Self {
4346        Self::new(value.into_channel())
4347    }
4348}
4349
4350#[derive(Debug, Clone)]
4351pub struct Server_Proxy {
4352    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4353}
4354
4355impl fidl::endpoints::Proxy for Server_Proxy {
4356    type Protocol = Server_Marker;
4357
4358    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4359        Self::new(inner)
4360    }
4361
4362    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4363        self.client.into_channel().map_err(|client| Self { client })
4364    }
4365
4366    fn as_channel(&self) -> &::fidl::AsyncChannel {
4367        self.client.as_channel()
4368    }
4369}
4370
4371impl Server_Proxy {
4372    /// Create a new Proxy for fuchsia.bluetooth.gatt2/Server.
4373    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4374        let protocol_name = <Server_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4375        Self { client: fidl::client::Client::new(channel, protocol_name) }
4376    }
4377
4378    /// Get a Stream of events from the remote end of the protocol.
4379    ///
4380    /// # Panics
4381    ///
4382    /// Panics if the event stream was already taken.
4383    pub fn take_event_stream(&self) -> Server_EventStream {
4384        Server_EventStream { event_receiver: self.client.take_event_receiver() }
4385    }
4386
4387    /// Publishes the given `service` so that it is available to all remote peers. Upon publication,
4388    /// the service is defined to have INITIAL_VALUE_CHANGED_CREDITS credits available for sending
4389    /// indications/notifications.
4390    ///
4391    /// The caller must assign distinct handles to the characteristics and descriptors listed in
4392    /// `info`. These identifiers will be used in requests sent to `service`.
4393    ///
4394    /// + request `info` Defines the structure of the GATT service. Includes characteristics and
4395    ///   descriptors that will be made available to peers, as well as the service handle, which is
4396    ///   required to be unique across all services published to this Server.
4397    /// + request `service` Provides the implementation of the service per the documented behavior
4398    ///   of a `LocalService`.
4399    /// - response An empty response indicates the service was successfully published.
4400    /// * error See `gatt2.PublishServiceError` for possible failure modes.
4401    pub fn r#publish_service(
4402        &self,
4403        mut info: &ServiceInfo,
4404        mut service: fidl::endpoints::ClientEnd<LocalServiceMarker>,
4405    ) -> fidl::client::QueryResponseFut<
4406        ServerPublishServiceResult,
4407        fidl::encoding::DefaultFuchsiaResourceDialect,
4408    > {
4409        Server_ProxyInterface::r#publish_service(self, info, service)
4410    }
4411}
4412
4413impl Server_ProxyInterface for Server_Proxy {
4414    type PublishServiceResponseFut = fidl::client::QueryResponseFut<
4415        ServerPublishServiceResult,
4416        fidl::encoding::DefaultFuchsiaResourceDialect,
4417    >;
4418    fn r#publish_service(
4419        &self,
4420        mut info: &ServiceInfo,
4421        mut service: fidl::endpoints::ClientEnd<LocalServiceMarker>,
4422    ) -> Self::PublishServiceResponseFut {
4423        fn _decode(
4424            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4425        ) -> Result<ServerPublishServiceResult, fidl::Error> {
4426            let _response = fidl::client::decode_transaction_body::<
4427                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PublishServiceError>,
4428                fidl::encoding::DefaultFuchsiaResourceDialect,
4429                0x3110442f2077bfe2,
4430            >(_buf?)?;
4431            Ok(_response.map(|x| x))
4432        }
4433        self.client
4434            .send_query_and_decode::<ServerPublishServiceRequest, ServerPublishServiceResult>(
4435                (info, service),
4436                0x3110442f2077bfe2,
4437                fidl::encoding::DynamicFlags::empty(),
4438                _decode,
4439            )
4440    }
4441}
4442
4443pub struct Server_EventStream {
4444    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4445}
4446
4447impl std::marker::Unpin for Server_EventStream {}
4448
4449impl futures::stream::FusedStream for Server_EventStream {
4450    fn is_terminated(&self) -> bool {
4451        self.event_receiver.is_terminated()
4452    }
4453}
4454
4455impl futures::Stream for Server_EventStream {
4456    type Item = Result<Server_Event, fidl::Error>;
4457
4458    fn poll_next(
4459        mut self: std::pin::Pin<&mut Self>,
4460        cx: &mut std::task::Context<'_>,
4461    ) -> std::task::Poll<Option<Self::Item>> {
4462        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4463            &mut self.event_receiver,
4464            cx
4465        )?) {
4466            Some(buf) => std::task::Poll::Ready(Some(Server_Event::decode(buf))),
4467            None => std::task::Poll::Ready(None),
4468        }
4469    }
4470}
4471
4472#[derive(Debug)]
4473pub enum Server_Event {}
4474
4475impl Server_Event {
4476    /// Decodes a message buffer as a [`Server_Event`].
4477    fn decode(
4478        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4479    ) -> Result<Server_Event, fidl::Error> {
4480        let (bytes, _handles) = buf.split_mut();
4481        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4482        debug_assert_eq!(tx_header.tx_id, 0);
4483        match tx_header.ordinal {
4484            _ => Err(fidl::Error::UnknownOrdinal {
4485                ordinal: tx_header.ordinal,
4486                protocol_name: <Server_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4487            }),
4488        }
4489    }
4490}
4491
4492/// A Stream of incoming requests for fuchsia.bluetooth.gatt2/Server.
4493pub struct Server_RequestStream {
4494    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4495    is_terminated: bool,
4496}
4497
4498impl std::marker::Unpin for Server_RequestStream {}
4499
4500impl futures::stream::FusedStream for Server_RequestStream {
4501    fn is_terminated(&self) -> bool {
4502        self.is_terminated
4503    }
4504}
4505
4506impl fidl::endpoints::RequestStream for Server_RequestStream {
4507    type Protocol = Server_Marker;
4508    type ControlHandle = Server_ControlHandle;
4509
4510    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4511        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4512    }
4513
4514    fn control_handle(&self) -> Self::ControlHandle {
4515        Server_ControlHandle { inner: self.inner.clone() }
4516    }
4517
4518    fn into_inner(
4519        self,
4520    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4521    {
4522        (self.inner, self.is_terminated)
4523    }
4524
4525    fn from_inner(
4526        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4527        is_terminated: bool,
4528    ) -> Self {
4529        Self { inner, is_terminated }
4530    }
4531}
4532
4533impl futures::Stream for Server_RequestStream {
4534    type Item = Result<Server_Request, fidl::Error>;
4535
4536    fn poll_next(
4537        mut self: std::pin::Pin<&mut Self>,
4538        cx: &mut std::task::Context<'_>,
4539    ) -> std::task::Poll<Option<Self::Item>> {
4540        let this = &mut *self;
4541        if this.inner.check_shutdown(cx) {
4542            this.is_terminated = true;
4543            return std::task::Poll::Ready(None);
4544        }
4545        if this.is_terminated {
4546            panic!("polled Server_RequestStream after completion");
4547        }
4548        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4549            |bytes, handles| {
4550                match this.inner.channel().read_etc(cx, bytes, handles) {
4551                    std::task::Poll::Ready(Ok(())) => {}
4552                    std::task::Poll::Pending => return std::task::Poll::Pending,
4553                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4554                        this.is_terminated = true;
4555                        return std::task::Poll::Ready(None);
4556                    }
4557                    std::task::Poll::Ready(Err(e)) => {
4558                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4559                            e.into(),
4560                        ))));
4561                    }
4562                }
4563
4564                // A message has been received from the channel
4565                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4566
4567                std::task::Poll::Ready(Some(match header.ordinal {
4568                    0x3110442f2077bfe2 => {
4569                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4570                        let mut req = fidl::new_empty!(
4571                            ServerPublishServiceRequest,
4572                            fidl::encoding::DefaultFuchsiaResourceDialect
4573                        );
4574                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ServerPublishServiceRequest>(&header, _body_bytes, handles, &mut req)?;
4575                        let control_handle = Server_ControlHandle { inner: this.inner.clone() };
4576                        Ok(Server_Request::PublishService {
4577                            info: req.info,
4578                            service: req.service,
4579
4580                            responder: Server_PublishServiceResponder {
4581                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4582                                tx_id: header.tx_id,
4583                            },
4584                        })
4585                    }
4586                    _ => Err(fidl::Error::UnknownOrdinal {
4587                        ordinal: header.ordinal,
4588                        protocol_name:
4589                            <Server_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4590                    }),
4591                }))
4592            },
4593        )
4594    }
4595}
4596
4597#[derive(Debug)]
4598pub enum Server_Request {
4599    /// Publishes the given `service` so that it is available to all remote peers. Upon publication,
4600    /// the service is defined to have INITIAL_VALUE_CHANGED_CREDITS credits available for sending
4601    /// indications/notifications.
4602    ///
4603    /// The caller must assign distinct handles to the characteristics and descriptors listed in
4604    /// `info`. These identifiers will be used in requests sent to `service`.
4605    ///
4606    /// + request `info` Defines the structure of the GATT service. Includes characteristics and
4607    ///   descriptors that will be made available to peers, as well as the service handle, which is
4608    ///   required to be unique across all services published to this Server.
4609    /// + request `service` Provides the implementation of the service per the documented behavior
4610    ///   of a `LocalService`.
4611    /// - response An empty response indicates the service was successfully published.
4612    /// * error See `gatt2.PublishServiceError` for possible failure modes.
4613    PublishService {
4614        info: ServiceInfo,
4615        service: fidl::endpoints::ClientEnd<LocalServiceMarker>,
4616        responder: Server_PublishServiceResponder,
4617    },
4618}
4619
4620impl Server_Request {
4621    #[allow(irrefutable_let_patterns)]
4622    pub fn into_publish_service(
4623        self,
4624    ) -> Option<(
4625        ServiceInfo,
4626        fidl::endpoints::ClientEnd<LocalServiceMarker>,
4627        Server_PublishServiceResponder,
4628    )> {
4629        if let Server_Request::PublishService { info, service, responder } = self {
4630            Some((info, service, responder))
4631        } else {
4632            None
4633        }
4634    }
4635
4636    /// Name of the method defined in FIDL
4637    pub fn method_name(&self) -> &'static str {
4638        match *self {
4639            Server_Request::PublishService { .. } => "publish_service",
4640        }
4641    }
4642}
4643
4644#[derive(Debug, Clone)]
4645pub struct Server_ControlHandle {
4646    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4647}
4648
4649impl fidl::endpoints::ControlHandle for Server_ControlHandle {
4650    fn shutdown(&self) {
4651        self.inner.shutdown()
4652    }
4653    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4654        self.inner.shutdown_with_epitaph(status)
4655    }
4656
4657    fn is_closed(&self) -> bool {
4658        self.inner.channel().is_closed()
4659    }
4660    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4661        self.inner.channel().on_closed()
4662    }
4663
4664    #[cfg(target_os = "fuchsia")]
4665    fn signal_peer(
4666        &self,
4667        clear_mask: zx::Signals,
4668        set_mask: zx::Signals,
4669    ) -> Result<(), zx_status::Status> {
4670        use fidl::Peered;
4671        self.inner.channel().signal_peer(clear_mask, set_mask)
4672    }
4673}
4674
4675impl Server_ControlHandle {}
4676
4677#[must_use = "FIDL methods require a response to be sent"]
4678#[derive(Debug)]
4679pub struct Server_PublishServiceResponder {
4680    control_handle: std::mem::ManuallyDrop<Server_ControlHandle>,
4681    tx_id: u32,
4682}
4683
4684/// Set the the channel to be shutdown (see [`Server_ControlHandle::shutdown`])
4685/// if the responder is dropped without sending a response, so that the client
4686/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4687impl std::ops::Drop for Server_PublishServiceResponder {
4688    fn drop(&mut self) {
4689        self.control_handle.shutdown();
4690        // Safety: drops once, never accessed again
4691        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4692    }
4693}
4694
4695impl fidl::endpoints::Responder for Server_PublishServiceResponder {
4696    type ControlHandle = Server_ControlHandle;
4697
4698    fn control_handle(&self) -> &Server_ControlHandle {
4699        &self.control_handle
4700    }
4701
4702    fn drop_without_shutdown(mut self) {
4703        // Safety: drops once, never accessed again due to mem::forget
4704        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4705        // Prevent Drop from running (which would shut down the channel)
4706        std::mem::forget(self);
4707    }
4708}
4709
4710impl Server_PublishServiceResponder {
4711    /// Sends a response to the FIDL transaction.
4712    ///
4713    /// Sets the channel to shutdown if an error occurs.
4714    pub fn send(self, mut result: Result<(), PublishServiceError>) -> Result<(), fidl::Error> {
4715        let _result = self.send_raw(result);
4716        if _result.is_err() {
4717            self.control_handle.shutdown();
4718        }
4719        self.drop_without_shutdown();
4720        _result
4721    }
4722
4723    /// Similar to "send" but does not shutdown the channel if an error occurs.
4724    pub fn send_no_shutdown_on_err(
4725        self,
4726        mut result: Result<(), PublishServiceError>,
4727    ) -> Result<(), fidl::Error> {
4728        let _result = self.send_raw(result);
4729        self.drop_without_shutdown();
4730        _result
4731    }
4732
4733    fn send_raw(&self, mut result: Result<(), PublishServiceError>) -> Result<(), fidl::Error> {
4734        self.control_handle.inner.send::<fidl::encoding::ResultType<
4735            fidl::encoding::EmptyStruct,
4736            PublishServiceError,
4737        >>(
4738            result,
4739            self.tx_id,
4740            0x3110442f2077bfe2,
4741            fidl::encoding::DynamicFlags::empty(),
4742        )
4743    }
4744}
4745
4746mod internal {
4747    use super::*;
4748
4749    impl fidl::encoding::ResourceTypeMarker for ClientConnectToServiceRequest {
4750        type Borrowed<'a> = &'a mut Self;
4751        fn take_or_borrow<'a>(
4752            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4753        ) -> Self::Borrowed<'a> {
4754            value
4755        }
4756    }
4757
4758    unsafe impl fidl::encoding::TypeMarker for ClientConnectToServiceRequest {
4759        type Owned = Self;
4760
4761        #[inline(always)]
4762        fn inline_align(_context: fidl::encoding::Context) -> usize {
4763            8
4764        }
4765
4766        #[inline(always)]
4767        fn inline_size(_context: fidl::encoding::Context) -> usize {
4768            16
4769        }
4770    }
4771
4772    unsafe impl
4773        fidl::encoding::Encode<
4774            ClientConnectToServiceRequest,
4775            fidl::encoding::DefaultFuchsiaResourceDialect,
4776        > for &mut ClientConnectToServiceRequest
4777    {
4778        #[inline]
4779        unsafe fn encode(
4780            self,
4781            encoder: &mut fidl::encoding::Encoder<
4782                '_,
4783                fidl::encoding::DefaultFuchsiaResourceDialect,
4784            >,
4785            offset: usize,
4786            _depth: fidl::encoding::Depth,
4787        ) -> fidl::Result<()> {
4788            encoder.debug_check_bounds::<ClientConnectToServiceRequest>(offset);
4789            // Delegate to tuple encoding.
4790            fidl::encoding::Encode::<ClientConnectToServiceRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
4791                (
4792                    <ServiceHandle as fidl::encoding::ValueTypeMarker>::borrow(&self.handle),
4793                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RemoteServiceMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.service),
4794                ),
4795                encoder, offset, _depth
4796            )
4797        }
4798    }
4799    unsafe impl<
4800        T0: fidl::encoding::Encode<ServiceHandle, fidl::encoding::DefaultFuchsiaResourceDialect>,
4801        T1: fidl::encoding::Encode<
4802                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RemoteServiceMarker>>,
4803                fidl::encoding::DefaultFuchsiaResourceDialect,
4804            >,
4805    >
4806        fidl::encoding::Encode<
4807            ClientConnectToServiceRequest,
4808            fidl::encoding::DefaultFuchsiaResourceDialect,
4809        > for (T0, T1)
4810    {
4811        #[inline]
4812        unsafe fn encode(
4813            self,
4814            encoder: &mut fidl::encoding::Encoder<
4815                '_,
4816                fidl::encoding::DefaultFuchsiaResourceDialect,
4817            >,
4818            offset: usize,
4819            depth: fidl::encoding::Depth,
4820        ) -> fidl::Result<()> {
4821            encoder.debug_check_bounds::<ClientConnectToServiceRequest>(offset);
4822            // Zero out padding regions. There's no need to apply masks
4823            // because the unmasked parts will be overwritten by fields.
4824            unsafe {
4825                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
4826                (ptr as *mut u64).write_unaligned(0);
4827            }
4828            // Write the fields.
4829            self.0.encode(encoder, offset + 0, depth)?;
4830            self.1.encode(encoder, offset + 8, depth)?;
4831            Ok(())
4832        }
4833    }
4834
4835    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4836        for ClientConnectToServiceRequest
4837    {
4838        #[inline(always)]
4839        fn new_empty() -> Self {
4840            Self {
4841                handle: fidl::new_empty!(
4842                    ServiceHandle,
4843                    fidl::encoding::DefaultFuchsiaResourceDialect
4844                ),
4845                service: fidl::new_empty!(
4846                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RemoteServiceMarker>>,
4847                    fidl::encoding::DefaultFuchsiaResourceDialect
4848                ),
4849            }
4850        }
4851
4852        #[inline]
4853        unsafe fn decode(
4854            &mut self,
4855            decoder: &mut fidl::encoding::Decoder<
4856                '_,
4857                fidl::encoding::DefaultFuchsiaResourceDialect,
4858            >,
4859            offset: usize,
4860            _depth: fidl::encoding::Depth,
4861        ) -> fidl::Result<()> {
4862            decoder.debug_check_bounds::<Self>(offset);
4863            // Verify that padding bytes are zero.
4864            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
4865            let padval = unsafe { (ptr as *const u64).read_unaligned() };
4866            let mask = 0xffffffff00000000u64;
4867            let maskedval = padval & mask;
4868            if maskedval != 0 {
4869                return Err(fidl::Error::NonZeroPadding {
4870                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
4871                });
4872            }
4873            fidl::decode!(
4874                ServiceHandle,
4875                fidl::encoding::DefaultFuchsiaResourceDialect,
4876                &mut self.handle,
4877                decoder,
4878                offset + 0,
4879                _depth
4880            )?;
4881            fidl::decode!(
4882                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RemoteServiceMarker>>,
4883                fidl::encoding::DefaultFuchsiaResourceDialect,
4884                &mut self.service,
4885                decoder,
4886                offset + 8,
4887                _depth
4888            )?;
4889            Ok(())
4890        }
4891    }
4892
4893    impl fidl::encoding::ResourceTypeMarker for LocalServiceOnIndicateValueRequest {
4894        type Borrowed<'a> = &'a mut Self;
4895        fn take_or_borrow<'a>(
4896            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4897        ) -> Self::Borrowed<'a> {
4898            value
4899        }
4900    }
4901
4902    unsafe impl fidl::encoding::TypeMarker for LocalServiceOnIndicateValueRequest {
4903        type Owned = Self;
4904
4905        #[inline(always)]
4906        fn inline_align(_context: fidl::encoding::Context) -> usize {
4907            8
4908        }
4909
4910        #[inline(always)]
4911        fn inline_size(_context: fidl::encoding::Context) -> usize {
4912            24
4913        }
4914    }
4915
4916    unsafe impl
4917        fidl::encoding::Encode<
4918            LocalServiceOnIndicateValueRequest,
4919            fidl::encoding::DefaultFuchsiaResourceDialect,
4920        > for &mut LocalServiceOnIndicateValueRequest
4921    {
4922        #[inline]
4923        unsafe fn encode(
4924            self,
4925            encoder: &mut fidl::encoding::Encoder<
4926                '_,
4927                fidl::encoding::DefaultFuchsiaResourceDialect,
4928            >,
4929            offset: usize,
4930            _depth: fidl::encoding::Depth,
4931        ) -> fidl::Result<()> {
4932            encoder.debug_check_bounds::<LocalServiceOnIndicateValueRequest>(offset);
4933            // Delegate to tuple encoding.
4934            fidl::encoding::Encode::<
4935                LocalServiceOnIndicateValueRequest,
4936                fidl::encoding::DefaultFuchsiaResourceDialect,
4937            >::encode(
4938                (
4939                    <ValueChangedParameters as fidl::encoding::ValueTypeMarker>::borrow(
4940                        &self.update,
4941                    ),
4942                    <fidl::encoding::HandleType<
4943                        fidl::EventPair,
4944                        { fidl::ObjectType::EVENTPAIR.into_raw() },
4945                        2147483648,
4946                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4947                        &mut self.confirmation,
4948                    ),
4949                ),
4950                encoder,
4951                offset,
4952                _depth,
4953            )
4954        }
4955    }
4956    unsafe impl<
4957        T0: fidl::encoding::Encode<
4958                ValueChangedParameters,
4959                fidl::encoding::DefaultFuchsiaResourceDialect,
4960            >,
4961        T1: fidl::encoding::Encode<
4962                fidl::encoding::HandleType<
4963                    fidl::EventPair,
4964                    { fidl::ObjectType::EVENTPAIR.into_raw() },
4965                    2147483648,
4966                >,
4967                fidl::encoding::DefaultFuchsiaResourceDialect,
4968            >,
4969    >
4970        fidl::encoding::Encode<
4971            LocalServiceOnIndicateValueRequest,
4972            fidl::encoding::DefaultFuchsiaResourceDialect,
4973        > for (T0, T1)
4974    {
4975        #[inline]
4976        unsafe fn encode(
4977            self,
4978            encoder: &mut fidl::encoding::Encoder<
4979                '_,
4980                fidl::encoding::DefaultFuchsiaResourceDialect,
4981            >,
4982            offset: usize,
4983            depth: fidl::encoding::Depth,
4984        ) -> fidl::Result<()> {
4985            encoder.debug_check_bounds::<LocalServiceOnIndicateValueRequest>(offset);
4986            // Zero out padding regions. There's no need to apply masks
4987            // because the unmasked parts will be overwritten by fields.
4988            unsafe {
4989                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
4990                (ptr as *mut u64).write_unaligned(0);
4991            }
4992            // Write the fields.
4993            self.0.encode(encoder, offset + 0, depth)?;
4994            self.1.encode(encoder, offset + 16, depth)?;
4995            Ok(())
4996        }
4997    }
4998
4999    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5000        for LocalServiceOnIndicateValueRequest
5001    {
5002        #[inline(always)]
5003        fn new_empty() -> Self {
5004            Self {
5005                update: fidl::new_empty!(
5006                    ValueChangedParameters,
5007                    fidl::encoding::DefaultFuchsiaResourceDialect
5008                ),
5009                confirmation: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
5010            }
5011        }
5012
5013        #[inline]
5014        unsafe fn decode(
5015            &mut self,
5016            decoder: &mut fidl::encoding::Decoder<
5017                '_,
5018                fidl::encoding::DefaultFuchsiaResourceDialect,
5019            >,
5020            offset: usize,
5021            _depth: fidl::encoding::Depth,
5022        ) -> fidl::Result<()> {
5023            decoder.debug_check_bounds::<Self>(offset);
5024            // Verify that padding bytes are zero.
5025            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
5026            let padval = unsafe { (ptr as *const u64).read_unaligned() };
5027            let mask = 0xffffffff00000000u64;
5028            let maskedval = padval & mask;
5029            if maskedval != 0 {
5030                return Err(fidl::Error::NonZeroPadding {
5031                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
5032                });
5033            }
5034            fidl::decode!(
5035                ValueChangedParameters,
5036                fidl::encoding::DefaultFuchsiaResourceDialect,
5037                &mut self.update,
5038                decoder,
5039                offset + 0,
5040                _depth
5041            )?;
5042            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.confirmation, decoder, offset + 16, _depth)?;
5043            Ok(())
5044        }
5045    }
5046
5047    impl fidl::encoding::ResourceTypeMarker for RemoteServiceRegisterCharacteristicNotifierRequest {
5048        type Borrowed<'a> = &'a mut Self;
5049        fn take_or_borrow<'a>(
5050            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5051        ) -> Self::Borrowed<'a> {
5052            value
5053        }
5054    }
5055
5056    unsafe impl fidl::encoding::TypeMarker for RemoteServiceRegisterCharacteristicNotifierRequest {
5057        type Owned = Self;
5058
5059        #[inline(always)]
5060        fn inline_align(_context: fidl::encoding::Context) -> usize {
5061            8
5062        }
5063
5064        #[inline(always)]
5065        fn inline_size(_context: fidl::encoding::Context) -> usize {
5066            16
5067        }
5068    }
5069
5070    unsafe impl
5071        fidl::encoding::Encode<
5072            RemoteServiceRegisterCharacteristicNotifierRequest,
5073            fidl::encoding::DefaultFuchsiaResourceDialect,
5074        > for &mut RemoteServiceRegisterCharacteristicNotifierRequest
5075    {
5076        #[inline]
5077        unsafe fn encode(
5078            self,
5079            encoder: &mut fidl::encoding::Encoder<
5080                '_,
5081                fidl::encoding::DefaultFuchsiaResourceDialect,
5082            >,
5083            offset: usize,
5084            _depth: fidl::encoding::Depth,
5085        ) -> fidl::Result<()> {
5086            encoder
5087                .debug_check_bounds::<RemoteServiceRegisterCharacteristicNotifierRequest>(offset);
5088            // Delegate to tuple encoding.
5089            fidl::encoding::Encode::<
5090                RemoteServiceRegisterCharacteristicNotifierRequest,
5091                fidl::encoding::DefaultFuchsiaResourceDialect,
5092            >::encode(
5093                (
5094                    <Handle as fidl::encoding::ValueTypeMarker>::borrow(&self.handle),
5095                    <fidl::encoding::Endpoint<
5096                        fidl::endpoints::ClientEnd<CharacteristicNotifierMarker>,
5097                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
5098                        &mut self.notifier
5099                    ),
5100                ),
5101                encoder,
5102                offset,
5103                _depth,
5104            )
5105        }
5106    }
5107    unsafe impl<
5108        T0: fidl::encoding::Encode<Handle, fidl::encoding::DefaultFuchsiaResourceDialect>,
5109        T1: fidl::encoding::Encode<
5110                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<CharacteristicNotifierMarker>>,
5111                fidl::encoding::DefaultFuchsiaResourceDialect,
5112            >,
5113    >
5114        fidl::encoding::Encode<
5115            RemoteServiceRegisterCharacteristicNotifierRequest,
5116            fidl::encoding::DefaultFuchsiaResourceDialect,
5117        > for (T0, T1)
5118    {
5119        #[inline]
5120        unsafe fn encode(
5121            self,
5122            encoder: &mut fidl::encoding::Encoder<
5123                '_,
5124                fidl::encoding::DefaultFuchsiaResourceDialect,
5125            >,
5126            offset: usize,
5127            depth: fidl::encoding::Depth,
5128        ) -> fidl::Result<()> {
5129            encoder
5130                .debug_check_bounds::<RemoteServiceRegisterCharacteristicNotifierRequest>(offset);
5131            // Zero out padding regions. There's no need to apply masks
5132            // because the unmasked parts will be overwritten by fields.
5133            unsafe {
5134                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
5135                (ptr as *mut u64).write_unaligned(0);
5136            }
5137            // Write the fields.
5138            self.0.encode(encoder, offset + 0, depth)?;
5139            self.1.encode(encoder, offset + 8, depth)?;
5140            Ok(())
5141        }
5142    }
5143
5144    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5145        for RemoteServiceRegisterCharacteristicNotifierRequest
5146    {
5147        #[inline(always)]
5148        fn new_empty() -> Self {
5149            Self {
5150                handle: fidl::new_empty!(Handle, fidl::encoding::DefaultFuchsiaResourceDialect),
5151                notifier: fidl::new_empty!(
5152                    fidl::encoding::Endpoint<
5153                        fidl::endpoints::ClientEnd<CharacteristicNotifierMarker>,
5154                    >,
5155                    fidl::encoding::DefaultFuchsiaResourceDialect
5156                ),
5157            }
5158        }
5159
5160        #[inline]
5161        unsafe fn decode(
5162            &mut self,
5163            decoder: &mut fidl::encoding::Decoder<
5164                '_,
5165                fidl::encoding::DefaultFuchsiaResourceDialect,
5166            >,
5167            offset: usize,
5168            _depth: fidl::encoding::Depth,
5169        ) -> fidl::Result<()> {
5170            decoder.debug_check_bounds::<Self>(offset);
5171            // Verify that padding bytes are zero.
5172            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
5173            let padval = unsafe { (ptr as *const u64).read_unaligned() };
5174            let mask = 0xffffffff00000000u64;
5175            let maskedval = padval & mask;
5176            if maskedval != 0 {
5177                return Err(fidl::Error::NonZeroPadding {
5178                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
5179                });
5180            }
5181            fidl::decode!(
5182                Handle,
5183                fidl::encoding::DefaultFuchsiaResourceDialect,
5184                &mut self.handle,
5185                decoder,
5186                offset + 0,
5187                _depth
5188            )?;
5189            fidl::decode!(
5190                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<CharacteristicNotifierMarker>>,
5191                fidl::encoding::DefaultFuchsiaResourceDialect,
5192                &mut self.notifier,
5193                decoder,
5194                offset + 8,
5195                _depth
5196            )?;
5197            Ok(())
5198        }
5199    }
5200
5201    impl fidl::encoding::ResourceTypeMarker for ServerPublishServiceRequest {
5202        type Borrowed<'a> = &'a mut Self;
5203        fn take_or_borrow<'a>(
5204            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5205        ) -> Self::Borrowed<'a> {
5206            value
5207        }
5208    }
5209
5210    unsafe impl fidl::encoding::TypeMarker for ServerPublishServiceRequest {
5211        type Owned = Self;
5212
5213        #[inline(always)]
5214        fn inline_align(_context: fidl::encoding::Context) -> usize {
5215            8
5216        }
5217
5218        #[inline(always)]
5219        fn inline_size(_context: fidl::encoding::Context) -> usize {
5220            24
5221        }
5222    }
5223
5224    unsafe impl
5225        fidl::encoding::Encode<
5226            ServerPublishServiceRequest,
5227            fidl::encoding::DefaultFuchsiaResourceDialect,
5228        > for &mut ServerPublishServiceRequest
5229    {
5230        #[inline]
5231        unsafe fn encode(
5232            self,
5233            encoder: &mut fidl::encoding::Encoder<
5234                '_,
5235                fidl::encoding::DefaultFuchsiaResourceDialect,
5236            >,
5237            offset: usize,
5238            _depth: fidl::encoding::Depth,
5239        ) -> fidl::Result<()> {
5240            encoder.debug_check_bounds::<ServerPublishServiceRequest>(offset);
5241            // Delegate to tuple encoding.
5242            fidl::encoding::Encode::<ServerPublishServiceRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
5243                (
5244                    <ServiceInfo as fidl::encoding::ValueTypeMarker>::borrow(&self.info),
5245                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<LocalServiceMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.service),
5246                ),
5247                encoder, offset, _depth
5248            )
5249        }
5250    }
5251    unsafe impl<
5252        T0: fidl::encoding::Encode<ServiceInfo, fidl::encoding::DefaultFuchsiaResourceDialect>,
5253        T1: fidl::encoding::Encode<
5254                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<LocalServiceMarker>>,
5255                fidl::encoding::DefaultFuchsiaResourceDialect,
5256            >,
5257    >
5258        fidl::encoding::Encode<
5259            ServerPublishServiceRequest,
5260            fidl::encoding::DefaultFuchsiaResourceDialect,
5261        > for (T0, T1)
5262    {
5263        #[inline]
5264        unsafe fn encode(
5265            self,
5266            encoder: &mut fidl::encoding::Encoder<
5267                '_,
5268                fidl::encoding::DefaultFuchsiaResourceDialect,
5269            >,
5270            offset: usize,
5271            depth: fidl::encoding::Depth,
5272        ) -> fidl::Result<()> {
5273            encoder.debug_check_bounds::<ServerPublishServiceRequest>(offset);
5274            // Zero out padding regions. There's no need to apply masks
5275            // because the unmasked parts will be overwritten by fields.
5276            unsafe {
5277                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
5278                (ptr as *mut u64).write_unaligned(0);
5279            }
5280            // Write the fields.
5281            self.0.encode(encoder, offset + 0, depth)?;
5282            self.1.encode(encoder, offset + 16, depth)?;
5283            Ok(())
5284        }
5285    }
5286
5287    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5288        for ServerPublishServiceRequest
5289    {
5290        #[inline(always)]
5291        fn new_empty() -> Self {
5292            Self {
5293                info: fidl::new_empty!(ServiceInfo, fidl::encoding::DefaultFuchsiaResourceDialect),
5294                service: fidl::new_empty!(
5295                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<LocalServiceMarker>>,
5296                    fidl::encoding::DefaultFuchsiaResourceDialect
5297                ),
5298            }
5299        }
5300
5301        #[inline]
5302        unsafe fn decode(
5303            &mut self,
5304            decoder: &mut fidl::encoding::Decoder<
5305                '_,
5306                fidl::encoding::DefaultFuchsiaResourceDialect,
5307            >,
5308            offset: usize,
5309            _depth: fidl::encoding::Depth,
5310        ) -> fidl::Result<()> {
5311            decoder.debug_check_bounds::<Self>(offset);
5312            // Verify that padding bytes are zero.
5313            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
5314            let padval = unsafe { (ptr as *const u64).read_unaligned() };
5315            let mask = 0xffffffff00000000u64;
5316            let maskedval = padval & mask;
5317            if maskedval != 0 {
5318                return Err(fidl::Error::NonZeroPadding {
5319                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
5320                });
5321            }
5322            fidl::decode!(
5323                ServiceInfo,
5324                fidl::encoding::DefaultFuchsiaResourceDialect,
5325                &mut self.info,
5326                decoder,
5327                offset + 0,
5328                _depth
5329            )?;
5330            fidl::decode!(
5331                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<LocalServiceMarker>>,
5332                fidl::encoding::DefaultFuchsiaResourceDialect,
5333                &mut self.service,
5334                decoder,
5335                offset + 16,
5336                _depth
5337            )?;
5338            Ok(())
5339        }
5340    }
5341}