Skip to main content

fidl_test_wlan_testcontroller/
fidl_test_wlan_testcontroller.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_test_wlan_testcontroller_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct TestControllerCreateFullmacRequest {
16    pub bridge_client:
17        fidl::endpoints::ClientEnd<fidl_fuchsia_wlan_fullmac::WlanFullmacImpl_Marker>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
21    for TestControllerCreateFullmacRequest
22{
23}
24
25#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
26#[repr(C)]
27pub struct TestControllerDeleteFullmacRequest {
28    pub id: u32,
29}
30
31impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
32    for TestControllerDeleteFullmacRequest
33{
34}
35
36#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
37#[repr(C)]
38pub struct TestControllerCreateFullmacResponse {
39    pub id: u32,
40}
41
42impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
43    for TestControllerCreateFullmacResponse
44{
45}
46
47#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
48pub struct TestControllerMarker;
49
50impl fidl::endpoints::ProtocolMarker for TestControllerMarker {
51    type Proxy = TestControllerProxy;
52    type RequestStream = TestControllerRequestStream;
53    #[cfg(target_os = "fuchsia")]
54    type SynchronousProxy = TestControllerSynchronousProxy;
55
56    const DEBUG_NAME: &'static str = "(anonymous) TestController";
57}
58pub type TestControllerCreateFullmacResult = Result<u32, i32>;
59pub type TestControllerDeleteFullmacResult = Result<(), i32>;
60
61pub trait TestControllerProxyInterface: Send + Sync {
62    type CreateFullmacResponseFut: std::future::Future<Output = Result<TestControllerCreateFullmacResult, fidl::Error>>
63        + Send;
64    fn r#create_fullmac(
65        &self,
66        bridge_client: fidl::endpoints::ClientEnd<
67            fidl_fuchsia_wlan_fullmac::WlanFullmacImpl_Marker,
68        >,
69    ) -> Self::CreateFullmacResponseFut;
70    type DeleteFullmacResponseFut: std::future::Future<Output = Result<TestControllerDeleteFullmacResult, fidl::Error>>
71        + Send;
72    fn r#delete_fullmac(&self, id: u32) -> Self::DeleteFullmacResponseFut;
73}
74#[derive(Debug)]
75#[cfg(target_os = "fuchsia")]
76pub struct TestControllerSynchronousProxy {
77    client: fidl::client::sync::Client,
78}
79
80#[cfg(target_os = "fuchsia")]
81impl fidl::endpoints::SynchronousProxy for TestControllerSynchronousProxy {
82    type Proxy = TestControllerProxy;
83    type Protocol = TestControllerMarker;
84
85    fn from_channel(inner: fidl::Channel) -> Self {
86        Self::new(inner)
87    }
88
89    fn into_channel(self) -> fidl::Channel {
90        self.client.into_channel()
91    }
92
93    fn as_channel(&self) -> &fidl::Channel {
94        self.client.as_channel()
95    }
96}
97
98#[cfg(target_os = "fuchsia")]
99impl TestControllerSynchronousProxy {
100    pub fn new(channel: fidl::Channel) -> Self {
101        Self { client: fidl::client::sync::Client::new(channel) }
102    }
103
104    pub fn into_channel(self) -> fidl::Channel {
105        self.client.into_channel()
106    }
107
108    /// Waits until an event arrives and returns it. It is safe for other
109    /// threads to make concurrent requests while waiting for an event.
110    pub fn wait_for_event(
111        &self,
112        deadline: zx::MonotonicInstant,
113    ) -> Result<TestControllerEvent, fidl::Error> {
114        TestControllerEvent::decode(self.client.wait_for_event::<TestControllerMarker>(deadline)?)
115    }
116
117    /// Create and bind Fullmac driver that forwards all incoming calls
118    /// to the |bridge_client|. The Fullmac driver will also create an instance
119    /// of SME on binding.
120    ///
121    /// The user should expect to receive a call to
122    /// WlanFullmacImpl::Start shortly after calling this.
123    ///
124    /// Returns an |id| that uniquely identifies the new instance of the Fullmac driver,
125    /// which can be used to delete the driver instance later.
126    pub fn r#create_fullmac(
127        &self,
128        mut bridge_client: fidl::endpoints::ClientEnd<
129            fidl_fuchsia_wlan_fullmac::WlanFullmacImpl_Marker,
130        >,
131        ___deadline: zx::MonotonicInstant,
132    ) -> Result<TestControllerCreateFullmacResult, fidl::Error> {
133        let _response = self.client.send_query::<
134            TestControllerCreateFullmacRequest,
135            fidl::encoding::ResultType<TestControllerCreateFullmacResponse, i32>,
136            TestControllerMarker,
137        >(
138            (bridge_client,),
139            0x1eaf55234a2c969d,
140            fidl::encoding::DynamicFlags::empty(),
141            ___deadline,
142        )?;
143        Ok(_response.map(|x| x.id))
144    }
145
146    /// Deletes the Fullmac driver with the given |id|.
147    pub fn r#delete_fullmac(
148        &self,
149        mut id: u32,
150        ___deadline: zx::MonotonicInstant,
151    ) -> Result<TestControllerDeleteFullmacResult, fidl::Error> {
152        let _response = self.client.send_query::<
153            TestControllerDeleteFullmacRequest,
154            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
155            TestControllerMarker,
156        >(
157            (id,),
158            0x153bf68847795c91,
159            fidl::encoding::DynamicFlags::empty(),
160            ___deadline,
161        )?;
162        Ok(_response.map(|x| x))
163    }
164}
165
166#[cfg(target_os = "fuchsia")]
167impl From<TestControllerSynchronousProxy> for zx::NullableHandle {
168    fn from(value: TestControllerSynchronousProxy) -> Self {
169        value.into_channel().into()
170    }
171}
172
173#[cfg(target_os = "fuchsia")]
174impl From<fidl::Channel> for TestControllerSynchronousProxy {
175    fn from(value: fidl::Channel) -> Self {
176        Self::new(value)
177    }
178}
179
180#[cfg(target_os = "fuchsia")]
181impl fidl::endpoints::FromClient for TestControllerSynchronousProxy {
182    type Protocol = TestControllerMarker;
183
184    fn from_client(value: fidl::endpoints::ClientEnd<TestControllerMarker>) -> Self {
185        Self::new(value.into_channel())
186    }
187}
188
189#[derive(Debug, Clone)]
190pub struct TestControllerProxy {
191    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
192}
193
194impl fidl::endpoints::Proxy for TestControllerProxy {
195    type Protocol = TestControllerMarker;
196
197    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
198        Self::new(inner)
199    }
200
201    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
202        self.client.into_channel().map_err(|client| Self { client })
203    }
204
205    fn as_channel(&self) -> &::fidl::AsyncChannel {
206        self.client.as_channel()
207    }
208}
209
210impl TestControllerProxy {
211    /// Create a new Proxy for test.wlan.testcontroller/TestController.
212    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
213        let protocol_name = <TestControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
214        Self { client: fidl::client::Client::new(channel, protocol_name) }
215    }
216
217    /// Get a Stream of events from the remote end of the protocol.
218    ///
219    /// # Panics
220    ///
221    /// Panics if the event stream was already taken.
222    pub fn take_event_stream(&self) -> TestControllerEventStream {
223        TestControllerEventStream { event_receiver: self.client.take_event_receiver() }
224    }
225
226    /// Create and bind Fullmac driver that forwards all incoming calls
227    /// to the |bridge_client|. The Fullmac driver will also create an instance
228    /// of SME on binding.
229    ///
230    /// The user should expect to receive a call to
231    /// WlanFullmacImpl::Start shortly after calling this.
232    ///
233    /// Returns an |id| that uniquely identifies the new instance of the Fullmac driver,
234    /// which can be used to delete the driver instance later.
235    pub fn r#create_fullmac(
236        &self,
237        mut bridge_client: fidl::endpoints::ClientEnd<
238            fidl_fuchsia_wlan_fullmac::WlanFullmacImpl_Marker,
239        >,
240    ) -> fidl::client::QueryResponseFut<
241        TestControllerCreateFullmacResult,
242        fidl::encoding::DefaultFuchsiaResourceDialect,
243    > {
244        TestControllerProxyInterface::r#create_fullmac(self, bridge_client)
245    }
246
247    /// Deletes the Fullmac driver with the given |id|.
248    pub fn r#delete_fullmac(
249        &self,
250        mut id: u32,
251    ) -> fidl::client::QueryResponseFut<
252        TestControllerDeleteFullmacResult,
253        fidl::encoding::DefaultFuchsiaResourceDialect,
254    > {
255        TestControllerProxyInterface::r#delete_fullmac(self, id)
256    }
257}
258
259impl TestControllerProxyInterface for TestControllerProxy {
260    type CreateFullmacResponseFut = fidl::client::QueryResponseFut<
261        TestControllerCreateFullmacResult,
262        fidl::encoding::DefaultFuchsiaResourceDialect,
263    >;
264    fn r#create_fullmac(
265        &self,
266        mut bridge_client: fidl::endpoints::ClientEnd<
267            fidl_fuchsia_wlan_fullmac::WlanFullmacImpl_Marker,
268        >,
269    ) -> Self::CreateFullmacResponseFut {
270        fn _decode(
271            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
272        ) -> Result<TestControllerCreateFullmacResult, fidl::Error> {
273            let _response = fidl::client::decode_transaction_body::<
274                fidl::encoding::ResultType<TestControllerCreateFullmacResponse, i32>,
275                fidl::encoding::DefaultFuchsiaResourceDialect,
276                0x1eaf55234a2c969d,
277            >(_buf?)?;
278            Ok(_response.map(|x| x.id))
279        }
280        self.client.send_query_and_decode::<
281            TestControllerCreateFullmacRequest,
282            TestControllerCreateFullmacResult,
283        >(
284            (bridge_client,),
285            0x1eaf55234a2c969d,
286            fidl::encoding::DynamicFlags::empty(),
287            _decode,
288        )
289    }
290
291    type DeleteFullmacResponseFut = fidl::client::QueryResponseFut<
292        TestControllerDeleteFullmacResult,
293        fidl::encoding::DefaultFuchsiaResourceDialect,
294    >;
295    fn r#delete_fullmac(&self, mut id: u32) -> Self::DeleteFullmacResponseFut {
296        fn _decode(
297            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
298        ) -> Result<TestControllerDeleteFullmacResult, fidl::Error> {
299            let _response = fidl::client::decode_transaction_body::<
300                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
301                fidl::encoding::DefaultFuchsiaResourceDialect,
302                0x153bf68847795c91,
303            >(_buf?)?;
304            Ok(_response.map(|x| x))
305        }
306        self.client.send_query_and_decode::<
307            TestControllerDeleteFullmacRequest,
308            TestControllerDeleteFullmacResult,
309        >(
310            (id,),
311            0x153bf68847795c91,
312            fidl::encoding::DynamicFlags::empty(),
313            _decode,
314        )
315    }
316}
317
318pub struct TestControllerEventStream {
319    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
320}
321
322impl std::marker::Unpin for TestControllerEventStream {}
323
324impl futures::stream::FusedStream for TestControllerEventStream {
325    fn is_terminated(&self) -> bool {
326        self.event_receiver.is_terminated()
327    }
328}
329
330impl futures::Stream for TestControllerEventStream {
331    type Item = Result<TestControllerEvent, fidl::Error>;
332
333    fn poll_next(
334        mut self: std::pin::Pin<&mut Self>,
335        cx: &mut std::task::Context<'_>,
336    ) -> std::task::Poll<Option<Self::Item>> {
337        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
338            &mut self.event_receiver,
339            cx
340        )?) {
341            Some(buf) => std::task::Poll::Ready(Some(TestControllerEvent::decode(buf))),
342            None => std::task::Poll::Ready(None),
343        }
344    }
345}
346
347#[derive(Debug)]
348pub enum TestControllerEvent {}
349
350impl TestControllerEvent {
351    /// Decodes a message buffer as a [`TestControllerEvent`].
352    fn decode(
353        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
354    ) -> Result<TestControllerEvent, fidl::Error> {
355        let (bytes, _handles) = buf.split_mut();
356        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
357        debug_assert_eq!(tx_header.tx_id, 0);
358        match tx_header.ordinal {
359            _ => Err(fidl::Error::UnknownOrdinal {
360                ordinal: tx_header.ordinal,
361                protocol_name:
362                    <TestControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
363            }),
364        }
365    }
366}
367
368/// A Stream of incoming requests for test.wlan.testcontroller/TestController.
369pub struct TestControllerRequestStream {
370    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
371    is_terminated: bool,
372}
373
374impl std::marker::Unpin for TestControllerRequestStream {}
375
376impl futures::stream::FusedStream for TestControllerRequestStream {
377    fn is_terminated(&self) -> bool {
378        self.is_terminated
379    }
380}
381
382impl fidl::endpoints::RequestStream for TestControllerRequestStream {
383    type Protocol = TestControllerMarker;
384    type ControlHandle = TestControllerControlHandle;
385
386    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
387        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
388    }
389
390    fn control_handle(&self) -> Self::ControlHandle {
391        TestControllerControlHandle { inner: self.inner.clone() }
392    }
393
394    fn into_inner(
395        self,
396    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
397    {
398        (self.inner, self.is_terminated)
399    }
400
401    fn from_inner(
402        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
403        is_terminated: bool,
404    ) -> Self {
405        Self { inner, is_terminated }
406    }
407}
408
409impl futures::Stream for TestControllerRequestStream {
410    type Item = Result<TestControllerRequest, fidl::Error>;
411
412    fn poll_next(
413        mut self: std::pin::Pin<&mut Self>,
414        cx: &mut std::task::Context<'_>,
415    ) -> std::task::Poll<Option<Self::Item>> {
416        let this = &mut *self;
417        if this.inner.check_shutdown(cx) {
418            this.is_terminated = true;
419            return std::task::Poll::Ready(None);
420        }
421        if this.is_terminated {
422            panic!("polled TestControllerRequestStream after completion");
423        }
424        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
425            |bytes, handles| {
426                match this.inner.channel().read_etc(cx, bytes, handles) {
427                    std::task::Poll::Ready(Ok(())) => {}
428                    std::task::Poll::Pending => return std::task::Poll::Pending,
429                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
430                        this.is_terminated = true;
431                        return std::task::Poll::Ready(None);
432                    }
433                    std::task::Poll::Ready(Err(e)) => {
434                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
435                            e.into(),
436                        ))));
437                    }
438                }
439
440                // A message has been received from the channel
441                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
442
443                std::task::Poll::Ready(Some(match header.ordinal {
444                    0x1eaf55234a2c969d => {
445                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
446                        let mut req = fidl::new_empty!(
447                            TestControllerCreateFullmacRequest,
448                            fidl::encoding::DefaultFuchsiaResourceDialect
449                        );
450                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<TestControllerCreateFullmacRequest>(&header, _body_bytes, handles, &mut req)?;
451                        let control_handle =
452                            TestControllerControlHandle { inner: this.inner.clone() };
453                        Ok(TestControllerRequest::CreateFullmac {
454                            bridge_client: req.bridge_client,
455
456                            responder: TestControllerCreateFullmacResponder {
457                                control_handle: std::mem::ManuallyDrop::new(control_handle),
458                                tx_id: header.tx_id,
459                            },
460                        })
461                    }
462                    0x153bf68847795c91 => {
463                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
464                        let mut req = fidl::new_empty!(
465                            TestControllerDeleteFullmacRequest,
466                            fidl::encoding::DefaultFuchsiaResourceDialect
467                        );
468                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<TestControllerDeleteFullmacRequest>(&header, _body_bytes, handles, &mut req)?;
469                        let control_handle =
470                            TestControllerControlHandle { inner: this.inner.clone() };
471                        Ok(TestControllerRequest::DeleteFullmac {
472                            id: req.id,
473
474                            responder: TestControllerDeleteFullmacResponder {
475                                control_handle: std::mem::ManuallyDrop::new(control_handle),
476                                tx_id: header.tx_id,
477                            },
478                        })
479                    }
480                    _ => Err(fidl::Error::UnknownOrdinal {
481                        ordinal: header.ordinal,
482                        protocol_name:
483                            <TestControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
484                    }),
485                }))
486            },
487        )
488    }
489}
490
491#[derive(Debug)]
492pub enum TestControllerRequest {
493    /// Create and bind Fullmac driver that forwards all incoming calls
494    /// to the |bridge_client|. The Fullmac driver will also create an instance
495    /// of SME on binding.
496    ///
497    /// The user should expect to receive a call to
498    /// WlanFullmacImpl::Start shortly after calling this.
499    ///
500    /// Returns an |id| that uniquely identifies the new instance of the Fullmac driver,
501    /// which can be used to delete the driver instance later.
502    CreateFullmac {
503        bridge_client:
504            fidl::endpoints::ClientEnd<fidl_fuchsia_wlan_fullmac::WlanFullmacImpl_Marker>,
505        responder: TestControllerCreateFullmacResponder,
506    },
507    /// Deletes the Fullmac driver with the given |id|.
508    DeleteFullmac { id: u32, responder: TestControllerDeleteFullmacResponder },
509}
510
511impl TestControllerRequest {
512    #[allow(irrefutable_let_patterns)]
513    pub fn into_create_fullmac(
514        self,
515    ) -> Option<(
516        fidl::endpoints::ClientEnd<fidl_fuchsia_wlan_fullmac::WlanFullmacImpl_Marker>,
517        TestControllerCreateFullmacResponder,
518    )> {
519        if let TestControllerRequest::CreateFullmac { bridge_client, responder } = self {
520            Some((bridge_client, responder))
521        } else {
522            None
523        }
524    }
525
526    #[allow(irrefutable_let_patterns)]
527    pub fn into_delete_fullmac(self) -> Option<(u32, TestControllerDeleteFullmacResponder)> {
528        if let TestControllerRequest::DeleteFullmac { id, responder } = self {
529            Some((id, responder))
530        } else {
531            None
532        }
533    }
534
535    /// Name of the method defined in FIDL
536    pub fn method_name(&self) -> &'static str {
537        match *self {
538            TestControllerRequest::CreateFullmac { .. } => "create_fullmac",
539            TestControllerRequest::DeleteFullmac { .. } => "delete_fullmac",
540        }
541    }
542}
543
544#[derive(Debug, Clone)]
545pub struct TestControllerControlHandle {
546    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
547}
548
549impl TestControllerControlHandle {
550    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
551        self.inner.shutdown_with_epitaph(status.into())
552    }
553}
554
555impl fidl::endpoints::ControlHandle for TestControllerControlHandle {
556    fn shutdown(&self) {
557        self.inner.shutdown()
558    }
559
560    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
561        self.inner.shutdown_with_epitaph(status)
562    }
563
564    fn is_closed(&self) -> bool {
565        self.inner.channel().is_closed()
566    }
567    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
568        self.inner.channel().on_closed()
569    }
570
571    #[cfg(target_os = "fuchsia")]
572    fn signal_peer(
573        &self,
574        clear_mask: zx::Signals,
575        set_mask: zx::Signals,
576    ) -> Result<(), zx_status::Status> {
577        use fidl::Peered;
578        self.inner.channel().signal_peer(clear_mask, set_mask)
579    }
580}
581
582impl TestControllerControlHandle {}
583
584#[must_use = "FIDL methods require a response to be sent"]
585#[derive(Debug)]
586pub struct TestControllerCreateFullmacResponder {
587    control_handle: std::mem::ManuallyDrop<TestControllerControlHandle>,
588    tx_id: u32,
589}
590
591/// Set the the channel to be shutdown (see [`TestControllerControlHandle::shutdown`])
592/// if the responder is dropped without sending a response, so that the client
593/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
594impl std::ops::Drop for TestControllerCreateFullmacResponder {
595    fn drop(&mut self) {
596        self.control_handle.shutdown();
597        // Safety: drops once, never accessed again
598        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
599    }
600}
601
602impl fidl::endpoints::Responder for TestControllerCreateFullmacResponder {
603    type ControlHandle = TestControllerControlHandle;
604
605    fn control_handle(&self) -> &TestControllerControlHandle {
606        &self.control_handle
607    }
608
609    fn drop_without_shutdown(mut self) {
610        // Safety: drops once, never accessed again due to mem::forget
611        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
612        // Prevent Drop from running (which would shut down the channel)
613        std::mem::forget(self);
614    }
615}
616
617impl TestControllerCreateFullmacResponder {
618    /// Sends a response to the FIDL transaction.
619    ///
620    /// Sets the channel to shutdown if an error occurs.
621    pub fn send(self, mut result: Result<u32, i32>) -> Result<(), fidl::Error> {
622        let _result = self.send_raw(result);
623        if _result.is_err() {
624            self.control_handle.shutdown();
625        }
626        self.drop_without_shutdown();
627        _result
628    }
629
630    /// Similar to "send" but does not shutdown the channel if an error occurs.
631    pub fn send_no_shutdown_on_err(self, mut result: Result<u32, i32>) -> Result<(), fidl::Error> {
632        let _result = self.send_raw(result);
633        self.drop_without_shutdown();
634        _result
635    }
636
637    fn send_raw(&self, mut result: Result<u32, i32>) -> Result<(), fidl::Error> {
638        self.control_handle.inner.send::<fidl::encoding::ResultType<
639            TestControllerCreateFullmacResponse,
640            i32,
641        >>(
642            result.map(|id| (id,)),
643            self.tx_id,
644            0x1eaf55234a2c969d,
645            fidl::encoding::DynamicFlags::empty(),
646        )
647    }
648}
649
650#[must_use = "FIDL methods require a response to be sent"]
651#[derive(Debug)]
652pub struct TestControllerDeleteFullmacResponder {
653    control_handle: std::mem::ManuallyDrop<TestControllerControlHandle>,
654    tx_id: u32,
655}
656
657/// Set the the channel to be shutdown (see [`TestControllerControlHandle::shutdown`])
658/// if the responder is dropped without sending a response, so that the client
659/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
660impl std::ops::Drop for TestControllerDeleteFullmacResponder {
661    fn drop(&mut self) {
662        self.control_handle.shutdown();
663        // Safety: drops once, never accessed again
664        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
665    }
666}
667
668impl fidl::endpoints::Responder for TestControllerDeleteFullmacResponder {
669    type ControlHandle = TestControllerControlHandle;
670
671    fn control_handle(&self) -> &TestControllerControlHandle {
672        &self.control_handle
673    }
674
675    fn drop_without_shutdown(mut self) {
676        // Safety: drops once, never accessed again due to mem::forget
677        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
678        // Prevent Drop from running (which would shut down the channel)
679        std::mem::forget(self);
680    }
681}
682
683impl TestControllerDeleteFullmacResponder {
684    /// Sends a response to the FIDL transaction.
685    ///
686    /// Sets the channel to shutdown if an error occurs.
687    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
688        let _result = self.send_raw(result);
689        if _result.is_err() {
690            self.control_handle.shutdown();
691        }
692        self.drop_without_shutdown();
693        _result
694    }
695
696    /// Similar to "send" but does not shutdown the channel if an error occurs.
697    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
698        let _result = self.send_raw(result);
699        self.drop_without_shutdown();
700        _result
701    }
702
703    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
704        self.control_handle
705            .inner
706            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
707                result,
708                self.tx_id,
709                0x153bf68847795c91,
710                fidl::encoding::DynamicFlags::empty(),
711            )
712    }
713}
714
715mod internal {
716    use super::*;
717
718    impl fidl::encoding::ResourceTypeMarker for TestControllerCreateFullmacRequest {
719        type Borrowed<'a> = &'a mut Self;
720        fn take_or_borrow<'a>(
721            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
722        ) -> Self::Borrowed<'a> {
723            value
724        }
725    }
726
727    unsafe impl fidl::encoding::TypeMarker for TestControllerCreateFullmacRequest {
728        type Owned = Self;
729
730        #[inline(always)]
731        fn inline_align(_context: fidl::encoding::Context) -> usize {
732            4
733        }
734
735        #[inline(always)]
736        fn inline_size(_context: fidl::encoding::Context) -> usize {
737            4
738        }
739    }
740
741    unsafe impl
742        fidl::encoding::Encode<
743            TestControllerCreateFullmacRequest,
744            fidl::encoding::DefaultFuchsiaResourceDialect,
745        > for &mut TestControllerCreateFullmacRequest
746    {
747        #[inline]
748        unsafe fn encode(
749            self,
750            encoder: &mut fidl::encoding::Encoder<
751                '_,
752                fidl::encoding::DefaultFuchsiaResourceDialect,
753            >,
754            offset: usize,
755            _depth: fidl::encoding::Depth,
756        ) -> fidl::Result<()> {
757            encoder.debug_check_bounds::<TestControllerCreateFullmacRequest>(offset);
758            // Delegate to tuple encoding.
759            fidl::encoding::Encode::<
760                TestControllerCreateFullmacRequest,
761                fidl::encoding::DefaultFuchsiaResourceDialect,
762            >::encode(
763                (<fidl::encoding::Endpoint<
764                    fidl::endpoints::ClientEnd<fidl_fuchsia_wlan_fullmac::WlanFullmacImpl_Marker>,
765                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
766                    &mut self.bridge_client
767                ),),
768                encoder,
769                offset,
770                _depth,
771            )
772        }
773    }
774    unsafe impl<
775        T0: fidl::encoding::Encode<
776                fidl::encoding::Endpoint<
777                    fidl::endpoints::ClientEnd<fidl_fuchsia_wlan_fullmac::WlanFullmacImpl_Marker>,
778                >,
779                fidl::encoding::DefaultFuchsiaResourceDialect,
780            >,
781    >
782        fidl::encoding::Encode<
783            TestControllerCreateFullmacRequest,
784            fidl::encoding::DefaultFuchsiaResourceDialect,
785        > for (T0,)
786    {
787        #[inline]
788        unsafe fn encode(
789            self,
790            encoder: &mut fidl::encoding::Encoder<
791                '_,
792                fidl::encoding::DefaultFuchsiaResourceDialect,
793            >,
794            offset: usize,
795            depth: fidl::encoding::Depth,
796        ) -> fidl::Result<()> {
797            encoder.debug_check_bounds::<TestControllerCreateFullmacRequest>(offset);
798            // Zero out padding regions. There's no need to apply masks
799            // because the unmasked parts will be overwritten by fields.
800            // Write the fields.
801            self.0.encode(encoder, offset + 0, depth)?;
802            Ok(())
803        }
804    }
805
806    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
807        for TestControllerCreateFullmacRequest
808    {
809        #[inline(always)]
810        fn new_empty() -> Self {
811            Self {
812                bridge_client: fidl::new_empty!(
813                    fidl::encoding::Endpoint<
814                        fidl::endpoints::ClientEnd<
815                            fidl_fuchsia_wlan_fullmac::WlanFullmacImpl_Marker,
816                        >,
817                    >,
818                    fidl::encoding::DefaultFuchsiaResourceDialect
819                ),
820            }
821        }
822
823        #[inline]
824        unsafe fn decode(
825            &mut self,
826            decoder: &mut fidl::encoding::Decoder<
827                '_,
828                fidl::encoding::DefaultFuchsiaResourceDialect,
829            >,
830            offset: usize,
831            _depth: fidl::encoding::Depth,
832        ) -> fidl::Result<()> {
833            decoder.debug_check_bounds::<Self>(offset);
834            // Verify that padding bytes are zero.
835            fidl::decode!(
836                fidl::encoding::Endpoint<
837                    fidl::endpoints::ClientEnd<fidl_fuchsia_wlan_fullmac::WlanFullmacImpl_Marker>,
838                >,
839                fidl::encoding::DefaultFuchsiaResourceDialect,
840                &mut self.bridge_client,
841                decoder,
842                offset + 0,
843                _depth
844            )?;
845            Ok(())
846        }
847    }
848
849    impl fidl::encoding::ResourceTypeMarker for TestControllerDeleteFullmacRequest {
850        type Borrowed<'a> = &'a mut Self;
851        fn take_or_borrow<'a>(
852            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
853        ) -> Self::Borrowed<'a> {
854            value
855        }
856    }
857
858    unsafe impl fidl::encoding::TypeMarker for TestControllerDeleteFullmacRequest {
859        type Owned = Self;
860
861        #[inline(always)]
862        fn inline_align(_context: fidl::encoding::Context) -> usize {
863            4
864        }
865
866        #[inline(always)]
867        fn inline_size(_context: fidl::encoding::Context) -> usize {
868            4
869        }
870        #[inline(always)]
871        fn encode_is_copy() -> bool {
872            true
873        }
874
875        #[inline(always)]
876        fn decode_is_copy() -> bool {
877            true
878        }
879    }
880
881    unsafe impl
882        fidl::encoding::Encode<
883            TestControllerDeleteFullmacRequest,
884            fidl::encoding::DefaultFuchsiaResourceDialect,
885        > for &mut TestControllerDeleteFullmacRequest
886    {
887        #[inline]
888        unsafe fn encode(
889            self,
890            encoder: &mut fidl::encoding::Encoder<
891                '_,
892                fidl::encoding::DefaultFuchsiaResourceDialect,
893            >,
894            offset: usize,
895            _depth: fidl::encoding::Depth,
896        ) -> fidl::Result<()> {
897            encoder.debug_check_bounds::<TestControllerDeleteFullmacRequest>(offset);
898            unsafe {
899                // Copy the object into the buffer.
900                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
901                (buf_ptr as *mut TestControllerDeleteFullmacRequest)
902                    .write_unaligned((self as *const TestControllerDeleteFullmacRequest).read());
903                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
904                // done second because the memcpy will write garbage to these bytes.
905            }
906            Ok(())
907        }
908    }
909    unsafe impl<T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>>
910        fidl::encoding::Encode<
911            TestControllerDeleteFullmacRequest,
912            fidl::encoding::DefaultFuchsiaResourceDialect,
913        > for (T0,)
914    {
915        #[inline]
916        unsafe fn encode(
917            self,
918            encoder: &mut fidl::encoding::Encoder<
919                '_,
920                fidl::encoding::DefaultFuchsiaResourceDialect,
921            >,
922            offset: usize,
923            depth: fidl::encoding::Depth,
924        ) -> fidl::Result<()> {
925            encoder.debug_check_bounds::<TestControllerDeleteFullmacRequest>(offset);
926            // Zero out padding regions. There's no need to apply masks
927            // because the unmasked parts will be overwritten by fields.
928            // Write the fields.
929            self.0.encode(encoder, offset + 0, depth)?;
930            Ok(())
931        }
932    }
933
934    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
935        for TestControllerDeleteFullmacRequest
936    {
937        #[inline(always)]
938        fn new_empty() -> Self {
939            Self { id: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect) }
940        }
941
942        #[inline]
943        unsafe fn decode(
944            &mut self,
945            decoder: &mut fidl::encoding::Decoder<
946                '_,
947                fidl::encoding::DefaultFuchsiaResourceDialect,
948            >,
949            offset: usize,
950            _depth: fidl::encoding::Depth,
951        ) -> fidl::Result<()> {
952            decoder.debug_check_bounds::<Self>(offset);
953            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
954            // Verify that padding bytes are zero.
955            // Copy from the buffer into the object.
956            unsafe {
957                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
958            }
959            Ok(())
960        }
961    }
962
963    impl fidl::encoding::ResourceTypeMarker for TestControllerCreateFullmacResponse {
964        type Borrowed<'a> = &'a mut Self;
965        fn take_or_borrow<'a>(
966            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
967        ) -> Self::Borrowed<'a> {
968            value
969        }
970    }
971
972    unsafe impl fidl::encoding::TypeMarker for TestControllerCreateFullmacResponse {
973        type Owned = Self;
974
975        #[inline(always)]
976        fn inline_align(_context: fidl::encoding::Context) -> usize {
977            4
978        }
979
980        #[inline(always)]
981        fn inline_size(_context: fidl::encoding::Context) -> usize {
982            4
983        }
984        #[inline(always)]
985        fn encode_is_copy() -> bool {
986            true
987        }
988
989        #[inline(always)]
990        fn decode_is_copy() -> bool {
991            true
992        }
993    }
994
995    unsafe impl
996        fidl::encoding::Encode<
997            TestControllerCreateFullmacResponse,
998            fidl::encoding::DefaultFuchsiaResourceDialect,
999        > for &mut TestControllerCreateFullmacResponse
1000    {
1001        #[inline]
1002        unsafe fn encode(
1003            self,
1004            encoder: &mut fidl::encoding::Encoder<
1005                '_,
1006                fidl::encoding::DefaultFuchsiaResourceDialect,
1007            >,
1008            offset: usize,
1009            _depth: fidl::encoding::Depth,
1010        ) -> fidl::Result<()> {
1011            encoder.debug_check_bounds::<TestControllerCreateFullmacResponse>(offset);
1012            unsafe {
1013                // Copy the object into the buffer.
1014                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
1015                (buf_ptr as *mut TestControllerCreateFullmacResponse)
1016                    .write_unaligned((self as *const TestControllerCreateFullmacResponse).read());
1017                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
1018                // done second because the memcpy will write garbage to these bytes.
1019            }
1020            Ok(())
1021        }
1022    }
1023    unsafe impl<T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>>
1024        fidl::encoding::Encode<
1025            TestControllerCreateFullmacResponse,
1026            fidl::encoding::DefaultFuchsiaResourceDialect,
1027        > for (T0,)
1028    {
1029        #[inline]
1030        unsafe fn encode(
1031            self,
1032            encoder: &mut fidl::encoding::Encoder<
1033                '_,
1034                fidl::encoding::DefaultFuchsiaResourceDialect,
1035            >,
1036            offset: usize,
1037            depth: fidl::encoding::Depth,
1038        ) -> fidl::Result<()> {
1039            encoder.debug_check_bounds::<TestControllerCreateFullmacResponse>(offset);
1040            // Zero out padding regions. There's no need to apply masks
1041            // because the unmasked parts will be overwritten by fields.
1042            // Write the fields.
1043            self.0.encode(encoder, offset + 0, depth)?;
1044            Ok(())
1045        }
1046    }
1047
1048    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1049        for TestControllerCreateFullmacResponse
1050    {
1051        #[inline(always)]
1052        fn new_empty() -> Self {
1053            Self { id: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect) }
1054        }
1055
1056        #[inline]
1057        unsafe fn decode(
1058            &mut self,
1059            decoder: &mut fidl::encoding::Decoder<
1060                '_,
1061                fidl::encoding::DefaultFuchsiaResourceDialect,
1062            >,
1063            offset: usize,
1064            _depth: fidl::encoding::Depth,
1065        ) -> fidl::Result<()> {
1066            decoder.debug_check_bounds::<Self>(offset);
1067            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
1068            // Verify that padding bytes are zero.
1069            // Copy from the buffer into the object.
1070            unsafe {
1071                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
1072            }
1073            Ok(())
1074        }
1075    }
1076}