Skip to main content

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