Skip to main content

fidl_fuchsia_bluetooth_deviceid/
fidl_fuchsia_bluetooth_deviceid.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_deviceid__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct DeviceIdentificationSetDeviceIdentificationRequest {
16    pub records: Vec<DeviceIdentificationRecord>,
17    pub token: fidl::endpoints::ServerEnd<DeviceIdentificationHandleMarker>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
21    for DeviceIdentificationSetDeviceIdentificationRequest
22{
23}
24
25#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
26pub struct DeviceIdentificationMarker;
27
28impl fidl::endpoints::ProtocolMarker for DeviceIdentificationMarker {
29    type Proxy = DeviceIdentificationProxy;
30    type RequestStream = DeviceIdentificationRequestStream;
31    #[cfg(target_os = "fuchsia")]
32    type SynchronousProxy = DeviceIdentificationSynchronousProxy;
33
34    const DEBUG_NAME: &'static str = "fuchsia.bluetooth.deviceid.DeviceIdentification";
35}
36impl fidl::endpoints::DiscoverableProtocolMarker for DeviceIdentificationMarker {}
37pub type DeviceIdentificationSetDeviceIdentificationResult = Result<(), i32>;
38
39pub trait DeviceIdentificationProxyInterface: Send + Sync {
40    type SetDeviceIdentificationResponseFut: std::future::Future<
41            Output = Result<DeviceIdentificationSetDeviceIdentificationResult, fidl::Error>,
42        > + Send;
43    fn r#set_device_identification(
44        &self,
45        records: &[DeviceIdentificationRecord],
46        token: fidl::endpoints::ServerEnd<DeviceIdentificationHandleMarker>,
47    ) -> Self::SetDeviceIdentificationResponseFut;
48}
49#[derive(Debug)]
50#[cfg(target_os = "fuchsia")]
51pub struct DeviceIdentificationSynchronousProxy {
52    client: fidl::client::sync::Client,
53}
54
55#[cfg(target_os = "fuchsia")]
56impl fidl::endpoints::SynchronousProxy for DeviceIdentificationSynchronousProxy {
57    type Proxy = DeviceIdentificationProxy;
58    type Protocol = DeviceIdentificationMarker;
59
60    fn from_channel(inner: fidl::Channel) -> Self {
61        Self::new(inner)
62    }
63
64    fn into_channel(self) -> fidl::Channel {
65        self.client.into_channel()
66    }
67
68    fn as_channel(&self) -> &fidl::Channel {
69        self.client.as_channel()
70    }
71}
72
73#[cfg(target_os = "fuchsia")]
74impl DeviceIdentificationSynchronousProxy {
75    pub fn new(channel: fidl::Channel) -> Self {
76        Self { client: fidl::client::sync::Client::new(channel) }
77    }
78
79    pub fn into_channel(self) -> fidl::Channel {
80        self.client.into_channel()
81    }
82
83    /// Waits until an event arrives and returns it. It is safe for other
84    /// threads to make concurrent requests while waiting for an event.
85    pub fn wait_for_event(
86        &self,
87        deadline: zx::MonotonicInstant,
88    ) -> Result<DeviceIdentificationEvent, fidl::Error> {
89        DeviceIdentificationEvent::decode(
90            self.client.wait_for_event::<DeviceIdentificationMarker>(deadline)?,
91        )
92    }
93
94    /// Request to set the device information to be advertised over Bluetooth.
95    ///
96    /// The device information can only be set once per provided `token`. To cancel the request,
97    /// close the `token` with any epitaph.
98    ///
99    /// At most one record in `records` may be denoted as the `primary` record. If multiple records
100    /// have `primary` set, `ZX_ERR_INVALID_ARGS` will be returned.
101    /// If the server is already advertising a `primary` record, a subsequent request with `primary`
102    /// may be rejected with `ZX_ERR_ALREADY_EXISTS`.
103    ///
104    /// + request `records` is the set of device information records that identify the device.
105    /// + request `token` is used to manage the lifetime of the advertised device information.
106    ///           The `records` will remain advertised as long as the channel is open.
107    ///           The device identification advertisement will be removed when `token` is closed
108    ///           with any epitaph.
109    /// - response An empty response will be sent when the `token` has been closed and the server
110    ///            has processed the closure.
111    /// * error Returns `ZX_ERR_INVALID_ARGS` if any of the provided `records` are invalidly
112    ///         formatted.
113    /// * error Returns `ZX_ERR_NO_RESOURCES` if the server has reached the maximum number of
114    ///         device information advertisements.
115    /// * error Returns `ZX_ERR_CANCELLED` if the request was cancelled by the server for all other
116    ///         errors.
117    pub fn r#set_device_identification(
118        &self,
119        mut records: &[DeviceIdentificationRecord],
120        mut token: fidl::endpoints::ServerEnd<DeviceIdentificationHandleMarker>,
121        ___deadline: zx::MonotonicInstant,
122    ) -> Result<DeviceIdentificationSetDeviceIdentificationResult, fidl::Error> {
123        let _response = self.client.send_query::<
124            DeviceIdentificationSetDeviceIdentificationRequest,
125            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
126            DeviceIdentificationMarker,
127        >(
128            (records, token,),
129            0x12ada3cb3fbcbd0a,
130            fidl::encoding::DynamicFlags::empty(),
131            ___deadline,
132        )?;
133        Ok(_response.map(|x| x))
134    }
135}
136
137#[cfg(target_os = "fuchsia")]
138impl From<DeviceIdentificationSynchronousProxy> for zx::NullableHandle {
139    fn from(value: DeviceIdentificationSynchronousProxy) -> Self {
140        value.into_channel().into()
141    }
142}
143
144#[cfg(target_os = "fuchsia")]
145impl From<fidl::Channel> for DeviceIdentificationSynchronousProxy {
146    fn from(value: fidl::Channel) -> Self {
147        Self::new(value)
148    }
149}
150
151#[cfg(target_os = "fuchsia")]
152impl fidl::endpoints::FromClient for DeviceIdentificationSynchronousProxy {
153    type Protocol = DeviceIdentificationMarker;
154
155    fn from_client(value: fidl::endpoints::ClientEnd<DeviceIdentificationMarker>) -> Self {
156        Self::new(value.into_channel())
157    }
158}
159
160#[derive(Debug, Clone)]
161pub struct DeviceIdentificationProxy {
162    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
163}
164
165impl fidl::endpoints::Proxy for DeviceIdentificationProxy {
166    type Protocol = DeviceIdentificationMarker;
167
168    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
169        Self::new(inner)
170    }
171
172    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
173        self.client.into_channel().map_err(|client| Self { client })
174    }
175
176    fn as_channel(&self) -> &::fidl::AsyncChannel {
177        self.client.as_channel()
178    }
179}
180
181impl DeviceIdentificationProxy {
182    /// Create a new Proxy for fuchsia.bluetooth.deviceid/DeviceIdentification.
183    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
184        let protocol_name =
185            <DeviceIdentificationMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
186        Self { client: fidl::client::Client::new(channel, protocol_name) }
187    }
188
189    /// Get a Stream of events from the remote end of the protocol.
190    ///
191    /// # Panics
192    ///
193    /// Panics if the event stream was already taken.
194    pub fn take_event_stream(&self) -> DeviceIdentificationEventStream {
195        DeviceIdentificationEventStream { event_receiver: self.client.take_event_receiver() }
196    }
197
198    /// Request to set the device information to be advertised over Bluetooth.
199    ///
200    /// The device information can only be set once per provided `token`. To cancel the request,
201    /// close the `token` with any epitaph.
202    ///
203    /// At most one record in `records` may be denoted as the `primary` record. If multiple records
204    /// have `primary` set, `ZX_ERR_INVALID_ARGS` will be returned.
205    /// If the server is already advertising a `primary` record, a subsequent request with `primary`
206    /// may be rejected with `ZX_ERR_ALREADY_EXISTS`.
207    ///
208    /// + request `records` is the set of device information records that identify the device.
209    /// + request `token` is used to manage the lifetime of the advertised device information.
210    ///           The `records` will remain advertised as long as the channel is open.
211    ///           The device identification advertisement will be removed when `token` is closed
212    ///           with any epitaph.
213    /// - response An empty response will be sent when the `token` has been closed and the server
214    ///            has processed the closure.
215    /// * error Returns `ZX_ERR_INVALID_ARGS` if any of the provided `records` are invalidly
216    ///         formatted.
217    /// * error Returns `ZX_ERR_NO_RESOURCES` if the server has reached the maximum number of
218    ///         device information advertisements.
219    /// * error Returns `ZX_ERR_CANCELLED` if the request was cancelled by the server for all other
220    ///         errors.
221    pub fn r#set_device_identification(
222        &self,
223        mut records: &[DeviceIdentificationRecord],
224        mut token: fidl::endpoints::ServerEnd<DeviceIdentificationHandleMarker>,
225    ) -> fidl::client::QueryResponseFut<
226        DeviceIdentificationSetDeviceIdentificationResult,
227        fidl::encoding::DefaultFuchsiaResourceDialect,
228    > {
229        DeviceIdentificationProxyInterface::r#set_device_identification(self, records, token)
230    }
231}
232
233impl DeviceIdentificationProxyInterface for DeviceIdentificationProxy {
234    type SetDeviceIdentificationResponseFut = fidl::client::QueryResponseFut<
235        DeviceIdentificationSetDeviceIdentificationResult,
236        fidl::encoding::DefaultFuchsiaResourceDialect,
237    >;
238    fn r#set_device_identification(
239        &self,
240        mut records: &[DeviceIdentificationRecord],
241        mut token: fidl::endpoints::ServerEnd<DeviceIdentificationHandleMarker>,
242    ) -> Self::SetDeviceIdentificationResponseFut {
243        fn _decode(
244            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
245        ) -> Result<DeviceIdentificationSetDeviceIdentificationResult, fidl::Error> {
246            let _response = fidl::client::decode_transaction_body::<
247                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
248                fidl::encoding::DefaultFuchsiaResourceDialect,
249                0x12ada3cb3fbcbd0a,
250            >(_buf?)?;
251            Ok(_response.map(|x| x))
252        }
253        self.client.send_query_and_decode::<
254            DeviceIdentificationSetDeviceIdentificationRequest,
255            DeviceIdentificationSetDeviceIdentificationResult,
256        >(
257            (records, token,),
258            0x12ada3cb3fbcbd0a,
259            fidl::encoding::DynamicFlags::empty(),
260            _decode,
261        )
262    }
263}
264
265pub struct DeviceIdentificationEventStream {
266    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
267}
268
269impl std::marker::Unpin for DeviceIdentificationEventStream {}
270
271impl futures::stream::FusedStream for DeviceIdentificationEventStream {
272    fn is_terminated(&self) -> bool {
273        self.event_receiver.is_terminated()
274    }
275}
276
277impl futures::Stream for DeviceIdentificationEventStream {
278    type Item = Result<DeviceIdentificationEvent, fidl::Error>;
279
280    fn poll_next(
281        mut self: std::pin::Pin<&mut Self>,
282        cx: &mut std::task::Context<'_>,
283    ) -> std::task::Poll<Option<Self::Item>> {
284        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
285            &mut self.event_receiver,
286            cx
287        )?) {
288            Some(buf) => std::task::Poll::Ready(Some(DeviceIdentificationEvent::decode(buf))),
289            None => std::task::Poll::Ready(None),
290        }
291    }
292}
293
294#[derive(Debug)]
295pub enum DeviceIdentificationEvent {}
296
297impl DeviceIdentificationEvent {
298    /// Decodes a message buffer as a [`DeviceIdentificationEvent`].
299    fn decode(
300        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
301    ) -> Result<DeviceIdentificationEvent, fidl::Error> {
302        let (bytes, _handles) = buf.split_mut();
303        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
304        debug_assert_eq!(tx_header.tx_id, 0);
305        match tx_header.ordinal {
306            _ => Err(fidl::Error::UnknownOrdinal {
307                ordinal: tx_header.ordinal,
308                protocol_name:
309                    <DeviceIdentificationMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
310            }),
311        }
312    }
313}
314
315/// A Stream of incoming requests for fuchsia.bluetooth.deviceid/DeviceIdentification.
316pub struct DeviceIdentificationRequestStream {
317    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
318    is_terminated: bool,
319}
320
321impl std::marker::Unpin for DeviceIdentificationRequestStream {}
322
323impl futures::stream::FusedStream for DeviceIdentificationRequestStream {
324    fn is_terminated(&self) -> bool {
325        self.is_terminated
326    }
327}
328
329impl fidl::endpoints::RequestStream for DeviceIdentificationRequestStream {
330    type Protocol = DeviceIdentificationMarker;
331    type ControlHandle = DeviceIdentificationControlHandle;
332
333    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
334        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
335    }
336
337    fn control_handle(&self) -> Self::ControlHandle {
338        DeviceIdentificationControlHandle { inner: self.inner.clone() }
339    }
340
341    fn into_inner(
342        self,
343    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
344    {
345        (self.inner, self.is_terminated)
346    }
347
348    fn from_inner(
349        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
350        is_terminated: bool,
351    ) -> Self {
352        Self { inner, is_terminated }
353    }
354}
355
356impl futures::Stream for DeviceIdentificationRequestStream {
357    type Item = Result<DeviceIdentificationRequest, fidl::Error>;
358
359    fn poll_next(
360        mut self: std::pin::Pin<&mut Self>,
361        cx: &mut std::task::Context<'_>,
362    ) -> std::task::Poll<Option<Self::Item>> {
363        let this = &mut *self;
364        if this.inner.check_shutdown(cx) {
365            this.is_terminated = true;
366            return std::task::Poll::Ready(None);
367        }
368        if this.is_terminated {
369            panic!("polled DeviceIdentificationRequestStream after completion");
370        }
371        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
372            |bytes, handles| {
373                match this.inner.channel().read_etc(cx, bytes, handles) {
374                    std::task::Poll::Ready(Ok(())) => {}
375                    std::task::Poll::Pending => return std::task::Poll::Pending,
376                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
377                        this.is_terminated = true;
378                        return std::task::Poll::Ready(None);
379                    }
380                    std::task::Poll::Ready(Err(e)) => {
381                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
382                            e.into(),
383                        ))));
384                    }
385                }
386
387                // A message has been received from the channel
388                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
389
390                std::task::Poll::Ready(Some(match header.ordinal {
391                0x12ada3cb3fbcbd0a => {
392                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
393                    let mut req = fidl::new_empty!(DeviceIdentificationSetDeviceIdentificationRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
394                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceIdentificationSetDeviceIdentificationRequest>(&header, _body_bytes, handles, &mut req)?;
395                    let control_handle = DeviceIdentificationControlHandle {
396                        inner: this.inner.clone(),
397                    };
398                    Ok(DeviceIdentificationRequest::SetDeviceIdentification {records: req.records,
399token: req.token,
400
401                        responder: DeviceIdentificationSetDeviceIdentificationResponder {
402                            control_handle: std::mem::ManuallyDrop::new(control_handle),
403                            tx_id: header.tx_id,
404                        },
405                    })
406                }
407                _ => Err(fidl::Error::UnknownOrdinal {
408                    ordinal: header.ordinal,
409                    protocol_name: <DeviceIdentificationMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
410                }),
411            }))
412            },
413        )
414    }
415}
416
417/// An interface for setting the identification of a Fuchsia device.
418#[derive(Debug)]
419pub enum DeviceIdentificationRequest {
420    /// Request to set the device information to be advertised over Bluetooth.
421    ///
422    /// The device information can only be set once per provided `token`. To cancel the request,
423    /// close the `token` with any epitaph.
424    ///
425    /// At most one record in `records` may be denoted as the `primary` record. If multiple records
426    /// have `primary` set, `ZX_ERR_INVALID_ARGS` will be returned.
427    /// If the server is already advertising a `primary` record, a subsequent request with `primary`
428    /// may be rejected with `ZX_ERR_ALREADY_EXISTS`.
429    ///
430    /// + request `records` is the set of device information records that identify the device.
431    /// + request `token` is used to manage the lifetime of the advertised device information.
432    ///           The `records` will remain advertised as long as the channel is open.
433    ///           The device identification advertisement will be removed when `token` is closed
434    ///           with any epitaph.
435    /// - response An empty response will be sent when the `token` has been closed and the server
436    ///            has processed the closure.
437    /// * error Returns `ZX_ERR_INVALID_ARGS` if any of the provided `records` are invalidly
438    ///         formatted.
439    /// * error Returns `ZX_ERR_NO_RESOURCES` if the server has reached the maximum number of
440    ///         device information advertisements.
441    /// * error Returns `ZX_ERR_CANCELLED` if the request was cancelled by the server for all other
442    ///         errors.
443    SetDeviceIdentification {
444        records: Vec<DeviceIdentificationRecord>,
445        token: fidl::endpoints::ServerEnd<DeviceIdentificationHandleMarker>,
446        responder: DeviceIdentificationSetDeviceIdentificationResponder,
447    },
448}
449
450impl DeviceIdentificationRequest {
451    #[allow(irrefutable_let_patterns)]
452    pub fn into_set_device_identification(
453        self,
454    ) -> Option<(
455        Vec<DeviceIdentificationRecord>,
456        fidl::endpoints::ServerEnd<DeviceIdentificationHandleMarker>,
457        DeviceIdentificationSetDeviceIdentificationResponder,
458    )> {
459        if let DeviceIdentificationRequest::SetDeviceIdentification { records, token, responder } =
460            self
461        {
462            Some((records, token, responder))
463        } else {
464            None
465        }
466    }
467
468    /// Name of the method defined in FIDL
469    pub fn method_name(&self) -> &'static str {
470        match *self {
471            DeviceIdentificationRequest::SetDeviceIdentification { .. } => {
472                "set_device_identification"
473            }
474        }
475    }
476}
477
478#[derive(Debug, Clone)]
479pub struct DeviceIdentificationControlHandle {
480    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
481}
482
483impl fidl::endpoints::ControlHandle for DeviceIdentificationControlHandle {
484    fn shutdown(&self) {
485        self.inner.shutdown()
486    }
487
488    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
489        self.inner.shutdown_with_epitaph(status)
490    }
491
492    fn is_closed(&self) -> bool {
493        self.inner.channel().is_closed()
494    }
495    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
496        self.inner.channel().on_closed()
497    }
498
499    #[cfg(target_os = "fuchsia")]
500    fn signal_peer(
501        &self,
502        clear_mask: zx::Signals,
503        set_mask: zx::Signals,
504    ) -> Result<(), zx_status::Status> {
505        use fidl::Peered;
506        self.inner.channel().signal_peer(clear_mask, set_mask)
507    }
508}
509
510impl DeviceIdentificationControlHandle {}
511
512#[must_use = "FIDL methods require a response to be sent"]
513#[derive(Debug)]
514pub struct DeviceIdentificationSetDeviceIdentificationResponder {
515    control_handle: std::mem::ManuallyDrop<DeviceIdentificationControlHandle>,
516    tx_id: u32,
517}
518
519/// Set the the channel to be shutdown (see [`DeviceIdentificationControlHandle::shutdown`])
520/// if the responder is dropped without sending a response, so that the client
521/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
522impl std::ops::Drop for DeviceIdentificationSetDeviceIdentificationResponder {
523    fn drop(&mut self) {
524        self.control_handle.shutdown();
525        // Safety: drops once, never accessed again
526        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
527    }
528}
529
530impl fidl::endpoints::Responder for DeviceIdentificationSetDeviceIdentificationResponder {
531    type ControlHandle = DeviceIdentificationControlHandle;
532
533    fn control_handle(&self) -> &DeviceIdentificationControlHandle {
534        &self.control_handle
535    }
536
537    fn drop_without_shutdown(mut self) {
538        // Safety: drops once, never accessed again due to mem::forget
539        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
540        // Prevent Drop from running (which would shut down the channel)
541        std::mem::forget(self);
542    }
543}
544
545impl DeviceIdentificationSetDeviceIdentificationResponder {
546    /// Sends a response to the FIDL transaction.
547    ///
548    /// Sets the channel to shutdown if an error occurs.
549    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
550        let _result = self.send_raw(result);
551        if _result.is_err() {
552            self.control_handle.shutdown();
553        }
554        self.drop_without_shutdown();
555        _result
556    }
557
558    /// Similar to "send" but does not shutdown the channel if an error occurs.
559    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
560        let _result = self.send_raw(result);
561        self.drop_without_shutdown();
562        _result
563    }
564
565    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
566        self.control_handle
567            .inner
568            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
569                result,
570                self.tx_id,
571                0x12ada3cb3fbcbd0a,
572                fidl::encoding::DynamicFlags::empty(),
573            )
574    }
575}
576
577#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
578pub struct DeviceIdentificationHandleMarker;
579
580impl fidl::endpoints::ProtocolMarker for DeviceIdentificationHandleMarker {
581    type Proxy = DeviceIdentificationHandleProxy;
582    type RequestStream = DeviceIdentificationHandleRequestStream;
583    #[cfg(target_os = "fuchsia")]
584    type SynchronousProxy = DeviceIdentificationHandleSynchronousProxy;
585
586    const DEBUG_NAME: &'static str = "(anonymous) DeviceIdentificationHandle";
587}
588
589pub trait DeviceIdentificationHandleProxyInterface: Send + Sync {}
590#[derive(Debug)]
591#[cfg(target_os = "fuchsia")]
592pub struct DeviceIdentificationHandleSynchronousProxy {
593    client: fidl::client::sync::Client,
594}
595
596#[cfg(target_os = "fuchsia")]
597impl fidl::endpoints::SynchronousProxy for DeviceIdentificationHandleSynchronousProxy {
598    type Proxy = DeviceIdentificationHandleProxy;
599    type Protocol = DeviceIdentificationHandleMarker;
600
601    fn from_channel(inner: fidl::Channel) -> Self {
602        Self::new(inner)
603    }
604
605    fn into_channel(self) -> fidl::Channel {
606        self.client.into_channel()
607    }
608
609    fn as_channel(&self) -> &fidl::Channel {
610        self.client.as_channel()
611    }
612}
613
614#[cfg(target_os = "fuchsia")]
615impl DeviceIdentificationHandleSynchronousProxy {
616    pub fn new(channel: fidl::Channel) -> Self {
617        Self { client: fidl::client::sync::Client::new(channel) }
618    }
619
620    pub fn into_channel(self) -> fidl::Channel {
621        self.client.into_channel()
622    }
623
624    /// Waits until an event arrives and returns it. It is safe for other
625    /// threads to make concurrent requests while waiting for an event.
626    pub fn wait_for_event(
627        &self,
628        deadline: zx::MonotonicInstant,
629    ) -> Result<DeviceIdentificationHandleEvent, fidl::Error> {
630        DeviceIdentificationHandleEvent::decode(
631            self.client.wait_for_event::<DeviceIdentificationHandleMarker>(deadline)?,
632        )
633    }
634}
635
636#[cfg(target_os = "fuchsia")]
637impl From<DeviceIdentificationHandleSynchronousProxy> for zx::NullableHandle {
638    fn from(value: DeviceIdentificationHandleSynchronousProxy) -> Self {
639        value.into_channel().into()
640    }
641}
642
643#[cfg(target_os = "fuchsia")]
644impl From<fidl::Channel> for DeviceIdentificationHandleSynchronousProxy {
645    fn from(value: fidl::Channel) -> Self {
646        Self::new(value)
647    }
648}
649
650#[cfg(target_os = "fuchsia")]
651impl fidl::endpoints::FromClient for DeviceIdentificationHandleSynchronousProxy {
652    type Protocol = DeviceIdentificationHandleMarker;
653
654    fn from_client(value: fidl::endpoints::ClientEnd<DeviceIdentificationHandleMarker>) -> Self {
655        Self::new(value.into_channel())
656    }
657}
658
659#[derive(Debug, Clone)]
660pub struct DeviceIdentificationHandleProxy {
661    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
662}
663
664impl fidl::endpoints::Proxy for DeviceIdentificationHandleProxy {
665    type Protocol = DeviceIdentificationHandleMarker;
666
667    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
668        Self::new(inner)
669    }
670
671    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
672        self.client.into_channel().map_err(|client| Self { client })
673    }
674
675    fn as_channel(&self) -> &::fidl::AsyncChannel {
676        self.client.as_channel()
677    }
678}
679
680impl DeviceIdentificationHandleProxy {
681    /// Create a new Proxy for fuchsia.bluetooth.deviceid/DeviceIdentificationHandle.
682    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
683        let protocol_name =
684            <DeviceIdentificationHandleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
685        Self { client: fidl::client::Client::new(channel, protocol_name) }
686    }
687
688    /// Get a Stream of events from the remote end of the protocol.
689    ///
690    /// # Panics
691    ///
692    /// Panics if the event stream was already taken.
693    pub fn take_event_stream(&self) -> DeviceIdentificationHandleEventStream {
694        DeviceIdentificationHandleEventStream { event_receiver: self.client.take_event_receiver() }
695    }
696}
697
698impl DeviceIdentificationHandleProxyInterface for DeviceIdentificationHandleProxy {}
699
700pub struct DeviceIdentificationHandleEventStream {
701    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
702}
703
704impl std::marker::Unpin for DeviceIdentificationHandleEventStream {}
705
706impl futures::stream::FusedStream for DeviceIdentificationHandleEventStream {
707    fn is_terminated(&self) -> bool {
708        self.event_receiver.is_terminated()
709    }
710}
711
712impl futures::Stream for DeviceIdentificationHandleEventStream {
713    type Item = Result<DeviceIdentificationHandleEvent, fidl::Error>;
714
715    fn poll_next(
716        mut self: std::pin::Pin<&mut Self>,
717        cx: &mut std::task::Context<'_>,
718    ) -> std::task::Poll<Option<Self::Item>> {
719        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
720            &mut self.event_receiver,
721            cx
722        )?) {
723            Some(buf) => std::task::Poll::Ready(Some(DeviceIdentificationHandleEvent::decode(buf))),
724            None => std::task::Poll::Ready(None),
725        }
726    }
727}
728
729#[derive(Debug)]
730pub enum DeviceIdentificationHandleEvent {}
731
732impl DeviceIdentificationHandleEvent {
733    /// Decodes a message buffer as a [`DeviceIdentificationHandleEvent`].
734    fn decode(
735        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
736    ) -> Result<DeviceIdentificationHandleEvent, fidl::Error> {
737        let (bytes, _handles) = buf.split_mut();
738        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
739        debug_assert_eq!(tx_header.tx_id, 0);
740        match tx_header.ordinal {
741            _ => Err(fidl::Error::UnknownOrdinal {
742                ordinal: tx_header.ordinal,
743                protocol_name: <DeviceIdentificationHandleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
744            })
745        }
746    }
747}
748
749/// A Stream of incoming requests for fuchsia.bluetooth.deviceid/DeviceIdentificationHandle.
750pub struct DeviceIdentificationHandleRequestStream {
751    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
752    is_terminated: bool,
753}
754
755impl std::marker::Unpin for DeviceIdentificationHandleRequestStream {}
756
757impl futures::stream::FusedStream for DeviceIdentificationHandleRequestStream {
758    fn is_terminated(&self) -> bool {
759        self.is_terminated
760    }
761}
762
763impl fidl::endpoints::RequestStream for DeviceIdentificationHandleRequestStream {
764    type Protocol = DeviceIdentificationHandleMarker;
765    type ControlHandle = DeviceIdentificationHandleControlHandle;
766
767    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
768        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
769    }
770
771    fn control_handle(&self) -> Self::ControlHandle {
772        DeviceIdentificationHandleControlHandle { inner: self.inner.clone() }
773    }
774
775    fn into_inner(
776        self,
777    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
778    {
779        (self.inner, self.is_terminated)
780    }
781
782    fn from_inner(
783        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
784        is_terminated: bool,
785    ) -> Self {
786        Self { inner, is_terminated }
787    }
788}
789
790impl futures::Stream for DeviceIdentificationHandleRequestStream {
791    type Item = Result<DeviceIdentificationHandleRequest, fidl::Error>;
792
793    fn poll_next(
794        mut self: std::pin::Pin<&mut Self>,
795        cx: &mut std::task::Context<'_>,
796    ) -> std::task::Poll<Option<Self::Item>> {
797        let this = &mut *self;
798        if this.inner.check_shutdown(cx) {
799            this.is_terminated = true;
800            return std::task::Poll::Ready(None);
801        }
802        if this.is_terminated {
803            panic!("polled DeviceIdentificationHandleRequestStream after completion");
804        }
805        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
806            |bytes, handles| {
807                match this.inner.channel().read_etc(cx, bytes, handles) {
808                    std::task::Poll::Ready(Ok(())) => {}
809                    std::task::Poll::Pending => return std::task::Poll::Pending,
810                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
811                        this.is_terminated = true;
812                        return std::task::Poll::Ready(None);
813                    }
814                    std::task::Poll::Ready(Err(e)) => {
815                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
816                            e.into(),
817                        ))));
818                    }
819                }
820
821                // A message has been received from the channel
822                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
823
824                std::task::Poll::Ready(Some(match header.ordinal {
825                _ => Err(fidl::Error::UnknownOrdinal {
826                    ordinal: header.ordinal,
827                    protocol_name: <DeviceIdentificationHandleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
828                }),
829            }))
830            },
831        )
832    }
833}
834
835/// Represents an active device identification advertisement. Close the handle with any epitaph to
836/// unregister the device identification request.
837#[derive(Debug)]
838pub enum DeviceIdentificationHandleRequest {}
839
840impl DeviceIdentificationHandleRequest {
841    /// Name of the method defined in FIDL
842    pub fn method_name(&self) -> &'static str {
843        match *self {}
844    }
845}
846
847#[derive(Debug, Clone)]
848pub struct DeviceIdentificationHandleControlHandle {
849    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
850}
851
852impl fidl::endpoints::ControlHandle for DeviceIdentificationHandleControlHandle {
853    fn shutdown(&self) {
854        self.inner.shutdown()
855    }
856
857    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
858        self.inner.shutdown_with_epitaph(status)
859    }
860
861    fn is_closed(&self) -> bool {
862        self.inner.channel().is_closed()
863    }
864    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
865        self.inner.channel().on_closed()
866    }
867
868    #[cfg(target_os = "fuchsia")]
869    fn signal_peer(
870        &self,
871        clear_mask: zx::Signals,
872        set_mask: zx::Signals,
873    ) -> Result<(), zx_status::Status> {
874        use fidl::Peered;
875        self.inner.channel().signal_peer(clear_mask, set_mask)
876    }
877}
878
879impl DeviceIdentificationHandleControlHandle {}
880
881mod internal {
882    use super::*;
883
884    impl fidl::encoding::ResourceTypeMarker for DeviceIdentificationSetDeviceIdentificationRequest {
885        type Borrowed<'a> = &'a mut Self;
886        fn take_or_borrow<'a>(
887            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
888        ) -> Self::Borrowed<'a> {
889            value
890        }
891    }
892
893    unsafe impl fidl::encoding::TypeMarker for DeviceIdentificationSetDeviceIdentificationRequest {
894        type Owned = Self;
895
896        #[inline(always)]
897        fn inline_align(_context: fidl::encoding::Context) -> usize {
898            8
899        }
900
901        #[inline(always)]
902        fn inline_size(_context: fidl::encoding::Context) -> usize {
903            24
904        }
905    }
906
907    unsafe impl
908        fidl::encoding::Encode<
909            DeviceIdentificationSetDeviceIdentificationRequest,
910            fidl::encoding::DefaultFuchsiaResourceDialect,
911        > for &mut DeviceIdentificationSetDeviceIdentificationRequest
912    {
913        #[inline]
914        unsafe fn encode(
915            self,
916            encoder: &mut fidl::encoding::Encoder<
917                '_,
918                fidl::encoding::DefaultFuchsiaResourceDialect,
919            >,
920            offset: usize,
921            _depth: fidl::encoding::Depth,
922        ) -> fidl::Result<()> {
923            encoder
924                .debug_check_bounds::<DeviceIdentificationSetDeviceIdentificationRequest>(offset);
925            // Delegate to tuple encoding.
926            fidl::encoding::Encode::<DeviceIdentificationSetDeviceIdentificationRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
927                (
928                    <fidl::encoding::Vector<DeviceIdentificationRecord, 3> as fidl::encoding::ValueTypeMarker>::borrow(&self.records),
929                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceIdentificationHandleMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.token),
930                ),
931                encoder, offset, _depth
932            )
933        }
934    }
935    unsafe impl<
936        T0: fidl::encoding::Encode<
937                fidl::encoding::Vector<DeviceIdentificationRecord, 3>,
938                fidl::encoding::DefaultFuchsiaResourceDialect,
939            >,
940        T1: fidl::encoding::Encode<
941                fidl::encoding::Endpoint<
942                    fidl::endpoints::ServerEnd<DeviceIdentificationHandleMarker>,
943                >,
944                fidl::encoding::DefaultFuchsiaResourceDialect,
945            >,
946    >
947        fidl::encoding::Encode<
948            DeviceIdentificationSetDeviceIdentificationRequest,
949            fidl::encoding::DefaultFuchsiaResourceDialect,
950        > for (T0, T1)
951    {
952        #[inline]
953        unsafe fn encode(
954            self,
955            encoder: &mut fidl::encoding::Encoder<
956                '_,
957                fidl::encoding::DefaultFuchsiaResourceDialect,
958            >,
959            offset: usize,
960            depth: fidl::encoding::Depth,
961        ) -> fidl::Result<()> {
962            encoder
963                .debug_check_bounds::<DeviceIdentificationSetDeviceIdentificationRequest>(offset);
964            // Zero out padding regions. There's no need to apply masks
965            // because the unmasked parts will be overwritten by fields.
966            unsafe {
967                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
968                (ptr as *mut u64).write_unaligned(0);
969            }
970            // Write the fields.
971            self.0.encode(encoder, offset + 0, depth)?;
972            self.1.encode(encoder, offset + 16, depth)?;
973            Ok(())
974        }
975    }
976
977    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
978        for DeviceIdentificationSetDeviceIdentificationRequest
979    {
980        #[inline(always)]
981        fn new_empty() -> Self {
982            Self {
983                records: fidl::new_empty!(fidl::encoding::Vector<DeviceIdentificationRecord, 3>, fidl::encoding::DefaultFuchsiaResourceDialect),
984                token: fidl::new_empty!(
985                    fidl::encoding::Endpoint<
986                        fidl::endpoints::ServerEnd<DeviceIdentificationHandleMarker>,
987                    >,
988                    fidl::encoding::DefaultFuchsiaResourceDialect
989                ),
990            }
991        }
992
993        #[inline]
994        unsafe fn decode(
995            &mut self,
996            decoder: &mut fidl::encoding::Decoder<
997                '_,
998                fidl::encoding::DefaultFuchsiaResourceDialect,
999            >,
1000            offset: usize,
1001            _depth: fidl::encoding::Depth,
1002        ) -> fidl::Result<()> {
1003            decoder.debug_check_bounds::<Self>(offset);
1004            // Verify that padding bytes are zero.
1005            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1006            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1007            let mask = 0xffffffff00000000u64;
1008            let maskedval = padval & mask;
1009            if maskedval != 0 {
1010                return Err(fidl::Error::NonZeroPadding {
1011                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1012                });
1013            }
1014            fidl::decode!(fidl::encoding::Vector<DeviceIdentificationRecord, 3>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.records, decoder, offset + 0, _depth)?;
1015            fidl::decode!(
1016                fidl::encoding::Endpoint<
1017                    fidl::endpoints::ServerEnd<DeviceIdentificationHandleMarker>,
1018                >,
1019                fidl::encoding::DefaultFuchsiaResourceDialect,
1020                &mut self.token,
1021                decoder,
1022                offset + 16,
1023                _depth
1024            )?;
1025            Ok(())
1026        }
1027    }
1028}