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