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