fidl_fuchsia_location_sensor/
fidl_fuchsia_location_sensor.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_location_sensor_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct WlanBaseStationWatcherReportCurrentStationsRequest {
16    pub stations: fidl::endpoints::ClientEnd<fidl_fuchsia_wlan_policy::ScanResultIteratorMarker>,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20    for WlanBaseStationWatcherReportCurrentStationsRequest
21{
22}
23
24#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
25pub struct WlanBaseStationWatcherMarker;
26
27impl fidl::endpoints::ProtocolMarker for WlanBaseStationWatcherMarker {
28    type Proxy = WlanBaseStationWatcherProxy;
29    type RequestStream = WlanBaseStationWatcherRequestStream;
30    #[cfg(target_os = "fuchsia")]
31    type SynchronousProxy = WlanBaseStationWatcherSynchronousProxy;
32
33    const DEBUG_NAME: &'static str = "fuchsia.location.sensor.WlanBaseStationWatcher";
34}
35impl fidl::endpoints::DiscoverableProtocolMarker for WlanBaseStationWatcherMarker {}
36
37pub trait WlanBaseStationWatcherProxyInterface: Send + Sync {
38    fn r#report_current_stations(
39        &self,
40        stations: fidl::endpoints::ClientEnd<fidl_fuchsia_wlan_policy::ScanResultIteratorMarker>,
41    ) -> Result<(), fidl::Error>;
42}
43#[derive(Debug)]
44#[cfg(target_os = "fuchsia")]
45pub struct WlanBaseStationWatcherSynchronousProxy {
46    client: fidl::client::sync::Client,
47}
48
49#[cfg(target_os = "fuchsia")]
50impl fidl::endpoints::SynchronousProxy for WlanBaseStationWatcherSynchronousProxy {
51    type Proxy = WlanBaseStationWatcherProxy;
52    type Protocol = WlanBaseStationWatcherMarker;
53
54    fn from_channel(inner: fidl::Channel) -> Self {
55        Self::new(inner)
56    }
57
58    fn into_channel(self) -> fidl::Channel {
59        self.client.into_channel()
60    }
61
62    fn as_channel(&self) -> &fidl::Channel {
63        self.client.as_channel()
64    }
65}
66
67#[cfg(target_os = "fuchsia")]
68impl WlanBaseStationWatcherSynchronousProxy {
69    pub fn new(channel: fidl::Channel) -> Self {
70        let protocol_name =
71            <WlanBaseStationWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
72        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
73    }
74
75    pub fn into_channel(self) -> fidl::Channel {
76        self.client.into_channel()
77    }
78
79    /// Waits until an event arrives and returns it. It is safe for other
80    /// threads to make concurrent requests while waiting for an event.
81    pub fn wait_for_event(
82        &self,
83        deadline: zx::MonotonicInstant,
84    ) -> Result<WlanBaseStationWatcherEvent, fidl::Error> {
85        WlanBaseStationWatcherEvent::decode(self.client.wait_for_event(deadline)?)
86    }
87
88    /// Provides a handle with which to enumerate the stations currently visible
89    /// to the device.
90    pub fn r#report_current_stations(
91        &self,
92        mut stations: fidl::endpoints::ClientEnd<
93            fidl_fuchsia_wlan_policy::ScanResultIteratorMarker,
94        >,
95    ) -> Result<(), fidl::Error> {
96        self.client.send::<WlanBaseStationWatcherReportCurrentStationsRequest>(
97            (stations,),
98            0x28fb79c8f0a302ca,
99            fidl::encoding::DynamicFlags::empty(),
100        )
101    }
102}
103
104#[cfg(target_os = "fuchsia")]
105impl From<WlanBaseStationWatcherSynchronousProxy> for zx::Handle {
106    fn from(value: WlanBaseStationWatcherSynchronousProxy) -> Self {
107        value.into_channel().into()
108    }
109}
110
111#[cfg(target_os = "fuchsia")]
112impl From<fidl::Channel> for WlanBaseStationWatcherSynchronousProxy {
113    fn from(value: fidl::Channel) -> Self {
114        Self::new(value)
115    }
116}
117
118#[derive(Debug, Clone)]
119pub struct WlanBaseStationWatcherProxy {
120    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
121}
122
123impl fidl::endpoints::Proxy for WlanBaseStationWatcherProxy {
124    type Protocol = WlanBaseStationWatcherMarker;
125
126    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
127        Self::new(inner)
128    }
129
130    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
131        self.client.into_channel().map_err(|client| Self { client })
132    }
133
134    fn as_channel(&self) -> &::fidl::AsyncChannel {
135        self.client.as_channel()
136    }
137}
138
139impl WlanBaseStationWatcherProxy {
140    /// Create a new Proxy for fuchsia.location.sensor/WlanBaseStationWatcher.
141    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
142        let protocol_name =
143            <WlanBaseStationWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
144        Self { client: fidl::client::Client::new(channel, protocol_name) }
145    }
146
147    /// Get a Stream of events from the remote end of the protocol.
148    ///
149    /// # Panics
150    ///
151    /// Panics if the event stream was already taken.
152    pub fn take_event_stream(&self) -> WlanBaseStationWatcherEventStream {
153        WlanBaseStationWatcherEventStream { event_receiver: self.client.take_event_receiver() }
154    }
155
156    /// Provides a handle with which to enumerate the stations currently visible
157    /// to the device.
158    pub fn r#report_current_stations(
159        &self,
160        mut stations: fidl::endpoints::ClientEnd<
161            fidl_fuchsia_wlan_policy::ScanResultIteratorMarker,
162        >,
163    ) -> Result<(), fidl::Error> {
164        WlanBaseStationWatcherProxyInterface::r#report_current_stations(self, stations)
165    }
166}
167
168impl WlanBaseStationWatcherProxyInterface for WlanBaseStationWatcherProxy {
169    fn r#report_current_stations(
170        &self,
171        mut stations: fidl::endpoints::ClientEnd<
172            fidl_fuchsia_wlan_policy::ScanResultIteratorMarker,
173        >,
174    ) -> Result<(), fidl::Error> {
175        self.client.send::<WlanBaseStationWatcherReportCurrentStationsRequest>(
176            (stations,),
177            0x28fb79c8f0a302ca,
178            fidl::encoding::DynamicFlags::empty(),
179        )
180    }
181}
182
183pub struct WlanBaseStationWatcherEventStream {
184    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
185}
186
187impl std::marker::Unpin for WlanBaseStationWatcherEventStream {}
188
189impl futures::stream::FusedStream for WlanBaseStationWatcherEventStream {
190    fn is_terminated(&self) -> bool {
191        self.event_receiver.is_terminated()
192    }
193}
194
195impl futures::Stream for WlanBaseStationWatcherEventStream {
196    type Item = Result<WlanBaseStationWatcherEvent, fidl::Error>;
197
198    fn poll_next(
199        mut self: std::pin::Pin<&mut Self>,
200        cx: &mut std::task::Context<'_>,
201    ) -> std::task::Poll<Option<Self::Item>> {
202        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
203            &mut self.event_receiver,
204            cx
205        )?) {
206            Some(buf) => std::task::Poll::Ready(Some(WlanBaseStationWatcherEvent::decode(buf))),
207            None => std::task::Poll::Ready(None),
208        }
209    }
210}
211
212#[derive(Debug)]
213pub enum WlanBaseStationWatcherEvent {}
214
215impl WlanBaseStationWatcherEvent {
216    /// Decodes a message buffer as a [`WlanBaseStationWatcherEvent`].
217    fn decode(
218        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
219    ) -> Result<WlanBaseStationWatcherEvent, fidl::Error> {
220        let (bytes, _handles) = buf.split_mut();
221        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
222        debug_assert_eq!(tx_header.tx_id, 0);
223        match tx_header.ordinal {
224            _ => Err(fidl::Error::UnknownOrdinal {
225                ordinal: tx_header.ordinal,
226                protocol_name:
227                    <WlanBaseStationWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
228            }),
229        }
230    }
231}
232
233/// A Stream of incoming requests for fuchsia.location.sensor/WlanBaseStationWatcher.
234pub struct WlanBaseStationWatcherRequestStream {
235    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
236    is_terminated: bool,
237}
238
239impl std::marker::Unpin for WlanBaseStationWatcherRequestStream {}
240
241impl futures::stream::FusedStream for WlanBaseStationWatcherRequestStream {
242    fn is_terminated(&self) -> bool {
243        self.is_terminated
244    }
245}
246
247impl fidl::endpoints::RequestStream for WlanBaseStationWatcherRequestStream {
248    type Protocol = WlanBaseStationWatcherMarker;
249    type ControlHandle = WlanBaseStationWatcherControlHandle;
250
251    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
252        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
253    }
254
255    fn control_handle(&self) -> Self::ControlHandle {
256        WlanBaseStationWatcherControlHandle { inner: self.inner.clone() }
257    }
258
259    fn into_inner(
260        self,
261    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
262    {
263        (self.inner, self.is_terminated)
264    }
265
266    fn from_inner(
267        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
268        is_terminated: bool,
269    ) -> Self {
270        Self { inner, is_terminated }
271    }
272}
273
274impl futures::Stream for WlanBaseStationWatcherRequestStream {
275    type Item = Result<WlanBaseStationWatcherRequest, fidl::Error>;
276
277    fn poll_next(
278        mut self: std::pin::Pin<&mut Self>,
279        cx: &mut std::task::Context<'_>,
280    ) -> std::task::Poll<Option<Self::Item>> {
281        let this = &mut *self;
282        if this.inner.check_shutdown(cx) {
283            this.is_terminated = true;
284            return std::task::Poll::Ready(None);
285        }
286        if this.is_terminated {
287            panic!("polled WlanBaseStationWatcherRequestStream after completion");
288        }
289        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
290            |bytes, handles| {
291                match this.inner.channel().read_etc(cx, bytes, handles) {
292                    std::task::Poll::Ready(Ok(())) => {}
293                    std::task::Poll::Pending => return std::task::Poll::Pending,
294                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
295                        this.is_terminated = true;
296                        return std::task::Poll::Ready(None);
297                    }
298                    std::task::Poll::Ready(Err(e)) => {
299                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
300                            e.into(),
301                        ))))
302                    }
303                }
304
305                // A message has been received from the channel
306                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
307
308                std::task::Poll::Ready(Some(match header.ordinal {
309                0x28fb79c8f0a302ca => {
310                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
311                    let mut req = fidl::new_empty!(WlanBaseStationWatcherReportCurrentStationsRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
312                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<WlanBaseStationWatcherReportCurrentStationsRequest>(&header, _body_bytes, handles, &mut req)?;
313                    let control_handle = WlanBaseStationWatcherControlHandle {
314                        inner: this.inner.clone(),
315                    };
316                    Ok(WlanBaseStationWatcherRequest::ReportCurrentStations {stations: req.stations,
317
318                        control_handle,
319                    })
320                }
321                _ => Err(fidl::Error::UnknownOrdinal {
322                    ordinal: header.ordinal,
323                    protocol_name: <WlanBaseStationWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
324                }),
325            }))
326            },
327        )
328    }
329}
330
331/// Passively accepts WLAN scan results.
332#[derive(Debug)]
333pub enum WlanBaseStationWatcherRequest {
334    /// Provides a handle with which to enumerate the stations currently visible
335    /// to the device.
336    ReportCurrentStations {
337        stations: fidl::endpoints::ClientEnd<fidl_fuchsia_wlan_policy::ScanResultIteratorMarker>,
338        control_handle: WlanBaseStationWatcherControlHandle,
339    },
340}
341
342impl WlanBaseStationWatcherRequest {
343    #[allow(irrefutable_let_patterns)]
344    pub fn into_report_current_stations(
345        self,
346    ) -> Option<(
347        fidl::endpoints::ClientEnd<fidl_fuchsia_wlan_policy::ScanResultIteratorMarker>,
348        WlanBaseStationWatcherControlHandle,
349    )> {
350        if let WlanBaseStationWatcherRequest::ReportCurrentStations { stations, control_handle } =
351            self
352        {
353            Some((stations, control_handle))
354        } else {
355            None
356        }
357    }
358
359    /// Name of the method defined in FIDL
360    pub fn method_name(&self) -> &'static str {
361        match *self {
362            WlanBaseStationWatcherRequest::ReportCurrentStations { .. } => {
363                "report_current_stations"
364            }
365        }
366    }
367}
368
369#[derive(Debug, Clone)]
370pub struct WlanBaseStationWatcherControlHandle {
371    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
372}
373
374impl fidl::endpoints::ControlHandle for WlanBaseStationWatcherControlHandle {
375    fn shutdown(&self) {
376        self.inner.shutdown()
377    }
378    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
379        self.inner.shutdown_with_epitaph(status)
380    }
381
382    fn is_closed(&self) -> bool {
383        self.inner.channel().is_closed()
384    }
385    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
386        self.inner.channel().on_closed()
387    }
388
389    #[cfg(target_os = "fuchsia")]
390    fn signal_peer(
391        &self,
392        clear_mask: zx::Signals,
393        set_mask: zx::Signals,
394    ) -> Result<(), zx_status::Status> {
395        use fidl::Peered;
396        self.inner.channel().signal_peer(clear_mask, set_mask)
397    }
398}
399
400impl WlanBaseStationWatcherControlHandle {}
401
402mod internal {
403    use super::*;
404
405    impl fidl::encoding::ResourceTypeMarker for WlanBaseStationWatcherReportCurrentStationsRequest {
406        type Borrowed<'a> = &'a mut Self;
407        fn take_or_borrow<'a>(
408            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
409        ) -> Self::Borrowed<'a> {
410            value
411        }
412    }
413
414    unsafe impl fidl::encoding::TypeMarker for WlanBaseStationWatcherReportCurrentStationsRequest {
415        type Owned = Self;
416
417        #[inline(always)]
418        fn inline_align(_context: fidl::encoding::Context) -> usize {
419            4
420        }
421
422        #[inline(always)]
423        fn inline_size(_context: fidl::encoding::Context) -> usize {
424            4
425        }
426    }
427
428    unsafe impl
429        fidl::encoding::Encode<
430            WlanBaseStationWatcherReportCurrentStationsRequest,
431            fidl::encoding::DefaultFuchsiaResourceDialect,
432        > for &mut WlanBaseStationWatcherReportCurrentStationsRequest
433    {
434        #[inline]
435        unsafe fn encode(
436            self,
437            encoder: &mut fidl::encoding::Encoder<
438                '_,
439                fidl::encoding::DefaultFuchsiaResourceDialect,
440            >,
441            offset: usize,
442            _depth: fidl::encoding::Depth,
443        ) -> fidl::Result<()> {
444            encoder
445                .debug_check_bounds::<WlanBaseStationWatcherReportCurrentStationsRequest>(offset);
446            // Delegate to tuple encoding.
447            fidl::encoding::Encode::<
448                WlanBaseStationWatcherReportCurrentStationsRequest,
449                fidl::encoding::DefaultFuchsiaResourceDialect,
450            >::encode(
451                (<fidl::encoding::Endpoint<
452                    fidl::endpoints::ClientEnd<fidl_fuchsia_wlan_policy::ScanResultIteratorMarker>,
453                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
454                    &mut self.stations
455                ),),
456                encoder,
457                offset,
458                _depth,
459            )
460        }
461    }
462    unsafe impl<
463            T0: fidl::encoding::Encode<
464                fidl::encoding::Endpoint<
465                    fidl::endpoints::ClientEnd<fidl_fuchsia_wlan_policy::ScanResultIteratorMarker>,
466                >,
467                fidl::encoding::DefaultFuchsiaResourceDialect,
468            >,
469        >
470        fidl::encoding::Encode<
471            WlanBaseStationWatcherReportCurrentStationsRequest,
472            fidl::encoding::DefaultFuchsiaResourceDialect,
473        > for (T0,)
474    {
475        #[inline]
476        unsafe fn encode(
477            self,
478            encoder: &mut fidl::encoding::Encoder<
479                '_,
480                fidl::encoding::DefaultFuchsiaResourceDialect,
481            >,
482            offset: usize,
483            depth: fidl::encoding::Depth,
484        ) -> fidl::Result<()> {
485            encoder
486                .debug_check_bounds::<WlanBaseStationWatcherReportCurrentStationsRequest>(offset);
487            // Zero out padding regions. There's no need to apply masks
488            // because the unmasked parts will be overwritten by fields.
489            // Write the fields.
490            self.0.encode(encoder, offset + 0, depth)?;
491            Ok(())
492        }
493    }
494
495    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
496        for WlanBaseStationWatcherReportCurrentStationsRequest
497    {
498        #[inline(always)]
499        fn new_empty() -> Self {
500            Self {
501                stations: fidl::new_empty!(
502                    fidl::encoding::Endpoint<
503                        fidl::endpoints::ClientEnd<
504                            fidl_fuchsia_wlan_policy::ScanResultIteratorMarker,
505                        >,
506                    >,
507                    fidl::encoding::DefaultFuchsiaResourceDialect
508                ),
509            }
510        }
511
512        #[inline]
513        unsafe fn decode(
514            &mut self,
515            decoder: &mut fidl::encoding::Decoder<
516                '_,
517                fidl::encoding::DefaultFuchsiaResourceDialect,
518            >,
519            offset: usize,
520            _depth: fidl::encoding::Depth,
521        ) -> fidl::Result<()> {
522            decoder.debug_check_bounds::<Self>(offset);
523            // Verify that padding bytes are zero.
524            fidl::decode!(
525                fidl::encoding::Endpoint<
526                    fidl::endpoints::ClientEnd<fidl_fuchsia_wlan_policy::ScanResultIteratorMarker>,
527                >,
528                fidl::encoding::DefaultFuchsiaResourceDialect,
529                &mut self.stations,
530                decoder,
531                offset + 0,
532                _depth
533            )?;
534            Ok(())
535        }
536    }
537}