fidl_fuchsia_bluetooth_gatt2/
fidl_fuchsia_bluetooth_gatt2.rs

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