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::Handle {
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    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
406        self.inner.shutdown_with_epitaph(status)
407    }
408
409    fn is_closed(&self) -> bool {
410        self.inner.channel().is_closed()
411    }
412    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
413        self.inner.channel().on_closed()
414    }
415
416    #[cfg(target_os = "fuchsia")]
417    fn signal_peer(
418        &self,
419        clear_mask: zx::Signals,
420        set_mask: zx::Signals,
421    ) -> Result<(), zx_status::Status> {
422        use fidl::Peered;
423        self.inner.channel().signal_peer(clear_mask, set_mask)
424    }
425}
426
427impl DetectControllerControlHandle {}
428
429#[must_use = "FIDL methods require a response to be sent"]
430#[derive(Debug)]
431pub struct DetectControllerEnterTestModeResponder {
432    control_handle: std::mem::ManuallyDrop<DetectControllerControlHandle>,
433    tx_id: u32,
434}
435
436/// Set the the channel to be shutdown (see [`DetectControllerControlHandle::shutdown`])
437/// if the responder is dropped without sending a response, so that the client
438/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
439impl std::ops::Drop for DetectControllerEnterTestModeResponder {
440    fn drop(&mut self) {
441        self.control_handle.shutdown();
442        // Safety: drops once, never accessed again
443        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
444    }
445}
446
447impl fidl::endpoints::Responder for DetectControllerEnterTestModeResponder {
448    type ControlHandle = DetectControllerControlHandle;
449
450    fn control_handle(&self) -> &DetectControllerControlHandle {
451        &self.control_handle
452    }
453
454    fn drop_without_shutdown(mut self) {
455        // Safety: drops once, never accessed again due to mem::forget
456        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
457        // Prevent Drop from running (which would shut down the channel)
458        std::mem::forget(self);
459    }
460}
461
462impl DetectControllerEnterTestModeResponder {
463    /// Sends a response to the FIDL transaction.
464    ///
465    /// Sets the channel to shutdown if an error occurs.
466    pub fn send(self) -> Result<(), fidl::Error> {
467        let _result = self.send_raw();
468        if _result.is_err() {
469            self.control_handle.shutdown();
470        }
471        self.drop_without_shutdown();
472        _result
473    }
474
475    /// Similar to "send" but does not shutdown the channel if an error occurs.
476    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
477        let _result = self.send_raw();
478        self.drop_without_shutdown();
479        _result
480    }
481
482    fn send_raw(&self) -> Result<(), fidl::Error> {
483        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
484            (),
485            self.tx_id,
486            0x6f4bb79cfba4f84,
487            fidl::encoding::DynamicFlags::empty(),
488        )
489    }
490}
491
492#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
493pub struct TestCaseControllerMarker;
494
495impl fidl::endpoints::ProtocolMarker for TestCaseControllerMarker {
496    type Proxy = TestCaseControllerProxy;
497    type RequestStream = TestCaseControllerRequestStream;
498    #[cfg(target_os = "fuchsia")]
499    type SynchronousProxy = TestCaseControllerSynchronousProxy;
500
501    const DEBUG_NAME: &'static str = "(anonymous) TestCaseController";
502}
503
504pub trait TestCaseControllerProxyInterface: Send + Sync {
505    type RunDefaultCycleResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
506    fn r#run_default_cycle(&self) -> Self::RunDefaultCycleResponseFut;
507}
508#[derive(Debug)]
509#[cfg(target_os = "fuchsia")]
510pub struct TestCaseControllerSynchronousProxy {
511    client: fidl::client::sync::Client,
512}
513
514#[cfg(target_os = "fuchsia")]
515impl fidl::endpoints::SynchronousProxy for TestCaseControllerSynchronousProxy {
516    type Proxy = TestCaseControllerProxy;
517    type Protocol = TestCaseControllerMarker;
518
519    fn from_channel(inner: fidl::Channel) -> Self {
520        Self::new(inner)
521    }
522
523    fn into_channel(self) -> fidl::Channel {
524        self.client.into_channel()
525    }
526
527    fn as_channel(&self) -> &fidl::Channel {
528        self.client.as_channel()
529    }
530}
531
532#[cfg(target_os = "fuchsia")]
533impl TestCaseControllerSynchronousProxy {
534    pub fn new(channel: fidl::Channel) -> Self {
535        let protocol_name =
536            <TestCaseControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
537        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
538    }
539
540    pub fn into_channel(self) -> fidl::Channel {
541        self.client.into_channel()
542    }
543
544    /// Waits until an event arrives and returns it. It is safe for other
545    /// threads to make concurrent requests while waiting for an event.
546    pub fn wait_for_event(
547        &self,
548        deadline: zx::MonotonicInstant,
549    ) -> Result<TestCaseControllerEvent, fidl::Error> {
550        TestCaseControllerEvent::decode(self.client.wait_for_event(deadline)?)
551    }
552
553    /// Run a single default test case. Returns when the test case completes.
554    /// Returns an error if the test case exits abnormally.
555    pub fn r#run_default_cycle(
556        &self,
557        ___deadline: zx::MonotonicInstant,
558    ) -> Result<(), fidl::Error> {
559        let _response =
560            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
561                (),
562                0x6f41c0399849aea2,
563                fidl::encoding::DynamicFlags::empty(),
564                ___deadline,
565            )?;
566        Ok(_response)
567    }
568}
569
570#[cfg(target_os = "fuchsia")]
571impl From<TestCaseControllerSynchronousProxy> for zx::Handle {
572    fn from(value: TestCaseControllerSynchronousProxy) -> Self {
573        value.into_channel().into()
574    }
575}
576
577#[cfg(target_os = "fuchsia")]
578impl From<fidl::Channel> for TestCaseControllerSynchronousProxy {
579    fn from(value: fidl::Channel) -> Self {
580        Self::new(value)
581    }
582}
583
584#[cfg(target_os = "fuchsia")]
585impl fidl::endpoints::FromClient for TestCaseControllerSynchronousProxy {
586    type Protocol = TestCaseControllerMarker;
587
588    fn from_client(value: fidl::endpoints::ClientEnd<TestCaseControllerMarker>) -> Self {
589        Self::new(value.into_channel())
590    }
591}
592
593#[derive(Debug, Clone)]
594pub struct TestCaseControllerProxy {
595    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
596}
597
598impl fidl::endpoints::Proxy for TestCaseControllerProxy {
599    type Protocol = TestCaseControllerMarker;
600
601    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
602        Self::new(inner)
603    }
604
605    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
606        self.client.into_channel().map_err(|client| Self { client })
607    }
608
609    fn as_channel(&self) -> &::fidl::AsyncChannel {
610        self.client.as_channel()
611    }
612}
613
614impl TestCaseControllerProxy {
615    /// Create a new Proxy for fuchsia.diagnostics.test/TestCaseController.
616    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
617        let protocol_name =
618            <TestCaseControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
619        Self { client: fidl::client::Client::new(channel, protocol_name) }
620    }
621
622    /// Get a Stream of events from the remote end of the protocol.
623    ///
624    /// # Panics
625    ///
626    /// Panics if the event stream was already taken.
627    pub fn take_event_stream(&self) -> TestCaseControllerEventStream {
628        TestCaseControllerEventStream { event_receiver: self.client.take_event_receiver() }
629    }
630
631    /// Run a single default test case. Returns when the test case completes.
632    /// Returns an error if the test case exits abnormally.
633    pub fn r#run_default_cycle(
634        &self,
635    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
636        TestCaseControllerProxyInterface::r#run_default_cycle(self)
637    }
638}
639
640impl TestCaseControllerProxyInterface for TestCaseControllerProxy {
641    type RunDefaultCycleResponseFut =
642        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
643    fn r#run_default_cycle(&self) -> Self::RunDefaultCycleResponseFut {
644        fn _decode(
645            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
646        ) -> Result<(), fidl::Error> {
647            let _response = fidl::client::decode_transaction_body::<
648                fidl::encoding::EmptyPayload,
649                fidl::encoding::DefaultFuchsiaResourceDialect,
650                0x6f41c0399849aea2,
651            >(_buf?)?;
652            Ok(_response)
653        }
654        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
655            (),
656            0x6f41c0399849aea2,
657            fidl::encoding::DynamicFlags::empty(),
658            _decode,
659        )
660    }
661}
662
663pub struct TestCaseControllerEventStream {
664    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
665}
666
667impl std::marker::Unpin for TestCaseControllerEventStream {}
668
669impl futures::stream::FusedStream for TestCaseControllerEventStream {
670    fn is_terminated(&self) -> bool {
671        self.event_receiver.is_terminated()
672    }
673}
674
675impl futures::Stream for TestCaseControllerEventStream {
676    type Item = Result<TestCaseControllerEvent, fidl::Error>;
677
678    fn poll_next(
679        mut self: std::pin::Pin<&mut Self>,
680        cx: &mut std::task::Context<'_>,
681    ) -> std::task::Poll<Option<Self::Item>> {
682        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
683            &mut self.event_receiver,
684            cx
685        )?) {
686            Some(buf) => std::task::Poll::Ready(Some(TestCaseControllerEvent::decode(buf))),
687            None => std::task::Poll::Ready(None),
688        }
689    }
690}
691
692#[derive(Debug)]
693pub enum TestCaseControllerEvent {}
694
695impl TestCaseControllerEvent {
696    /// Decodes a message buffer as a [`TestCaseControllerEvent`].
697    fn decode(
698        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
699    ) -> Result<TestCaseControllerEvent, fidl::Error> {
700        let (bytes, _handles) = buf.split_mut();
701        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
702        debug_assert_eq!(tx_header.tx_id, 0);
703        match tx_header.ordinal {
704            _ => Err(fidl::Error::UnknownOrdinal {
705                ordinal: tx_header.ordinal,
706                protocol_name:
707                    <TestCaseControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
708            }),
709        }
710    }
711}
712
713/// A Stream of incoming requests for fuchsia.diagnostics.test/TestCaseController.
714pub struct TestCaseControllerRequestStream {
715    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
716    is_terminated: bool,
717}
718
719impl std::marker::Unpin for TestCaseControllerRequestStream {}
720
721impl futures::stream::FusedStream for TestCaseControllerRequestStream {
722    fn is_terminated(&self) -> bool {
723        self.is_terminated
724    }
725}
726
727impl fidl::endpoints::RequestStream for TestCaseControllerRequestStream {
728    type Protocol = TestCaseControllerMarker;
729    type ControlHandle = TestCaseControllerControlHandle;
730
731    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
732        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
733    }
734
735    fn control_handle(&self) -> Self::ControlHandle {
736        TestCaseControllerControlHandle { inner: self.inner.clone() }
737    }
738
739    fn into_inner(
740        self,
741    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
742    {
743        (self.inner, self.is_terminated)
744    }
745
746    fn from_inner(
747        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
748        is_terminated: bool,
749    ) -> Self {
750        Self { inner, is_terminated }
751    }
752}
753
754impl futures::Stream for TestCaseControllerRequestStream {
755    type Item = Result<TestCaseControllerRequest, fidl::Error>;
756
757    fn poll_next(
758        mut self: std::pin::Pin<&mut Self>,
759        cx: &mut std::task::Context<'_>,
760    ) -> std::task::Poll<Option<Self::Item>> {
761        let this = &mut *self;
762        if this.inner.check_shutdown(cx) {
763            this.is_terminated = true;
764            return std::task::Poll::Ready(None);
765        }
766        if this.is_terminated {
767            panic!("polled TestCaseControllerRequestStream after completion");
768        }
769        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
770            |bytes, handles| {
771                match this.inner.channel().read_etc(cx, bytes, handles) {
772                    std::task::Poll::Ready(Ok(())) => {}
773                    std::task::Poll::Pending => return std::task::Poll::Pending,
774                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
775                        this.is_terminated = true;
776                        return std::task::Poll::Ready(None);
777                    }
778                    std::task::Poll::Ready(Err(e)) => {
779                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
780                            e.into(),
781                        ))))
782                    }
783                }
784
785                // A message has been received from the channel
786                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
787
788                std::task::Poll::Ready(Some(match header.ordinal {
789                0x6f41c0399849aea2 => {
790                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
791                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
792                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
793                    let control_handle = TestCaseControllerControlHandle {
794                        inner: this.inner.clone(),
795                    };
796                    Ok(TestCaseControllerRequest::RunDefaultCycle {
797                        responder: TestCaseControllerRunDefaultCycleResponder {
798                            control_handle: std::mem::ManuallyDrop::new(control_handle),
799                            tx_id: header.tx_id,
800                        },
801                    })
802                }
803                _ => Err(fidl::Error::UnknownOrdinal {
804                    ordinal: header.ordinal,
805                    protocol_name: <TestCaseControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
806                }),
807            }))
808            },
809        )
810    }
811}
812
813/// Tell Detect when to run test cases. Close the protocol to exit test mode.
814/// Running a test case (for example, with RunDefaultCycle() does not exit test
815/// mode when the test case completes.
816#[derive(Debug)]
817pub enum TestCaseControllerRequest {
818    /// Run a single default test case. Returns when the test case completes.
819    /// Returns an error if the test case exits abnormally.
820    RunDefaultCycle { responder: TestCaseControllerRunDefaultCycleResponder },
821}
822
823impl TestCaseControllerRequest {
824    #[allow(irrefutable_let_patterns)]
825    pub fn into_run_default_cycle(self) -> Option<(TestCaseControllerRunDefaultCycleResponder)> {
826        if let TestCaseControllerRequest::RunDefaultCycle { responder } = self {
827            Some((responder))
828        } else {
829            None
830        }
831    }
832
833    /// Name of the method defined in FIDL
834    pub fn method_name(&self) -> &'static str {
835        match *self {
836            TestCaseControllerRequest::RunDefaultCycle { .. } => "run_default_cycle",
837        }
838    }
839}
840
841#[derive(Debug, Clone)]
842pub struct TestCaseControllerControlHandle {
843    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
844}
845
846impl fidl::endpoints::ControlHandle for TestCaseControllerControlHandle {
847    fn shutdown(&self) {
848        self.inner.shutdown()
849    }
850    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
851        self.inner.shutdown_with_epitaph(status)
852    }
853
854    fn is_closed(&self) -> bool {
855        self.inner.channel().is_closed()
856    }
857    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
858        self.inner.channel().on_closed()
859    }
860
861    #[cfg(target_os = "fuchsia")]
862    fn signal_peer(
863        &self,
864        clear_mask: zx::Signals,
865        set_mask: zx::Signals,
866    ) -> Result<(), zx_status::Status> {
867        use fidl::Peered;
868        self.inner.channel().signal_peer(clear_mask, set_mask)
869    }
870}
871
872impl TestCaseControllerControlHandle {}
873
874#[must_use = "FIDL methods require a response to be sent"]
875#[derive(Debug)]
876pub struct TestCaseControllerRunDefaultCycleResponder {
877    control_handle: std::mem::ManuallyDrop<TestCaseControllerControlHandle>,
878    tx_id: u32,
879}
880
881/// Set the the channel to be shutdown (see [`TestCaseControllerControlHandle::shutdown`])
882/// if the responder is dropped without sending a response, so that the client
883/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
884impl std::ops::Drop for TestCaseControllerRunDefaultCycleResponder {
885    fn drop(&mut self) {
886        self.control_handle.shutdown();
887        // Safety: drops once, never accessed again
888        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
889    }
890}
891
892impl fidl::endpoints::Responder for TestCaseControllerRunDefaultCycleResponder {
893    type ControlHandle = TestCaseControllerControlHandle;
894
895    fn control_handle(&self) -> &TestCaseControllerControlHandle {
896        &self.control_handle
897    }
898
899    fn drop_without_shutdown(mut self) {
900        // Safety: drops once, never accessed again due to mem::forget
901        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
902        // Prevent Drop from running (which would shut down the channel)
903        std::mem::forget(self);
904    }
905}
906
907impl TestCaseControllerRunDefaultCycleResponder {
908    /// Sends a response to the FIDL transaction.
909    ///
910    /// Sets the channel to shutdown if an error occurs.
911    pub fn send(self) -> Result<(), fidl::Error> {
912        let _result = self.send_raw();
913        if _result.is_err() {
914            self.control_handle.shutdown();
915        }
916        self.drop_without_shutdown();
917        _result
918    }
919
920    /// Similar to "send" but does not shutdown the channel if an error occurs.
921    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
922        let _result = self.send_raw();
923        self.drop_without_shutdown();
924        _result
925    }
926
927    fn send_raw(&self) -> Result<(), fidl::Error> {
928        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
929            (),
930            self.tx_id,
931            0x6f41c0399849aea2,
932            fidl::encoding::DynamicFlags::empty(),
933        )
934    }
935}
936
937mod internal {
938    use super::*;
939
940    impl fidl::encoding::ResourceTypeMarker for DetectControllerEnterTestModeRequest {
941        type Borrowed<'a> = &'a mut Self;
942        fn take_or_borrow<'a>(
943            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
944        ) -> Self::Borrowed<'a> {
945            value
946        }
947    }
948
949    unsafe impl fidl::encoding::TypeMarker for DetectControllerEnterTestModeRequest {
950        type Owned = Self;
951
952        #[inline(always)]
953        fn inline_align(_context: fidl::encoding::Context) -> usize {
954            4
955        }
956
957        #[inline(always)]
958        fn inline_size(_context: fidl::encoding::Context) -> usize {
959            4
960        }
961    }
962
963    unsafe impl
964        fidl::encoding::Encode<
965            DetectControllerEnterTestModeRequest,
966            fidl::encoding::DefaultFuchsiaResourceDialect,
967        > for &mut DetectControllerEnterTestModeRequest
968    {
969        #[inline]
970        unsafe fn encode(
971            self,
972            encoder: &mut fidl::encoding::Encoder<
973                '_,
974                fidl::encoding::DefaultFuchsiaResourceDialect,
975            >,
976            offset: usize,
977            _depth: fidl::encoding::Depth,
978        ) -> fidl::Result<()> {
979            encoder.debug_check_bounds::<DetectControllerEnterTestModeRequest>(offset);
980            // Delegate to tuple encoding.
981            fidl::encoding::Encode::<DetectControllerEnterTestModeRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
982                (
983                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<TestCaseControllerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.test_controller),
984                ),
985                encoder, offset, _depth
986            )
987        }
988    }
989    unsafe impl<
990            T0: fidl::encoding::Encode<
991                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<TestCaseControllerMarker>>,
992                fidl::encoding::DefaultFuchsiaResourceDialect,
993            >,
994        >
995        fidl::encoding::Encode<
996            DetectControllerEnterTestModeRequest,
997            fidl::encoding::DefaultFuchsiaResourceDialect,
998        > for (T0,)
999    {
1000        #[inline]
1001        unsafe fn encode(
1002            self,
1003            encoder: &mut fidl::encoding::Encoder<
1004                '_,
1005                fidl::encoding::DefaultFuchsiaResourceDialect,
1006            >,
1007            offset: usize,
1008            depth: fidl::encoding::Depth,
1009        ) -> fidl::Result<()> {
1010            encoder.debug_check_bounds::<DetectControllerEnterTestModeRequest>(offset);
1011            // Zero out padding regions. There's no need to apply masks
1012            // because the unmasked parts will be overwritten by fields.
1013            // Write the fields.
1014            self.0.encode(encoder, offset + 0, depth)?;
1015            Ok(())
1016        }
1017    }
1018
1019    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1020        for DetectControllerEnterTestModeRequest
1021    {
1022        #[inline(always)]
1023        fn new_empty() -> Self {
1024            Self {
1025                test_controller: fidl::new_empty!(
1026                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<TestCaseControllerMarker>>,
1027                    fidl::encoding::DefaultFuchsiaResourceDialect
1028                ),
1029            }
1030        }
1031
1032        #[inline]
1033        unsafe fn decode(
1034            &mut self,
1035            decoder: &mut fidl::encoding::Decoder<
1036                '_,
1037                fidl::encoding::DefaultFuchsiaResourceDialect,
1038            >,
1039            offset: usize,
1040            _depth: fidl::encoding::Depth,
1041        ) -> fidl::Result<()> {
1042            decoder.debug_check_bounds::<Self>(offset);
1043            // Verify that padding bytes are zero.
1044            fidl::decode!(
1045                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<TestCaseControllerMarker>>,
1046                fidl::encoding::DefaultFuchsiaResourceDialect,
1047                &mut self.test_controller,
1048                decoder,
1049                offset + 0,
1050                _depth
1051            )?;
1052            Ok(())
1053        }
1054    }
1055}