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