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