Skip to main content

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