Skip to main content

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