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