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 fidl::endpoints::ControlHandle for TestControllerControlHandle {
550    fn shutdown(&self) {
551        self.inner.shutdown()
552    }
553
554    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
555        self.inner.shutdown_with_epitaph(status)
556    }
557
558    fn is_closed(&self) -> bool {
559        self.inner.channel().is_closed()
560    }
561    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
562        self.inner.channel().on_closed()
563    }
564
565    #[cfg(target_os = "fuchsia")]
566    fn signal_peer(
567        &self,
568        clear_mask: zx::Signals,
569        set_mask: zx::Signals,
570    ) -> Result<(), zx_status::Status> {
571        use fidl::Peered;
572        self.inner.channel().signal_peer(clear_mask, set_mask)
573    }
574}
575
576impl TestControllerControlHandle {}
577
578#[must_use = "FIDL methods require a response to be sent"]
579#[derive(Debug)]
580pub struct TestControllerCreateFullmacResponder {
581    control_handle: std::mem::ManuallyDrop<TestControllerControlHandle>,
582    tx_id: u32,
583}
584
585/// Set the the channel to be shutdown (see [`TestControllerControlHandle::shutdown`])
586/// if the responder is dropped without sending a response, so that the client
587/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
588impl std::ops::Drop for TestControllerCreateFullmacResponder {
589    fn drop(&mut self) {
590        self.control_handle.shutdown();
591        // Safety: drops once, never accessed again
592        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
593    }
594}
595
596impl fidl::endpoints::Responder for TestControllerCreateFullmacResponder {
597    type ControlHandle = TestControllerControlHandle;
598
599    fn control_handle(&self) -> &TestControllerControlHandle {
600        &self.control_handle
601    }
602
603    fn drop_without_shutdown(mut self) {
604        // Safety: drops once, never accessed again due to mem::forget
605        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
606        // Prevent Drop from running (which would shut down the channel)
607        std::mem::forget(self);
608    }
609}
610
611impl TestControllerCreateFullmacResponder {
612    /// Sends a response to the FIDL transaction.
613    ///
614    /// Sets the channel to shutdown if an error occurs.
615    pub fn send(self, mut result: Result<u32, i32>) -> Result<(), fidl::Error> {
616        let _result = self.send_raw(result);
617        if _result.is_err() {
618            self.control_handle.shutdown();
619        }
620        self.drop_without_shutdown();
621        _result
622    }
623
624    /// Similar to "send" but does not shutdown the channel if an error occurs.
625    pub fn send_no_shutdown_on_err(self, mut result: Result<u32, i32>) -> Result<(), fidl::Error> {
626        let _result = self.send_raw(result);
627        self.drop_without_shutdown();
628        _result
629    }
630
631    fn send_raw(&self, mut result: Result<u32, i32>) -> Result<(), fidl::Error> {
632        self.control_handle.inner.send::<fidl::encoding::ResultType<
633            TestControllerCreateFullmacResponse,
634            i32,
635        >>(
636            result.map(|id| (id,)),
637            self.tx_id,
638            0x1eaf55234a2c969d,
639            fidl::encoding::DynamicFlags::empty(),
640        )
641    }
642}
643
644#[must_use = "FIDL methods require a response to be sent"]
645#[derive(Debug)]
646pub struct TestControllerDeleteFullmacResponder {
647    control_handle: std::mem::ManuallyDrop<TestControllerControlHandle>,
648    tx_id: u32,
649}
650
651/// Set the the channel to be shutdown (see [`TestControllerControlHandle::shutdown`])
652/// if the responder is dropped without sending a response, so that the client
653/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
654impl std::ops::Drop for TestControllerDeleteFullmacResponder {
655    fn drop(&mut self) {
656        self.control_handle.shutdown();
657        // Safety: drops once, never accessed again
658        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
659    }
660}
661
662impl fidl::endpoints::Responder for TestControllerDeleteFullmacResponder {
663    type ControlHandle = TestControllerControlHandle;
664
665    fn control_handle(&self) -> &TestControllerControlHandle {
666        &self.control_handle
667    }
668
669    fn drop_without_shutdown(mut self) {
670        // Safety: drops once, never accessed again due to mem::forget
671        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
672        // Prevent Drop from running (which would shut down the channel)
673        std::mem::forget(self);
674    }
675}
676
677impl TestControllerDeleteFullmacResponder {
678    /// Sends a response to the FIDL transaction.
679    ///
680    /// Sets the channel to shutdown if an error occurs.
681    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
682        let _result = self.send_raw(result);
683        if _result.is_err() {
684            self.control_handle.shutdown();
685        }
686        self.drop_without_shutdown();
687        _result
688    }
689
690    /// Similar to "send" but does not shutdown the channel if an error occurs.
691    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
692        let _result = self.send_raw(result);
693        self.drop_without_shutdown();
694        _result
695    }
696
697    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
698        self.control_handle
699            .inner
700            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
701                result,
702                self.tx_id,
703                0x153bf68847795c91,
704                fidl::encoding::DynamicFlags::empty(),
705            )
706    }
707}
708
709mod internal {
710    use super::*;
711
712    impl fidl::encoding::ResourceTypeMarker for TestControllerCreateFullmacRequest {
713        type Borrowed<'a> = &'a mut Self;
714        fn take_or_borrow<'a>(
715            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
716        ) -> Self::Borrowed<'a> {
717            value
718        }
719    }
720
721    unsafe impl fidl::encoding::TypeMarker for TestControllerCreateFullmacRequest {
722        type Owned = Self;
723
724        #[inline(always)]
725        fn inline_align(_context: fidl::encoding::Context) -> usize {
726            4
727        }
728
729        #[inline(always)]
730        fn inline_size(_context: fidl::encoding::Context) -> usize {
731            4
732        }
733    }
734
735    unsafe impl
736        fidl::encoding::Encode<
737            TestControllerCreateFullmacRequest,
738            fidl::encoding::DefaultFuchsiaResourceDialect,
739        > for &mut TestControllerCreateFullmacRequest
740    {
741        #[inline]
742        unsafe fn encode(
743            self,
744            encoder: &mut fidl::encoding::Encoder<
745                '_,
746                fidl::encoding::DefaultFuchsiaResourceDialect,
747            >,
748            offset: usize,
749            _depth: fidl::encoding::Depth,
750        ) -> fidl::Result<()> {
751            encoder.debug_check_bounds::<TestControllerCreateFullmacRequest>(offset);
752            // Delegate to tuple encoding.
753            fidl::encoding::Encode::<
754                TestControllerCreateFullmacRequest,
755                fidl::encoding::DefaultFuchsiaResourceDialect,
756            >::encode(
757                (<fidl::encoding::Endpoint<
758                    fidl::endpoints::ClientEnd<fidl_fuchsia_wlan_fullmac::WlanFullmacImpl_Marker>,
759                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
760                    &mut self.bridge_client
761                ),),
762                encoder,
763                offset,
764                _depth,
765            )
766        }
767    }
768    unsafe impl<
769        T0: fidl::encoding::Encode<
770                fidl::encoding::Endpoint<
771                    fidl::endpoints::ClientEnd<fidl_fuchsia_wlan_fullmac::WlanFullmacImpl_Marker>,
772                >,
773                fidl::encoding::DefaultFuchsiaResourceDialect,
774            >,
775    >
776        fidl::encoding::Encode<
777            TestControllerCreateFullmacRequest,
778            fidl::encoding::DefaultFuchsiaResourceDialect,
779        > for (T0,)
780    {
781        #[inline]
782        unsafe fn encode(
783            self,
784            encoder: &mut fidl::encoding::Encoder<
785                '_,
786                fidl::encoding::DefaultFuchsiaResourceDialect,
787            >,
788            offset: usize,
789            depth: fidl::encoding::Depth,
790        ) -> fidl::Result<()> {
791            encoder.debug_check_bounds::<TestControllerCreateFullmacRequest>(offset);
792            // Zero out padding regions. There's no need to apply masks
793            // because the unmasked parts will be overwritten by fields.
794            // Write the fields.
795            self.0.encode(encoder, offset + 0, depth)?;
796            Ok(())
797        }
798    }
799
800    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
801        for TestControllerCreateFullmacRequest
802    {
803        #[inline(always)]
804        fn new_empty() -> Self {
805            Self {
806                bridge_client: fidl::new_empty!(
807                    fidl::encoding::Endpoint<
808                        fidl::endpoints::ClientEnd<
809                            fidl_fuchsia_wlan_fullmac::WlanFullmacImpl_Marker,
810                        >,
811                    >,
812                    fidl::encoding::DefaultFuchsiaResourceDialect
813                ),
814            }
815        }
816
817        #[inline]
818        unsafe fn decode(
819            &mut self,
820            decoder: &mut fidl::encoding::Decoder<
821                '_,
822                fidl::encoding::DefaultFuchsiaResourceDialect,
823            >,
824            offset: usize,
825            _depth: fidl::encoding::Depth,
826        ) -> fidl::Result<()> {
827            decoder.debug_check_bounds::<Self>(offset);
828            // Verify that padding bytes are zero.
829            fidl::decode!(
830                fidl::encoding::Endpoint<
831                    fidl::endpoints::ClientEnd<fidl_fuchsia_wlan_fullmac::WlanFullmacImpl_Marker>,
832                >,
833                fidl::encoding::DefaultFuchsiaResourceDialect,
834                &mut self.bridge_client,
835                decoder,
836                offset + 0,
837                _depth
838            )?;
839            Ok(())
840        }
841    }
842
843    impl fidl::encoding::ResourceTypeMarker for TestControllerDeleteFullmacRequest {
844        type Borrowed<'a> = &'a mut Self;
845        fn take_or_borrow<'a>(
846            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
847        ) -> Self::Borrowed<'a> {
848            value
849        }
850    }
851
852    unsafe impl fidl::encoding::TypeMarker for TestControllerDeleteFullmacRequest {
853        type Owned = Self;
854
855        #[inline(always)]
856        fn inline_align(_context: fidl::encoding::Context) -> usize {
857            4
858        }
859
860        #[inline(always)]
861        fn inline_size(_context: fidl::encoding::Context) -> usize {
862            4
863        }
864        #[inline(always)]
865        fn encode_is_copy() -> bool {
866            true
867        }
868
869        #[inline(always)]
870        fn decode_is_copy() -> bool {
871            true
872        }
873    }
874
875    unsafe impl
876        fidl::encoding::Encode<
877            TestControllerDeleteFullmacRequest,
878            fidl::encoding::DefaultFuchsiaResourceDialect,
879        > for &mut TestControllerDeleteFullmacRequest
880    {
881        #[inline]
882        unsafe fn encode(
883            self,
884            encoder: &mut fidl::encoding::Encoder<
885                '_,
886                fidl::encoding::DefaultFuchsiaResourceDialect,
887            >,
888            offset: usize,
889            _depth: fidl::encoding::Depth,
890        ) -> fidl::Result<()> {
891            encoder.debug_check_bounds::<TestControllerDeleteFullmacRequest>(offset);
892            unsafe {
893                // Copy the object into the buffer.
894                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
895                (buf_ptr as *mut TestControllerDeleteFullmacRequest)
896                    .write_unaligned((self as *const TestControllerDeleteFullmacRequest).read());
897                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
898                // done second because the memcpy will write garbage to these bytes.
899            }
900            Ok(())
901        }
902    }
903    unsafe impl<T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>>
904        fidl::encoding::Encode<
905            TestControllerDeleteFullmacRequest,
906            fidl::encoding::DefaultFuchsiaResourceDialect,
907        > for (T0,)
908    {
909        #[inline]
910        unsafe fn encode(
911            self,
912            encoder: &mut fidl::encoding::Encoder<
913                '_,
914                fidl::encoding::DefaultFuchsiaResourceDialect,
915            >,
916            offset: usize,
917            depth: fidl::encoding::Depth,
918        ) -> fidl::Result<()> {
919            encoder.debug_check_bounds::<TestControllerDeleteFullmacRequest>(offset);
920            // Zero out padding regions. There's no need to apply masks
921            // because the unmasked parts will be overwritten by fields.
922            // Write the fields.
923            self.0.encode(encoder, offset + 0, depth)?;
924            Ok(())
925        }
926    }
927
928    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
929        for TestControllerDeleteFullmacRequest
930    {
931        #[inline(always)]
932        fn new_empty() -> Self {
933            Self { id: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect) }
934        }
935
936        #[inline]
937        unsafe fn decode(
938            &mut self,
939            decoder: &mut fidl::encoding::Decoder<
940                '_,
941                fidl::encoding::DefaultFuchsiaResourceDialect,
942            >,
943            offset: usize,
944            _depth: fidl::encoding::Depth,
945        ) -> fidl::Result<()> {
946            decoder.debug_check_bounds::<Self>(offset);
947            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
948            // Verify that padding bytes are zero.
949            // Copy from the buffer into the object.
950            unsafe {
951                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
952            }
953            Ok(())
954        }
955    }
956
957    impl fidl::encoding::ResourceTypeMarker for TestControllerCreateFullmacResponse {
958        type Borrowed<'a> = &'a mut Self;
959        fn take_or_borrow<'a>(
960            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
961        ) -> Self::Borrowed<'a> {
962            value
963        }
964    }
965
966    unsafe impl fidl::encoding::TypeMarker for TestControllerCreateFullmacResponse {
967        type Owned = Self;
968
969        #[inline(always)]
970        fn inline_align(_context: fidl::encoding::Context) -> usize {
971            4
972        }
973
974        #[inline(always)]
975        fn inline_size(_context: fidl::encoding::Context) -> usize {
976            4
977        }
978        #[inline(always)]
979        fn encode_is_copy() -> bool {
980            true
981        }
982
983        #[inline(always)]
984        fn decode_is_copy() -> bool {
985            true
986        }
987    }
988
989    unsafe impl
990        fidl::encoding::Encode<
991            TestControllerCreateFullmacResponse,
992            fidl::encoding::DefaultFuchsiaResourceDialect,
993        > for &mut TestControllerCreateFullmacResponse
994    {
995        #[inline]
996        unsafe fn encode(
997            self,
998            encoder: &mut fidl::encoding::Encoder<
999                '_,
1000                fidl::encoding::DefaultFuchsiaResourceDialect,
1001            >,
1002            offset: usize,
1003            _depth: fidl::encoding::Depth,
1004        ) -> fidl::Result<()> {
1005            encoder.debug_check_bounds::<TestControllerCreateFullmacResponse>(offset);
1006            unsafe {
1007                // Copy the object into the buffer.
1008                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
1009                (buf_ptr as *mut TestControllerCreateFullmacResponse)
1010                    .write_unaligned((self as *const TestControllerCreateFullmacResponse).read());
1011                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
1012                // done second because the memcpy will write garbage to these bytes.
1013            }
1014            Ok(())
1015        }
1016    }
1017    unsafe impl<T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>>
1018        fidl::encoding::Encode<
1019            TestControllerCreateFullmacResponse,
1020            fidl::encoding::DefaultFuchsiaResourceDialect,
1021        > for (T0,)
1022    {
1023        #[inline]
1024        unsafe fn encode(
1025            self,
1026            encoder: &mut fidl::encoding::Encoder<
1027                '_,
1028                fidl::encoding::DefaultFuchsiaResourceDialect,
1029            >,
1030            offset: usize,
1031            depth: fidl::encoding::Depth,
1032        ) -> fidl::Result<()> {
1033            encoder.debug_check_bounds::<TestControllerCreateFullmacResponse>(offset);
1034            // Zero out padding regions. There's no need to apply masks
1035            // because the unmasked parts will be overwritten by fields.
1036            // Write the fields.
1037            self.0.encode(encoder, offset + 0, depth)?;
1038            Ok(())
1039        }
1040    }
1041
1042    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1043        for TestControllerCreateFullmacResponse
1044    {
1045        #[inline(always)]
1046        fn new_empty() -> Self {
1047            Self { id: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect) }
1048        }
1049
1050        #[inline]
1051        unsafe fn decode(
1052            &mut self,
1053            decoder: &mut fidl::encoding::Decoder<
1054                '_,
1055                fidl::encoding::DefaultFuchsiaResourceDialect,
1056            >,
1057            offset: usize,
1058            _depth: fidl::encoding::Depth,
1059        ) -> fidl::Result<()> {
1060            decoder.debug_check_bounds::<Self>(offset);
1061            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
1062            // Verify that padding bytes are zero.
1063            // Copy from the buffer into the object.
1064            unsafe {
1065                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
1066            }
1067            Ok(())
1068        }
1069    }
1070}