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