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