Skip to main content

fidl_fuchsia_wlan_tap/
fidl_fuchsia_wlan_tap.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_wlan_tap_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct WlantapCtlCreatePhyRequest {
16    pub config: WlantapPhyConfig,
17    pub proxy: fidl::endpoints::ServerEnd<WlantapPhyMarker>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
21    for WlantapCtlCreatePhyRequest
22{
23}
24
25#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
26pub struct WlantapCtlMarker;
27
28impl fidl::endpoints::ProtocolMarker for WlantapCtlMarker {
29    type Proxy = WlantapCtlProxy;
30    type RequestStream = WlantapCtlRequestStream;
31    #[cfg(target_os = "fuchsia")]
32    type SynchronousProxy = WlantapCtlSynchronousProxy;
33
34    const DEBUG_NAME: &'static str = "(anonymous) WlantapCtl";
35}
36
37pub trait WlantapCtlProxyInterface: Send + Sync {
38    type CreatePhyResponseFut: std::future::Future<Output = Result<i32, fidl::Error>> + Send;
39    fn r#create_phy(
40        &self,
41        config: &WlantapPhyConfig,
42        proxy: fidl::endpoints::ServerEnd<WlantapPhyMarker>,
43    ) -> Self::CreatePhyResponseFut;
44}
45#[derive(Debug)]
46#[cfg(target_os = "fuchsia")]
47pub struct WlantapCtlSynchronousProxy {
48    client: fidl::client::sync::Client,
49}
50
51#[cfg(target_os = "fuchsia")]
52impl fidl::endpoints::SynchronousProxy for WlantapCtlSynchronousProxy {
53    type Proxy = WlantapCtlProxy;
54    type Protocol = WlantapCtlMarker;
55
56    fn from_channel(inner: fidl::Channel) -> Self {
57        Self::new(inner)
58    }
59
60    fn into_channel(self) -> fidl::Channel {
61        self.client.into_channel()
62    }
63
64    fn as_channel(&self) -> &fidl::Channel {
65        self.client.as_channel()
66    }
67}
68
69#[cfg(target_os = "fuchsia")]
70impl WlantapCtlSynchronousProxy {
71    pub fn new(channel: fidl::Channel) -> Self {
72        Self { client: fidl::client::sync::Client::new(channel) }
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<WlantapCtlEvent, fidl::Error> {
85        WlantapCtlEvent::decode(self.client.wait_for_event::<WlantapCtlMarker>(deadline)?)
86    }
87
88    pub fn r#create_phy(
89        &self,
90        mut config: &WlantapPhyConfig,
91        mut proxy: fidl::endpoints::ServerEnd<WlantapPhyMarker>,
92        ___deadline: zx::MonotonicInstant,
93    ) -> Result<i32, fidl::Error> {
94        let _response = self.client.send_query::<
95            WlantapCtlCreatePhyRequest,
96            WlantapCtlCreatePhyResponse,
97            WlantapCtlMarker,
98        >(
99            (config, proxy,),
100            0x50273d8f10ceb35d,
101            fidl::encoding::DynamicFlags::empty(),
102            ___deadline,
103        )?;
104        Ok(_response.status)
105    }
106}
107
108#[cfg(target_os = "fuchsia")]
109impl From<WlantapCtlSynchronousProxy> for zx::NullableHandle {
110    fn from(value: WlantapCtlSynchronousProxy) -> Self {
111        value.into_channel().into()
112    }
113}
114
115#[cfg(target_os = "fuchsia")]
116impl From<fidl::Channel> for WlantapCtlSynchronousProxy {
117    fn from(value: fidl::Channel) -> Self {
118        Self::new(value)
119    }
120}
121
122#[cfg(target_os = "fuchsia")]
123impl fidl::endpoints::FromClient for WlantapCtlSynchronousProxy {
124    type Protocol = WlantapCtlMarker;
125
126    fn from_client(value: fidl::endpoints::ClientEnd<WlantapCtlMarker>) -> Self {
127        Self::new(value.into_channel())
128    }
129}
130
131#[derive(Debug, Clone)]
132pub struct WlantapCtlProxy {
133    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
134}
135
136impl fidl::endpoints::Proxy for WlantapCtlProxy {
137    type Protocol = WlantapCtlMarker;
138
139    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
140        Self::new(inner)
141    }
142
143    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
144        self.client.into_channel().map_err(|client| Self { client })
145    }
146
147    fn as_channel(&self) -> &::fidl::AsyncChannel {
148        self.client.as_channel()
149    }
150}
151
152impl WlantapCtlProxy {
153    /// Create a new Proxy for fuchsia.wlan.tap/WlantapCtl.
154    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
155        let protocol_name = <WlantapCtlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
156        Self { client: fidl::client::Client::new(channel, protocol_name) }
157    }
158
159    /// Get a Stream of events from the remote end of the protocol.
160    ///
161    /// # Panics
162    ///
163    /// Panics if the event stream was already taken.
164    pub fn take_event_stream(&self) -> WlantapCtlEventStream {
165        WlantapCtlEventStream { event_receiver: self.client.take_event_receiver() }
166    }
167
168    pub fn r#create_phy(
169        &self,
170        mut config: &WlantapPhyConfig,
171        mut proxy: fidl::endpoints::ServerEnd<WlantapPhyMarker>,
172    ) -> fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect> {
173        WlantapCtlProxyInterface::r#create_phy(self, config, proxy)
174    }
175}
176
177impl WlantapCtlProxyInterface for WlantapCtlProxy {
178    type CreatePhyResponseFut =
179        fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect>;
180    fn r#create_phy(
181        &self,
182        mut config: &WlantapPhyConfig,
183        mut proxy: fidl::endpoints::ServerEnd<WlantapPhyMarker>,
184    ) -> Self::CreatePhyResponseFut {
185        fn _decode(
186            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
187        ) -> Result<i32, fidl::Error> {
188            let _response = fidl::client::decode_transaction_body::<
189                WlantapCtlCreatePhyResponse,
190                fidl::encoding::DefaultFuchsiaResourceDialect,
191                0x50273d8f10ceb35d,
192            >(_buf?)?;
193            Ok(_response.status)
194        }
195        self.client.send_query_and_decode::<WlantapCtlCreatePhyRequest, i32>(
196            (config, proxy),
197            0x50273d8f10ceb35d,
198            fidl::encoding::DynamicFlags::empty(),
199            _decode,
200        )
201    }
202}
203
204pub struct WlantapCtlEventStream {
205    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
206}
207
208impl std::marker::Unpin for WlantapCtlEventStream {}
209
210impl futures::stream::FusedStream for WlantapCtlEventStream {
211    fn is_terminated(&self) -> bool {
212        self.event_receiver.is_terminated()
213    }
214}
215
216impl futures::Stream for WlantapCtlEventStream {
217    type Item = Result<WlantapCtlEvent, fidl::Error>;
218
219    fn poll_next(
220        mut self: std::pin::Pin<&mut Self>,
221        cx: &mut std::task::Context<'_>,
222    ) -> std::task::Poll<Option<Self::Item>> {
223        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
224            &mut self.event_receiver,
225            cx
226        )?) {
227            Some(buf) => std::task::Poll::Ready(Some(WlantapCtlEvent::decode(buf))),
228            None => std::task::Poll::Ready(None),
229        }
230    }
231}
232
233#[derive(Debug)]
234pub enum WlantapCtlEvent {}
235
236impl WlantapCtlEvent {
237    /// Decodes a message buffer as a [`WlantapCtlEvent`].
238    fn decode(
239        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
240    ) -> Result<WlantapCtlEvent, fidl::Error> {
241        let (bytes, _handles) = buf.split_mut();
242        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
243        debug_assert_eq!(tx_header.tx_id, 0);
244        match tx_header.ordinal {
245            _ => Err(fidl::Error::UnknownOrdinal {
246                ordinal: tx_header.ordinal,
247                protocol_name: <WlantapCtlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
248            }),
249        }
250    }
251}
252
253/// A Stream of incoming requests for fuchsia.wlan.tap/WlantapCtl.
254pub struct WlantapCtlRequestStream {
255    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
256    is_terminated: bool,
257}
258
259impl std::marker::Unpin for WlantapCtlRequestStream {}
260
261impl futures::stream::FusedStream for WlantapCtlRequestStream {
262    fn is_terminated(&self) -> bool {
263        self.is_terminated
264    }
265}
266
267impl fidl::endpoints::RequestStream for WlantapCtlRequestStream {
268    type Protocol = WlantapCtlMarker;
269    type ControlHandle = WlantapCtlControlHandle;
270
271    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
272        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
273    }
274
275    fn control_handle(&self) -> Self::ControlHandle {
276        WlantapCtlControlHandle { inner: self.inner.clone() }
277    }
278
279    fn into_inner(
280        self,
281    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
282    {
283        (self.inner, self.is_terminated)
284    }
285
286    fn from_inner(
287        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
288        is_terminated: bool,
289    ) -> Self {
290        Self { inner, is_terminated }
291    }
292}
293
294impl futures::Stream for WlantapCtlRequestStream {
295    type Item = Result<WlantapCtlRequest, fidl::Error>;
296
297    fn poll_next(
298        mut self: std::pin::Pin<&mut Self>,
299        cx: &mut std::task::Context<'_>,
300    ) -> std::task::Poll<Option<Self::Item>> {
301        let this = &mut *self;
302        if this.inner.check_shutdown(cx) {
303            this.is_terminated = true;
304            return std::task::Poll::Ready(None);
305        }
306        if this.is_terminated {
307            panic!("polled WlantapCtlRequestStream after completion");
308        }
309        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
310            |bytes, handles| {
311                match this.inner.channel().read_etc(cx, bytes, handles) {
312                    std::task::Poll::Ready(Ok(())) => {}
313                    std::task::Poll::Pending => return std::task::Poll::Pending,
314                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
315                        this.is_terminated = true;
316                        return std::task::Poll::Ready(None);
317                    }
318                    std::task::Poll::Ready(Err(e)) => {
319                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
320                            e.into(),
321                        ))));
322                    }
323                }
324
325                // A message has been received from the channel
326                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
327
328                std::task::Poll::Ready(Some(match header.ordinal {
329                    0x50273d8f10ceb35d => {
330                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
331                        let mut req = fidl::new_empty!(
332                            WlantapCtlCreatePhyRequest,
333                            fidl::encoding::DefaultFuchsiaResourceDialect
334                        );
335                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<WlantapCtlCreatePhyRequest>(&header, _body_bytes, handles, &mut req)?;
336                        let control_handle = WlantapCtlControlHandle { inner: this.inner.clone() };
337                        Ok(WlantapCtlRequest::CreatePhy {
338                            config: req.config,
339                            proxy: req.proxy,
340
341                            responder: WlantapCtlCreatePhyResponder {
342                                control_handle: std::mem::ManuallyDrop::new(control_handle),
343                                tx_id: header.tx_id,
344                            },
345                        })
346                    }
347                    _ => Err(fidl::Error::UnknownOrdinal {
348                        ordinal: header.ordinal,
349                        protocol_name:
350                            <WlantapCtlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
351                    }),
352                }))
353            },
354        )
355    }
356}
357
358/// Instruct the wlantap-ctl device to creates a fake wlantap-phy device based on the
359/// `WlantapPhyConfig` passed in. The newly created wlantap-phy device will use the channel to
360/// allow a `WlantapPhy` client to observe and control its behavior.
361#[derive(Debug)]
362pub enum WlantapCtlRequest {
363    CreatePhy {
364        config: WlantapPhyConfig,
365        proxy: fidl::endpoints::ServerEnd<WlantapPhyMarker>,
366        responder: WlantapCtlCreatePhyResponder,
367    },
368}
369
370impl WlantapCtlRequest {
371    #[allow(irrefutable_let_patterns)]
372    pub fn into_create_phy(
373        self,
374    ) -> Option<(
375        WlantapPhyConfig,
376        fidl::endpoints::ServerEnd<WlantapPhyMarker>,
377        WlantapCtlCreatePhyResponder,
378    )> {
379        if let WlantapCtlRequest::CreatePhy { config, proxy, responder } = self {
380            Some((config, proxy, responder))
381        } else {
382            None
383        }
384    }
385
386    /// Name of the method defined in FIDL
387    pub fn method_name(&self) -> &'static str {
388        match *self {
389            WlantapCtlRequest::CreatePhy { .. } => "create_phy",
390        }
391    }
392}
393
394#[derive(Debug, Clone)]
395pub struct WlantapCtlControlHandle {
396    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
397}
398
399impl WlantapCtlControlHandle {
400    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
401        self.inner.shutdown_with_epitaph(status.into())
402    }
403}
404
405impl fidl::endpoints::ControlHandle for WlantapCtlControlHandle {
406    fn shutdown(&self) {
407        self.inner.shutdown()
408    }
409
410    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
411        self.inner.shutdown_with_epitaph(status)
412    }
413
414    fn is_closed(&self) -> bool {
415        self.inner.channel().is_closed()
416    }
417    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
418        self.inner.channel().on_closed()
419    }
420
421    #[cfg(target_os = "fuchsia")]
422    fn signal_peer(
423        &self,
424        clear_mask: zx::Signals,
425        set_mask: zx::Signals,
426    ) -> Result<(), zx_status::Status> {
427        use fidl::Peered;
428        self.inner.channel().signal_peer(clear_mask, set_mask)
429    }
430}
431
432impl WlantapCtlControlHandle {}
433
434#[must_use = "FIDL methods require a response to be sent"]
435#[derive(Debug)]
436pub struct WlantapCtlCreatePhyResponder {
437    control_handle: std::mem::ManuallyDrop<WlantapCtlControlHandle>,
438    tx_id: u32,
439}
440
441/// Set the the channel to be shutdown (see [`WlantapCtlControlHandle::shutdown`])
442/// if the responder is dropped without sending a response, so that the client
443/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
444impl std::ops::Drop for WlantapCtlCreatePhyResponder {
445    fn drop(&mut self) {
446        self.control_handle.shutdown();
447        // Safety: drops once, never accessed again
448        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
449    }
450}
451
452impl fidl::endpoints::Responder for WlantapCtlCreatePhyResponder {
453    type ControlHandle = WlantapCtlControlHandle;
454
455    fn control_handle(&self) -> &WlantapCtlControlHandle {
456        &self.control_handle
457    }
458
459    fn drop_without_shutdown(mut self) {
460        // Safety: drops once, never accessed again due to mem::forget
461        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
462        // Prevent Drop from running (which would shut down the channel)
463        std::mem::forget(self);
464    }
465}
466
467impl WlantapCtlCreatePhyResponder {
468    /// Sends a response to the FIDL transaction.
469    ///
470    /// Sets the channel to shutdown if an error occurs.
471    pub fn send(self, mut status: i32) -> Result<(), fidl::Error> {
472        let _result = self.send_raw(status);
473        if _result.is_err() {
474            self.control_handle.shutdown();
475        }
476        self.drop_without_shutdown();
477        _result
478    }
479
480    /// Similar to "send" but does not shutdown the channel if an error occurs.
481    pub fn send_no_shutdown_on_err(self, mut status: i32) -> Result<(), fidl::Error> {
482        let _result = self.send_raw(status);
483        self.drop_without_shutdown();
484        _result
485    }
486
487    fn send_raw(&self, mut status: i32) -> Result<(), fidl::Error> {
488        self.control_handle.inner.send::<WlantapCtlCreatePhyResponse>(
489            (status,),
490            self.tx_id,
491            0x50273d8f10ceb35d,
492            fidl::encoding::DynamicFlags::empty(),
493        )
494    }
495}
496
497#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
498pub struct WlantapPhyMarker;
499
500impl fidl::endpoints::ProtocolMarker for WlantapPhyMarker {
501    type Proxy = WlantapPhyProxy;
502    type RequestStream = WlantapPhyRequestStream;
503    #[cfg(target_os = "fuchsia")]
504    type SynchronousProxy = WlantapPhySynchronousProxy;
505
506    const DEBUG_NAME: &'static str = "(anonymous) WlantapPhy";
507}
508
509pub trait WlantapPhyProxyInterface: Send + Sync {
510    type ShutdownResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
511    fn r#shutdown(&self) -> Self::ShutdownResponseFut;
512    fn r#rx(&self, data: &[u8], info: &WlanRxInfo) -> Result<(), fidl::Error>;
513    fn r#report_tx_result(
514        &self,
515        txr: &fidl_fuchsia_wlan_softmac::WlanTxResult,
516    ) -> Result<(), fidl::Error>;
517    fn r#scan_complete(&self, scan_id: u64, status: i32) -> Result<(), fidl::Error>;
518}
519#[derive(Debug)]
520#[cfg(target_os = "fuchsia")]
521pub struct WlantapPhySynchronousProxy {
522    client: fidl::client::sync::Client,
523}
524
525#[cfg(target_os = "fuchsia")]
526impl fidl::endpoints::SynchronousProxy for WlantapPhySynchronousProxy {
527    type Proxy = WlantapPhyProxy;
528    type Protocol = WlantapPhyMarker;
529
530    fn from_channel(inner: fidl::Channel) -> Self {
531        Self::new(inner)
532    }
533
534    fn into_channel(self) -> fidl::Channel {
535        self.client.into_channel()
536    }
537
538    fn as_channel(&self) -> &fidl::Channel {
539        self.client.as_channel()
540    }
541}
542
543#[cfg(target_os = "fuchsia")]
544impl WlantapPhySynchronousProxy {
545    pub fn new(channel: fidl::Channel) -> Self {
546        Self { client: fidl::client::sync::Client::new(channel) }
547    }
548
549    pub fn into_channel(self) -> fidl::Channel {
550        self.client.into_channel()
551    }
552
553    /// Waits until an event arrives and returns it. It is safe for other
554    /// threads to make concurrent requests while waiting for an event.
555    pub fn wait_for_event(
556        &self,
557        deadline: zx::MonotonicInstant,
558    ) -> Result<WlantapPhyEvent, fidl::Error> {
559        WlantapPhyEvent::decode(self.client.wait_for_event::<WlantapPhyMarker>(deadline)?)
560    }
561
562    /// Shutdown the phy device so that it does not respond to any further calls.
563    /// Once shutdown, there is no way to restart the device.
564    /// It can only be called at the end of a test.
565    pub fn r#shutdown(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
566        let _response = self.client.send_query::<
567            fidl::encoding::EmptyPayload,
568            fidl::encoding::EmptyPayload,
569            WlantapPhyMarker,
570        >(
571            (),
572            0x1df8087c49fa9a5e,
573            fidl::encoding::DynamicFlags::empty(),
574            ___deadline,
575        )?;
576        Ok(_response)
577    }
578
579    /// The device "receives" a frame "over the air" and pass it up to driver.
580    pub fn r#rx(&self, mut data: &[u8], mut info: &WlanRxInfo) -> Result<(), fidl::Error> {
581        self.client.send::<WlantapPhyRxRequest>(
582            (data, info),
583            0x165a656419ab3b41,
584            fidl::encoding::DynamicFlags::empty(),
585        )
586    }
587
588    /// For rate selection (Minstrel), the device's last frame transmission is a success/failure,
589    /// with a certain number of retries.
590    pub fn r#report_tx_result(
591        &self,
592        mut txr: &fidl_fuchsia_wlan_softmac::WlanTxResult,
593    ) -> Result<(), fidl::Error> {
594        self.client.send::<WlantapPhyReportTxResultRequest>(
595            (txr,),
596            0x2c27ed678c1e7eb4,
597            fidl::encoding::DynamicFlags::empty(),
598        )
599    }
600
601    pub fn r#scan_complete(&self, mut scan_id: u64, mut status: i32) -> Result<(), fidl::Error> {
602        self.client.send::<WlantapPhyScanCompleteRequest>(
603            (scan_id, status),
604            0x61a579015cff7674,
605            fidl::encoding::DynamicFlags::empty(),
606        )
607    }
608}
609
610#[cfg(target_os = "fuchsia")]
611impl From<WlantapPhySynchronousProxy> for zx::NullableHandle {
612    fn from(value: WlantapPhySynchronousProxy) -> Self {
613        value.into_channel().into()
614    }
615}
616
617#[cfg(target_os = "fuchsia")]
618impl From<fidl::Channel> for WlantapPhySynchronousProxy {
619    fn from(value: fidl::Channel) -> Self {
620        Self::new(value)
621    }
622}
623
624#[cfg(target_os = "fuchsia")]
625impl fidl::endpoints::FromClient for WlantapPhySynchronousProxy {
626    type Protocol = WlantapPhyMarker;
627
628    fn from_client(value: fidl::endpoints::ClientEnd<WlantapPhyMarker>) -> Self {
629        Self::new(value.into_channel())
630    }
631}
632
633#[derive(Debug, Clone)]
634pub struct WlantapPhyProxy {
635    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
636}
637
638impl fidl::endpoints::Proxy for WlantapPhyProxy {
639    type Protocol = WlantapPhyMarker;
640
641    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
642        Self::new(inner)
643    }
644
645    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
646        self.client.into_channel().map_err(|client| Self { client })
647    }
648
649    fn as_channel(&self) -> &::fidl::AsyncChannel {
650        self.client.as_channel()
651    }
652}
653
654impl WlantapPhyProxy {
655    /// Create a new Proxy for fuchsia.wlan.tap/WlantapPhy.
656    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
657        let protocol_name = <WlantapPhyMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
658        Self { client: fidl::client::Client::new(channel, protocol_name) }
659    }
660
661    /// Get a Stream of events from the remote end of the protocol.
662    ///
663    /// # Panics
664    ///
665    /// Panics if the event stream was already taken.
666    pub fn take_event_stream(&self) -> WlantapPhyEventStream {
667        WlantapPhyEventStream { event_receiver: self.client.take_event_receiver() }
668    }
669
670    /// Shutdown the phy device so that it does not respond to any further calls.
671    /// Once shutdown, there is no way to restart the device.
672    /// It can only be called at the end of a test.
673    pub fn r#shutdown(
674        &self,
675    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
676        WlantapPhyProxyInterface::r#shutdown(self)
677    }
678
679    /// The device "receives" a frame "over the air" and pass it up to driver.
680    pub fn r#rx(&self, mut data: &[u8], mut info: &WlanRxInfo) -> Result<(), fidl::Error> {
681        WlantapPhyProxyInterface::r#rx(self, data, info)
682    }
683
684    /// For rate selection (Minstrel), the device's last frame transmission is a success/failure,
685    /// with a certain number of retries.
686    pub fn r#report_tx_result(
687        &self,
688        mut txr: &fidl_fuchsia_wlan_softmac::WlanTxResult,
689    ) -> Result<(), fidl::Error> {
690        WlantapPhyProxyInterface::r#report_tx_result(self, txr)
691    }
692
693    pub fn r#scan_complete(&self, mut scan_id: u64, mut status: i32) -> Result<(), fidl::Error> {
694        WlantapPhyProxyInterface::r#scan_complete(self, scan_id, status)
695    }
696}
697
698impl WlantapPhyProxyInterface for WlantapPhyProxy {
699    type ShutdownResponseFut =
700        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
701    fn r#shutdown(&self) -> Self::ShutdownResponseFut {
702        fn _decode(
703            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
704        ) -> Result<(), fidl::Error> {
705            let _response = fidl::client::decode_transaction_body::<
706                fidl::encoding::EmptyPayload,
707                fidl::encoding::DefaultFuchsiaResourceDialect,
708                0x1df8087c49fa9a5e,
709            >(_buf?)?;
710            Ok(_response)
711        }
712        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
713            (),
714            0x1df8087c49fa9a5e,
715            fidl::encoding::DynamicFlags::empty(),
716            _decode,
717        )
718    }
719
720    fn r#rx(&self, mut data: &[u8], mut info: &WlanRxInfo) -> Result<(), fidl::Error> {
721        self.client.send::<WlantapPhyRxRequest>(
722            (data, info),
723            0x165a656419ab3b41,
724            fidl::encoding::DynamicFlags::empty(),
725        )
726    }
727
728    fn r#report_tx_result(
729        &self,
730        mut txr: &fidl_fuchsia_wlan_softmac::WlanTxResult,
731    ) -> Result<(), fidl::Error> {
732        self.client.send::<WlantapPhyReportTxResultRequest>(
733            (txr,),
734            0x2c27ed678c1e7eb4,
735            fidl::encoding::DynamicFlags::empty(),
736        )
737    }
738
739    fn r#scan_complete(&self, mut scan_id: u64, mut status: i32) -> Result<(), fidl::Error> {
740        self.client.send::<WlantapPhyScanCompleteRequest>(
741            (scan_id, status),
742            0x61a579015cff7674,
743            fidl::encoding::DynamicFlags::empty(),
744        )
745    }
746}
747
748pub struct WlantapPhyEventStream {
749    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
750}
751
752impl std::marker::Unpin for WlantapPhyEventStream {}
753
754impl futures::stream::FusedStream for WlantapPhyEventStream {
755    fn is_terminated(&self) -> bool {
756        self.event_receiver.is_terminated()
757    }
758}
759
760impl futures::Stream for WlantapPhyEventStream {
761    type Item = Result<WlantapPhyEvent, fidl::Error>;
762
763    fn poll_next(
764        mut self: std::pin::Pin<&mut Self>,
765        cx: &mut std::task::Context<'_>,
766    ) -> std::task::Poll<Option<Self::Item>> {
767        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
768            &mut self.event_receiver,
769            cx
770        )?) {
771            Some(buf) => std::task::Poll::Ready(Some(WlantapPhyEvent::decode(buf))),
772            None => std::task::Poll::Ready(None),
773        }
774    }
775}
776
777#[derive(Debug)]
778pub enum WlantapPhyEvent {
779    Tx { args: TxArgs },
780    WlanSoftmacStart {},
781    SetChannel { args: SetChannelArgs },
782    JoinBss { args: JoinBssArgs },
783    StartScan { args: StartScanArgs },
784    SetKey { args: SetKeyArgs },
785    SetCountry { args: SetCountryArgs },
786}
787
788impl WlantapPhyEvent {
789    #[allow(irrefutable_let_patterns)]
790    pub fn into_tx(self) -> Option<TxArgs> {
791        if let WlantapPhyEvent::Tx { args } = self { Some((args)) } else { None }
792    }
793    #[allow(irrefutable_let_patterns)]
794    pub fn into_wlan_softmac_start(self) -> Option<()> {
795        if let WlantapPhyEvent::WlanSoftmacStart {} = self { Some(()) } else { None }
796    }
797    #[allow(irrefutable_let_patterns)]
798    pub fn into_set_channel(self) -> Option<SetChannelArgs> {
799        if let WlantapPhyEvent::SetChannel { args } = self { Some((args)) } else { None }
800    }
801    #[allow(irrefutable_let_patterns)]
802    pub fn into_join_bss(self) -> Option<JoinBssArgs> {
803        if let WlantapPhyEvent::JoinBss { args } = self { Some((args)) } else { None }
804    }
805    #[allow(irrefutable_let_patterns)]
806    pub fn into_start_scan(self) -> Option<StartScanArgs> {
807        if let WlantapPhyEvent::StartScan { args } = self { Some((args)) } else { None }
808    }
809    #[allow(irrefutable_let_patterns)]
810    pub fn into_set_key(self) -> Option<SetKeyArgs> {
811        if let WlantapPhyEvent::SetKey { args } = self { Some((args)) } else { None }
812    }
813    #[allow(irrefutable_let_patterns)]
814    pub fn into_set_country(self) -> Option<SetCountryArgs> {
815        if let WlantapPhyEvent::SetCountry { args } = self { Some((args)) } else { None }
816    }
817
818    /// Decodes a message buffer as a [`WlantapPhyEvent`].
819    fn decode(
820        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
821    ) -> Result<WlantapPhyEvent, fidl::Error> {
822        let (bytes, _handles) = buf.split_mut();
823        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
824        debug_assert_eq!(tx_header.tx_id, 0);
825        match tx_header.ordinal {
826            0x3ccc6c207280b569 => {
827                let mut out = fidl::new_empty!(
828                    WlantapPhyTxRequest,
829                    fidl::encoding::DefaultFuchsiaResourceDialect
830                );
831                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<WlantapPhyTxRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
832                Ok((WlantapPhyEvent::Tx { args: out.args }))
833            }
834            0x328bcae20dec2b88 => {
835                let mut out = fidl::new_empty!(
836                    fidl::encoding::EmptyPayload,
837                    fidl::encoding::DefaultFuchsiaResourceDialect
838                );
839                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
840                Ok((WlantapPhyEvent::WlanSoftmacStart {}))
841            }
842            0x60eb9a607f96a948 => {
843                let mut out = fidl::new_empty!(
844                    WlantapPhySetChannelRequest,
845                    fidl::encoding::DefaultFuchsiaResourceDialect
846                );
847                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<WlantapPhySetChannelRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
848                Ok((WlantapPhyEvent::SetChannel { args: out.args }))
849            }
850            0xef930e871dbf2f9 => {
851                let mut out = fidl::new_empty!(
852                    WlantapPhyJoinBssRequest,
853                    fidl::encoding::DefaultFuchsiaResourceDialect
854                );
855                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<WlantapPhyJoinBssRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
856                Ok((WlantapPhyEvent::JoinBss { args: out.args }))
857            }
858            0x75ed87321e05cdbb => {
859                let mut out = fidl::new_empty!(
860                    WlantapPhyStartScanRequest,
861                    fidl::encoding::DefaultFuchsiaResourceDialect
862                );
863                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<WlantapPhyStartScanRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
864                Ok((WlantapPhyEvent::StartScan { args: out.args }))
865            }
866            0xff7bf591b026267 => {
867                let mut out = fidl::new_empty!(
868                    WlantapPhySetKeyRequest,
869                    fidl::encoding::DefaultFuchsiaResourceDialect
870                );
871                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<WlantapPhySetKeyRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
872                Ok((WlantapPhyEvent::SetKey { args: out.args }))
873            }
874            0x4cd2f84e3ccfcd14 => {
875                let mut out = fidl::new_empty!(
876                    WlantapPhySetCountryRequest,
877                    fidl::encoding::DefaultFuchsiaResourceDialect
878                );
879                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<WlantapPhySetCountryRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
880                Ok((WlantapPhyEvent::SetCountry { args: out.args }))
881            }
882            _ => Err(fidl::Error::UnknownOrdinal {
883                ordinal: tx_header.ordinal,
884                protocol_name: <WlantapPhyMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
885            }),
886        }
887    }
888}
889
890/// A Stream of incoming requests for fuchsia.wlan.tap/WlantapPhy.
891pub struct WlantapPhyRequestStream {
892    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
893    is_terminated: bool,
894}
895
896impl std::marker::Unpin for WlantapPhyRequestStream {}
897
898impl futures::stream::FusedStream for WlantapPhyRequestStream {
899    fn is_terminated(&self) -> bool {
900        self.is_terminated
901    }
902}
903
904impl fidl::endpoints::RequestStream for WlantapPhyRequestStream {
905    type Protocol = WlantapPhyMarker;
906    type ControlHandle = WlantapPhyControlHandle;
907
908    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
909        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
910    }
911
912    fn control_handle(&self) -> Self::ControlHandle {
913        WlantapPhyControlHandle { inner: self.inner.clone() }
914    }
915
916    fn into_inner(
917        self,
918    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
919    {
920        (self.inner, self.is_terminated)
921    }
922
923    fn from_inner(
924        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
925        is_terminated: bool,
926    ) -> Self {
927        Self { inner, is_terminated }
928    }
929}
930
931impl futures::Stream for WlantapPhyRequestStream {
932    type Item = Result<WlantapPhyRequest, fidl::Error>;
933
934    fn poll_next(
935        mut self: std::pin::Pin<&mut Self>,
936        cx: &mut std::task::Context<'_>,
937    ) -> std::task::Poll<Option<Self::Item>> {
938        let this = &mut *self;
939        if this.inner.check_shutdown(cx) {
940            this.is_terminated = true;
941            return std::task::Poll::Ready(None);
942        }
943        if this.is_terminated {
944            panic!("polled WlantapPhyRequestStream after completion");
945        }
946        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
947            |bytes, handles| {
948                match this.inner.channel().read_etc(cx, bytes, handles) {
949                    std::task::Poll::Ready(Ok(())) => {}
950                    std::task::Poll::Pending => return std::task::Poll::Pending,
951                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
952                        this.is_terminated = true;
953                        return std::task::Poll::Ready(None);
954                    }
955                    std::task::Poll::Ready(Err(e)) => {
956                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
957                            e.into(),
958                        ))));
959                    }
960                }
961
962                // A message has been received from the channel
963                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
964
965                std::task::Poll::Ready(Some(match header.ordinal {
966                    0x1df8087c49fa9a5e => {
967                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
968                        let mut req = fidl::new_empty!(
969                            fidl::encoding::EmptyPayload,
970                            fidl::encoding::DefaultFuchsiaResourceDialect
971                        );
972                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
973                        let control_handle = WlantapPhyControlHandle { inner: this.inner.clone() };
974                        Ok(WlantapPhyRequest::Shutdown {
975                            responder: WlantapPhyShutdownResponder {
976                                control_handle: std::mem::ManuallyDrop::new(control_handle),
977                                tx_id: header.tx_id,
978                            },
979                        })
980                    }
981                    0x165a656419ab3b41 => {
982                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
983                        let mut req = fidl::new_empty!(
984                            WlantapPhyRxRequest,
985                            fidl::encoding::DefaultFuchsiaResourceDialect
986                        );
987                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<WlantapPhyRxRequest>(&header, _body_bytes, handles, &mut req)?;
988                        let control_handle = WlantapPhyControlHandle { inner: this.inner.clone() };
989                        Ok(WlantapPhyRequest::Rx { data: req.data, info: req.info, control_handle })
990                    }
991                    0x2c27ed678c1e7eb4 => {
992                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
993                        let mut req = fidl::new_empty!(
994                            WlantapPhyReportTxResultRequest,
995                            fidl::encoding::DefaultFuchsiaResourceDialect
996                        );
997                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<WlantapPhyReportTxResultRequest>(&header, _body_bytes, handles, &mut req)?;
998                        let control_handle = WlantapPhyControlHandle { inner: this.inner.clone() };
999                        Ok(WlantapPhyRequest::ReportTxResult { txr: req.txr, control_handle })
1000                    }
1001                    0x61a579015cff7674 => {
1002                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1003                        let mut req = fidl::new_empty!(
1004                            WlantapPhyScanCompleteRequest,
1005                            fidl::encoding::DefaultFuchsiaResourceDialect
1006                        );
1007                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<WlantapPhyScanCompleteRequest>(&header, _body_bytes, handles, &mut req)?;
1008                        let control_handle = WlantapPhyControlHandle { inner: this.inner.clone() };
1009                        Ok(WlantapPhyRequest::ScanComplete {
1010                            scan_id: req.scan_id,
1011                            status: req.status,
1012
1013                            control_handle,
1014                        })
1015                    }
1016                    _ => Err(fidl::Error::UnknownOrdinal {
1017                        ordinal: header.ordinal,
1018                        protocol_name:
1019                            <WlantapPhyMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1020                    }),
1021                }))
1022            },
1023        )
1024    }
1025}
1026
1027/// Allow the test program to observe and control the behavior of the wlantap-phy device.
1028/// A wlantap-phy device is a special vendor device and its driver (Fuchsia being the vendor)
1029/// used for testing purpose.
1030/// Implements a subset of `wlan_softmac_ifc_t` and `wlan_softmac_protocol_ops_t` defined in
1031/// fuchsia.wlan.softmac/softmac.fidl
1032/// Implements a subset of `WlanPhyImpl` protocol defined in
1033/// fuchsia.hardware.phyimpl/wlanphy-impl.fidl
1034#[derive(Debug)]
1035pub enum WlantapPhyRequest {
1036    /// Shutdown the phy device so that it does not respond to any further calls.
1037    /// Once shutdown, there is no way to restart the device.
1038    /// It can only be called at the end of a test.
1039    Shutdown {
1040        responder: WlantapPhyShutdownResponder,
1041    },
1042    /// The device "receives" a frame "over the air" and pass it up to driver.
1043    Rx {
1044        data: Vec<u8>,
1045        info: WlanRxInfo,
1046        control_handle: WlantapPhyControlHandle,
1047    },
1048    /// For rate selection (Minstrel), the device's last frame transmission is a success/failure,
1049    /// with a certain number of retries.
1050    ReportTxResult {
1051        txr: fidl_fuchsia_wlan_softmac::WlanTxResult,
1052        control_handle: WlantapPhyControlHandle,
1053    },
1054    ScanComplete {
1055        scan_id: u64,
1056        status: i32,
1057        control_handle: WlantapPhyControlHandle,
1058    },
1059}
1060
1061impl WlantapPhyRequest {
1062    #[allow(irrefutable_let_patterns)]
1063    pub fn into_shutdown(self) -> Option<(WlantapPhyShutdownResponder)> {
1064        if let WlantapPhyRequest::Shutdown { responder } = self { Some((responder)) } else { None }
1065    }
1066
1067    #[allow(irrefutable_let_patterns)]
1068    pub fn into_rx(self) -> Option<(Vec<u8>, WlanRxInfo, WlantapPhyControlHandle)> {
1069        if let WlantapPhyRequest::Rx { data, info, control_handle } = self {
1070            Some((data, info, control_handle))
1071        } else {
1072            None
1073        }
1074    }
1075
1076    #[allow(irrefutable_let_patterns)]
1077    pub fn into_report_tx_result(
1078        self,
1079    ) -> Option<(fidl_fuchsia_wlan_softmac::WlanTxResult, WlantapPhyControlHandle)> {
1080        if let WlantapPhyRequest::ReportTxResult { txr, control_handle } = self {
1081            Some((txr, control_handle))
1082        } else {
1083            None
1084        }
1085    }
1086
1087    #[allow(irrefutable_let_patterns)]
1088    pub fn into_scan_complete(self) -> Option<(u64, i32, WlantapPhyControlHandle)> {
1089        if let WlantapPhyRequest::ScanComplete { scan_id, status, control_handle } = self {
1090            Some((scan_id, status, control_handle))
1091        } else {
1092            None
1093        }
1094    }
1095
1096    /// Name of the method defined in FIDL
1097    pub fn method_name(&self) -> &'static str {
1098        match *self {
1099            WlantapPhyRequest::Shutdown { .. } => "shutdown",
1100            WlantapPhyRequest::Rx { .. } => "rx",
1101            WlantapPhyRequest::ReportTxResult { .. } => "report_tx_result",
1102            WlantapPhyRequest::ScanComplete { .. } => "scan_complete",
1103        }
1104    }
1105}
1106
1107#[derive(Debug, Clone)]
1108pub struct WlantapPhyControlHandle {
1109    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1110}
1111
1112impl WlantapPhyControlHandle {
1113    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1114        self.inner.shutdown_with_epitaph(status.into())
1115    }
1116}
1117
1118impl fidl::endpoints::ControlHandle for WlantapPhyControlHandle {
1119    fn shutdown(&self) {
1120        self.inner.shutdown()
1121    }
1122
1123    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1124        self.inner.shutdown_with_epitaph(status)
1125    }
1126
1127    fn is_closed(&self) -> bool {
1128        self.inner.channel().is_closed()
1129    }
1130    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1131        self.inner.channel().on_closed()
1132    }
1133
1134    #[cfg(target_os = "fuchsia")]
1135    fn signal_peer(
1136        &self,
1137        clear_mask: zx::Signals,
1138        set_mask: zx::Signals,
1139    ) -> Result<(), zx_status::Status> {
1140        use fidl::Peered;
1141        self.inner.channel().signal_peer(clear_mask, set_mask)
1142    }
1143}
1144
1145impl WlantapPhyControlHandle {
1146    pub fn send_tx(&self, mut args: &TxArgs) -> Result<(), fidl::Error> {
1147        self.inner.send::<WlantapPhyTxRequest>(
1148            (args,),
1149            0,
1150            0x3ccc6c207280b569,
1151            fidl::encoding::DynamicFlags::empty(),
1152        )
1153    }
1154
1155    pub fn send_wlan_softmac_start(&self) -> Result<(), fidl::Error> {
1156        self.inner.send::<fidl::encoding::EmptyPayload>(
1157            (),
1158            0,
1159            0x328bcae20dec2b88,
1160            fidl::encoding::DynamicFlags::empty(),
1161        )
1162    }
1163
1164    pub fn send_set_channel(&self, mut args: &SetChannelArgs) -> Result<(), fidl::Error> {
1165        self.inner.send::<WlantapPhySetChannelRequest>(
1166            (args,),
1167            0,
1168            0x60eb9a607f96a948,
1169            fidl::encoding::DynamicFlags::empty(),
1170        )
1171    }
1172
1173    pub fn send_join_bss(&self, mut args: &JoinBssArgs) -> Result<(), fidl::Error> {
1174        self.inner.send::<WlantapPhyJoinBssRequest>(
1175            (args,),
1176            0,
1177            0xef930e871dbf2f9,
1178            fidl::encoding::DynamicFlags::empty(),
1179        )
1180    }
1181
1182    pub fn send_start_scan(&self, mut args: &StartScanArgs) -> Result<(), fidl::Error> {
1183        self.inner.send::<WlantapPhyStartScanRequest>(
1184            (args,),
1185            0,
1186            0x75ed87321e05cdbb,
1187            fidl::encoding::DynamicFlags::empty(),
1188        )
1189    }
1190
1191    pub fn send_set_key(&self, mut args: &SetKeyArgs) -> Result<(), fidl::Error> {
1192        self.inner.send::<WlantapPhySetKeyRequest>(
1193            (args,),
1194            0,
1195            0xff7bf591b026267,
1196            fidl::encoding::DynamicFlags::empty(),
1197        )
1198    }
1199
1200    pub fn send_set_country(&self, mut args: &SetCountryArgs) -> Result<(), fidl::Error> {
1201        self.inner.send::<WlantapPhySetCountryRequest>(
1202            (args,),
1203            0,
1204            0x4cd2f84e3ccfcd14,
1205            fidl::encoding::DynamicFlags::empty(),
1206        )
1207    }
1208}
1209
1210#[must_use = "FIDL methods require a response to be sent"]
1211#[derive(Debug)]
1212pub struct WlantapPhyShutdownResponder {
1213    control_handle: std::mem::ManuallyDrop<WlantapPhyControlHandle>,
1214    tx_id: u32,
1215}
1216
1217/// Set the the channel to be shutdown (see [`WlantapPhyControlHandle::shutdown`])
1218/// if the responder is dropped without sending a response, so that the client
1219/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1220impl std::ops::Drop for WlantapPhyShutdownResponder {
1221    fn drop(&mut self) {
1222        self.control_handle.shutdown();
1223        // Safety: drops once, never accessed again
1224        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1225    }
1226}
1227
1228impl fidl::endpoints::Responder for WlantapPhyShutdownResponder {
1229    type ControlHandle = WlantapPhyControlHandle;
1230
1231    fn control_handle(&self) -> &WlantapPhyControlHandle {
1232        &self.control_handle
1233    }
1234
1235    fn drop_without_shutdown(mut self) {
1236        // Safety: drops once, never accessed again due to mem::forget
1237        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1238        // Prevent Drop from running (which would shut down the channel)
1239        std::mem::forget(self);
1240    }
1241}
1242
1243impl WlantapPhyShutdownResponder {
1244    /// Sends a response to the FIDL transaction.
1245    ///
1246    /// Sets the channel to shutdown if an error occurs.
1247    pub fn send(self) -> Result<(), fidl::Error> {
1248        let _result = self.send_raw();
1249        if _result.is_err() {
1250            self.control_handle.shutdown();
1251        }
1252        self.drop_without_shutdown();
1253        _result
1254    }
1255
1256    /// Similar to "send" but does not shutdown the channel if an error occurs.
1257    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1258        let _result = self.send_raw();
1259        self.drop_without_shutdown();
1260        _result
1261    }
1262
1263    fn send_raw(&self) -> Result<(), fidl::Error> {
1264        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1265            (),
1266            self.tx_id,
1267            0x1df8087c49fa9a5e,
1268            fidl::encoding::DynamicFlags::empty(),
1269        )
1270    }
1271}
1272
1273#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1274pub struct ServiceMarker;
1275
1276#[cfg(target_os = "fuchsia")]
1277impl fidl::endpoints::ServiceMarker for ServiceMarker {
1278    type Proxy = ServiceProxy;
1279    type Request = ServiceRequest;
1280    const SERVICE_NAME: &'static str = "fuchsia.wlan.tap.Service";
1281}
1282
1283/// A request for one of the member protocols of Service.
1284///
1285#[cfg(target_os = "fuchsia")]
1286pub enum ServiceRequest {
1287    WlantapCtl(WlantapCtlRequestStream),
1288}
1289
1290#[cfg(target_os = "fuchsia")]
1291impl fidl::endpoints::ServiceRequest for ServiceRequest {
1292    type Service = ServiceMarker;
1293
1294    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
1295        match name {
1296            "wlantap_ctl" => Self::WlantapCtl(
1297                <WlantapCtlRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
1298            ),
1299            _ => panic!("no such member protocol name for service Service"),
1300        }
1301    }
1302
1303    fn member_names() -> &'static [&'static str] {
1304        &["wlantap_ctl"]
1305    }
1306}
1307#[cfg(target_os = "fuchsia")]
1308pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
1309
1310#[cfg(target_os = "fuchsia")]
1311impl fidl::endpoints::ServiceProxy for ServiceProxy {
1312    type Service = ServiceMarker;
1313
1314    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
1315        Self(opener)
1316    }
1317}
1318
1319#[cfg(target_os = "fuchsia")]
1320impl ServiceProxy {
1321    pub fn connect_to_wlantap_ctl(&self) -> Result<WlantapCtlProxy, fidl::Error> {
1322        let (proxy, server_end) = fidl::endpoints::create_proxy::<WlantapCtlMarker>();
1323        self.connect_channel_to_wlantap_ctl(server_end)?;
1324        Ok(proxy)
1325    }
1326
1327    /// Like `connect_to_wlantap_ctl`, but returns a sync proxy.
1328    /// See [`Self::connect_to_wlantap_ctl`] for more details.
1329    pub fn connect_to_wlantap_ctl_sync(&self) -> Result<WlantapCtlSynchronousProxy, fidl::Error> {
1330        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<WlantapCtlMarker>();
1331        self.connect_channel_to_wlantap_ctl(server_end)?;
1332        Ok(proxy)
1333    }
1334
1335    /// Like `connect_to_wlantap_ctl`, but accepts a server end.
1336    /// See [`Self::connect_to_wlantap_ctl`] for more details.
1337    pub fn connect_channel_to_wlantap_ctl(
1338        &self,
1339        server_end: fidl::endpoints::ServerEnd<WlantapCtlMarker>,
1340    ) -> Result<(), fidl::Error> {
1341        self.0.open_member("wlantap_ctl", server_end.into_channel())
1342    }
1343
1344    pub fn instance_name(&self) -> &str {
1345        self.0.instance_name()
1346    }
1347}
1348
1349mod internal {
1350    use super::*;
1351
1352    impl fidl::encoding::ResourceTypeMarker for WlantapCtlCreatePhyRequest {
1353        type Borrowed<'a> = &'a mut Self;
1354        fn take_or_borrow<'a>(
1355            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1356        ) -> Self::Borrowed<'a> {
1357            value
1358        }
1359    }
1360
1361    unsafe impl fidl::encoding::TypeMarker for WlantapCtlCreatePhyRequest {
1362        type Owned = Self;
1363
1364        #[inline(always)]
1365        fn inline_align(_context: fidl::encoding::Context) -> usize {
1366            8
1367        }
1368
1369        #[inline(always)]
1370        fn inline_size(_context: fidl::encoding::Context) -> usize {
1371            152
1372        }
1373    }
1374
1375    unsafe impl
1376        fidl::encoding::Encode<
1377            WlantapCtlCreatePhyRequest,
1378            fidl::encoding::DefaultFuchsiaResourceDialect,
1379        > for &mut WlantapCtlCreatePhyRequest
1380    {
1381        #[inline]
1382        unsafe fn encode(
1383            self,
1384            encoder: &mut fidl::encoding::Encoder<
1385                '_,
1386                fidl::encoding::DefaultFuchsiaResourceDialect,
1387            >,
1388            offset: usize,
1389            _depth: fidl::encoding::Depth,
1390        ) -> fidl::Result<()> {
1391            encoder.debug_check_bounds::<WlantapCtlCreatePhyRequest>(offset);
1392            // Delegate to tuple encoding.
1393            fidl::encoding::Encode::<WlantapCtlCreatePhyRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1394                (
1395                    <WlantapPhyConfig as fidl::encoding::ValueTypeMarker>::borrow(&self.config),
1396                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<WlantapPhyMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.proxy),
1397                ),
1398                encoder, offset, _depth
1399            )
1400        }
1401    }
1402    unsafe impl<
1403        T0: fidl::encoding::Encode<WlantapPhyConfig, fidl::encoding::DefaultFuchsiaResourceDialect>,
1404        T1: fidl::encoding::Encode<
1405                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<WlantapPhyMarker>>,
1406                fidl::encoding::DefaultFuchsiaResourceDialect,
1407            >,
1408    >
1409        fidl::encoding::Encode<
1410            WlantapCtlCreatePhyRequest,
1411            fidl::encoding::DefaultFuchsiaResourceDialect,
1412        > for (T0, T1)
1413    {
1414        #[inline]
1415        unsafe fn encode(
1416            self,
1417            encoder: &mut fidl::encoding::Encoder<
1418                '_,
1419                fidl::encoding::DefaultFuchsiaResourceDialect,
1420            >,
1421            offset: usize,
1422            depth: fidl::encoding::Depth,
1423        ) -> fidl::Result<()> {
1424            encoder.debug_check_bounds::<WlantapCtlCreatePhyRequest>(offset);
1425            // Zero out padding regions. There's no need to apply masks
1426            // because the unmasked parts will be overwritten by fields.
1427            unsafe {
1428                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(144);
1429                (ptr as *mut u64).write_unaligned(0);
1430            }
1431            // Write the fields.
1432            self.0.encode(encoder, offset + 0, depth)?;
1433            self.1.encode(encoder, offset + 144, depth)?;
1434            Ok(())
1435        }
1436    }
1437
1438    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1439        for WlantapCtlCreatePhyRequest
1440    {
1441        #[inline(always)]
1442        fn new_empty() -> Self {
1443            Self {
1444                config: fidl::new_empty!(
1445                    WlantapPhyConfig,
1446                    fidl::encoding::DefaultFuchsiaResourceDialect
1447                ),
1448                proxy: fidl::new_empty!(
1449                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<WlantapPhyMarker>>,
1450                    fidl::encoding::DefaultFuchsiaResourceDialect
1451                ),
1452            }
1453        }
1454
1455        #[inline]
1456        unsafe fn decode(
1457            &mut self,
1458            decoder: &mut fidl::encoding::Decoder<
1459                '_,
1460                fidl::encoding::DefaultFuchsiaResourceDialect,
1461            >,
1462            offset: usize,
1463            _depth: fidl::encoding::Depth,
1464        ) -> fidl::Result<()> {
1465            decoder.debug_check_bounds::<Self>(offset);
1466            // Verify that padding bytes are zero.
1467            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(144) };
1468            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1469            let mask = 0xffffffff00000000u64;
1470            let maskedval = padval & mask;
1471            if maskedval != 0 {
1472                return Err(fidl::Error::NonZeroPadding {
1473                    padding_start: offset + 144 + ((mask as u64).trailing_zeros() / 8) as usize,
1474                });
1475            }
1476            fidl::decode!(
1477                WlantapPhyConfig,
1478                fidl::encoding::DefaultFuchsiaResourceDialect,
1479                &mut self.config,
1480                decoder,
1481                offset + 0,
1482                _depth
1483            )?;
1484            fidl::decode!(
1485                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<WlantapPhyMarker>>,
1486                fidl::encoding::DefaultFuchsiaResourceDialect,
1487                &mut self.proxy,
1488                decoder,
1489                offset + 144,
1490                _depth
1491            )?;
1492            Ok(())
1493        }
1494    }
1495}