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