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