Skip to main content

fidl_fuchsia_blackout_test/
fidl_fuchsia_blackout_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_blackout_test__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct ControllerMarker;
16
17impl fidl::endpoints::ProtocolMarker for ControllerMarker {
18    type Proxy = ControllerProxy;
19    type RequestStream = ControllerRequestStream;
20    #[cfg(target_os = "fuchsia")]
21    type SynchronousProxy = ControllerSynchronousProxy;
22
23    const DEBUG_NAME: &'static str = "fuchsia.blackout.test.Controller";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for ControllerMarker {}
26pub type ControllerSetupResult = Result<(), i32>;
27pub type ControllerTestResult = Result<(), i32>;
28pub type ControllerVerifyResult = Result<(), i32>;
29
30pub trait ControllerProxyInterface: Send + Sync {
31    type SetupResponseFut: std::future::Future<Output = Result<ControllerSetupResult, fidl::Error>>
32        + Send;
33    fn r#setup(
34        &self,
35        device_label: &str,
36        device_path: Option<&str>,
37        seed: u64,
38    ) -> Self::SetupResponseFut;
39    type TestResponseFut: std::future::Future<Output = Result<ControllerTestResult, fidl::Error>>
40        + Send;
41    fn r#test(
42        &self,
43        device_label: &str,
44        device_path: Option<&str>,
45        seed: u64,
46        duration: u64,
47    ) -> Self::TestResponseFut;
48    type VerifyResponseFut: std::future::Future<Output = Result<ControllerVerifyResult, fidl::Error>>
49        + Send;
50    fn r#verify(
51        &self,
52        device_label: &str,
53        device_path: Option<&str>,
54        seed: u64,
55    ) -> Self::VerifyResponseFut;
56}
57#[derive(Debug)]
58#[cfg(target_os = "fuchsia")]
59pub struct ControllerSynchronousProxy {
60    client: fidl::client::sync::Client,
61}
62
63#[cfg(target_os = "fuchsia")]
64impl fidl::endpoints::SynchronousProxy for ControllerSynchronousProxy {
65    type Proxy = ControllerProxy;
66    type Protocol = ControllerMarker;
67
68    fn from_channel(inner: fidl::Channel) -> Self {
69        Self::new(inner)
70    }
71
72    fn into_channel(self) -> fidl::Channel {
73        self.client.into_channel()
74    }
75
76    fn as_channel(&self) -> &fidl::Channel {
77        self.client.as_channel()
78    }
79}
80
81#[cfg(target_os = "fuchsia")]
82impl ControllerSynchronousProxy {
83    pub fn new(channel: fidl::Channel) -> Self {
84        Self { client: fidl::client::sync::Client::new(channel) }
85    }
86
87    pub fn into_channel(self) -> fidl::Channel {
88        self.client.into_channel()
89    }
90
91    /// Waits until an event arrives and returns it. It is safe for other
92    /// threads to make concurrent requests while waiting for an event.
93    pub fn wait_for_event(
94        &self,
95        deadline: zx::MonotonicInstant,
96    ) -> Result<ControllerEvent, fidl::Error> {
97        ControllerEvent::decode(self.client.wait_for_event::<ControllerMarker>(deadline)?)
98    }
99
100    /// Run the setup step for this test. Often, this involves formatting the filesystem of choice
101    /// onto the block device, and perhaps setting up a base of files to work with.
102    pub fn r#setup(
103        &self,
104        mut device_label: &str,
105        mut device_path: Option<&str>,
106        mut seed: u64,
107        ___deadline: zx::MonotonicInstant,
108    ) -> Result<ControllerSetupResult, fidl::Error> {
109        let _response = self.client.send_query::<
110            ControllerSetupRequest,
111            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
112            ControllerMarker,
113        >(
114            (device_label, device_path, seed,),
115            0x764c5a319190bb48,
116            fidl::encoding::DynamicFlags::empty(),
117            ___deadline,
118        )?;
119        Ok(_response.map(|x| x))
120    }
121
122    /// Run the test step for this test. This kicks off the load generation algorithm for this
123    /// test, which will run indefinitely. It's expected that this load will be interrupted by a
124    /// power cycle. If the provided duration is non-zero, this protocol will return after
125    /// approximately that amount of time, but the load will continue to run. If the duration
126    /// provided is zero, then the test will return when it's done, which for a lot of normal
127    /// blackout tests might be never.
128    pub fn r#test(
129        &self,
130        mut device_label: &str,
131        mut device_path: Option<&str>,
132        mut seed: u64,
133        mut duration: u64,
134        ___deadline: zx::MonotonicInstant,
135    ) -> Result<ControllerTestResult, fidl::Error> {
136        let _response = self.client.send_query::<
137            ControllerTestRequest,
138            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
139            ControllerMarker,
140        >(
141            (device_label, device_path, seed, duration,),
142            0x3bbfd404364ff799,
143            fidl::encoding::DynamicFlags::empty(),
144            ___deadline,
145        )?;
146        Ok(_response.map(|x| x))
147    }
148
149    /// Run the verify step for this test. Most of the time it involves running fsck on the block
150    /// device and returning the result.
151    pub fn r#verify(
152        &self,
153        mut device_label: &str,
154        mut device_path: Option<&str>,
155        mut seed: u64,
156        ___deadline: zx::MonotonicInstant,
157    ) -> Result<ControllerVerifyResult, fidl::Error> {
158        let _response = self.client.send_query::<
159            ControllerVerifyRequest,
160            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
161            ControllerMarker,
162        >(
163            (device_label, device_path, seed,),
164            0x83fd280ed680d48,
165            fidl::encoding::DynamicFlags::empty(),
166            ___deadline,
167        )?;
168        Ok(_response.map(|x| x))
169    }
170}
171
172#[cfg(target_os = "fuchsia")]
173impl From<ControllerSynchronousProxy> for zx::NullableHandle {
174    fn from(value: ControllerSynchronousProxy) -> Self {
175        value.into_channel().into()
176    }
177}
178
179#[cfg(target_os = "fuchsia")]
180impl From<fidl::Channel> for ControllerSynchronousProxy {
181    fn from(value: fidl::Channel) -> Self {
182        Self::new(value)
183    }
184}
185
186#[cfg(target_os = "fuchsia")]
187impl fidl::endpoints::FromClient for ControllerSynchronousProxy {
188    type Protocol = ControllerMarker;
189
190    fn from_client(value: fidl::endpoints::ClientEnd<ControllerMarker>) -> Self {
191        Self::new(value.into_channel())
192    }
193}
194
195#[derive(Debug, Clone)]
196pub struct ControllerProxy {
197    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
198}
199
200impl fidl::endpoints::Proxy for ControllerProxy {
201    type Protocol = ControllerMarker;
202
203    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
204        Self::new(inner)
205    }
206
207    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
208        self.client.into_channel().map_err(|client| Self { client })
209    }
210
211    fn as_channel(&self) -> &::fidl::AsyncChannel {
212        self.client.as_channel()
213    }
214}
215
216impl ControllerProxy {
217    /// Create a new Proxy for fuchsia.blackout.test/Controller.
218    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
219        let protocol_name = <ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
220        Self { client: fidl::client::Client::new(channel, protocol_name) }
221    }
222
223    /// Get a Stream of events from the remote end of the protocol.
224    ///
225    /// # Panics
226    ///
227    /// Panics if the event stream was already taken.
228    pub fn take_event_stream(&self) -> ControllerEventStream {
229        ControllerEventStream { event_receiver: self.client.take_event_receiver() }
230    }
231
232    /// Run the setup step for this test. Often, this involves formatting the filesystem of choice
233    /// onto the block device, and perhaps setting up a base of files to work with.
234    pub fn r#setup(
235        &self,
236        mut device_label: &str,
237        mut device_path: Option<&str>,
238        mut seed: u64,
239    ) -> fidl::client::QueryResponseFut<
240        ControllerSetupResult,
241        fidl::encoding::DefaultFuchsiaResourceDialect,
242    > {
243        ControllerProxyInterface::r#setup(self, device_label, device_path, seed)
244    }
245
246    /// Run the test step for this test. This kicks off the load generation algorithm for this
247    /// test, which will run indefinitely. It's expected that this load will be interrupted by a
248    /// power cycle. If the provided duration is non-zero, this protocol will return after
249    /// approximately that amount of time, but the load will continue to run. If the duration
250    /// provided is zero, then the test will return when it's done, which for a lot of normal
251    /// blackout tests might be never.
252    pub fn r#test(
253        &self,
254        mut device_label: &str,
255        mut device_path: Option<&str>,
256        mut seed: u64,
257        mut duration: u64,
258    ) -> fidl::client::QueryResponseFut<
259        ControllerTestResult,
260        fidl::encoding::DefaultFuchsiaResourceDialect,
261    > {
262        ControllerProxyInterface::r#test(self, device_label, device_path, seed, duration)
263    }
264
265    /// Run the verify step for this test. Most of the time it involves running fsck on the block
266    /// device and returning the result.
267    pub fn r#verify(
268        &self,
269        mut device_label: &str,
270        mut device_path: Option<&str>,
271        mut seed: u64,
272    ) -> fidl::client::QueryResponseFut<
273        ControllerVerifyResult,
274        fidl::encoding::DefaultFuchsiaResourceDialect,
275    > {
276        ControllerProxyInterface::r#verify(self, device_label, device_path, seed)
277    }
278}
279
280impl ControllerProxyInterface for ControllerProxy {
281    type SetupResponseFut = fidl::client::QueryResponseFut<
282        ControllerSetupResult,
283        fidl::encoding::DefaultFuchsiaResourceDialect,
284    >;
285    fn r#setup(
286        &self,
287        mut device_label: &str,
288        mut device_path: Option<&str>,
289        mut seed: u64,
290    ) -> Self::SetupResponseFut {
291        fn _decode(
292            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
293        ) -> Result<ControllerSetupResult, fidl::Error> {
294            let _response = fidl::client::decode_transaction_body::<
295                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
296                fidl::encoding::DefaultFuchsiaResourceDialect,
297                0x764c5a319190bb48,
298            >(_buf?)?;
299            Ok(_response.map(|x| x))
300        }
301        self.client.send_query_and_decode::<ControllerSetupRequest, ControllerSetupResult>(
302            (device_label, device_path, seed),
303            0x764c5a319190bb48,
304            fidl::encoding::DynamicFlags::empty(),
305            _decode,
306        )
307    }
308
309    type TestResponseFut = fidl::client::QueryResponseFut<
310        ControllerTestResult,
311        fidl::encoding::DefaultFuchsiaResourceDialect,
312    >;
313    fn r#test(
314        &self,
315        mut device_label: &str,
316        mut device_path: Option<&str>,
317        mut seed: u64,
318        mut duration: u64,
319    ) -> Self::TestResponseFut {
320        fn _decode(
321            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
322        ) -> Result<ControllerTestResult, fidl::Error> {
323            let _response = fidl::client::decode_transaction_body::<
324                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
325                fidl::encoding::DefaultFuchsiaResourceDialect,
326                0x3bbfd404364ff799,
327            >(_buf?)?;
328            Ok(_response.map(|x| x))
329        }
330        self.client.send_query_and_decode::<ControllerTestRequest, ControllerTestResult>(
331            (device_label, device_path, seed, duration),
332            0x3bbfd404364ff799,
333            fidl::encoding::DynamicFlags::empty(),
334            _decode,
335        )
336    }
337
338    type VerifyResponseFut = fidl::client::QueryResponseFut<
339        ControllerVerifyResult,
340        fidl::encoding::DefaultFuchsiaResourceDialect,
341    >;
342    fn r#verify(
343        &self,
344        mut device_label: &str,
345        mut device_path: Option<&str>,
346        mut seed: u64,
347    ) -> Self::VerifyResponseFut {
348        fn _decode(
349            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
350        ) -> Result<ControllerVerifyResult, fidl::Error> {
351            let _response = fidl::client::decode_transaction_body::<
352                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
353                fidl::encoding::DefaultFuchsiaResourceDialect,
354                0x83fd280ed680d48,
355            >(_buf?)?;
356            Ok(_response.map(|x| x))
357        }
358        self.client.send_query_and_decode::<ControllerVerifyRequest, ControllerVerifyResult>(
359            (device_label, device_path, seed),
360            0x83fd280ed680d48,
361            fidl::encoding::DynamicFlags::empty(),
362            _decode,
363        )
364    }
365}
366
367pub struct ControllerEventStream {
368    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
369}
370
371impl std::marker::Unpin for ControllerEventStream {}
372
373impl futures::stream::FusedStream for ControllerEventStream {
374    fn is_terminated(&self) -> bool {
375        self.event_receiver.is_terminated()
376    }
377}
378
379impl futures::Stream for ControllerEventStream {
380    type Item = Result<ControllerEvent, fidl::Error>;
381
382    fn poll_next(
383        mut self: std::pin::Pin<&mut Self>,
384        cx: &mut std::task::Context<'_>,
385    ) -> std::task::Poll<Option<Self::Item>> {
386        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
387            &mut self.event_receiver,
388            cx
389        )?) {
390            Some(buf) => std::task::Poll::Ready(Some(ControllerEvent::decode(buf))),
391            None => std::task::Poll::Ready(None),
392        }
393    }
394}
395
396#[derive(Debug)]
397pub enum ControllerEvent {}
398
399impl ControllerEvent {
400    /// Decodes a message buffer as a [`ControllerEvent`].
401    fn decode(
402        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
403    ) -> Result<ControllerEvent, fidl::Error> {
404        let (bytes, _handles) = buf.split_mut();
405        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
406        debug_assert_eq!(tx_header.tx_id, 0);
407        match tx_header.ordinal {
408            _ => Err(fidl::Error::UnknownOrdinal {
409                ordinal: tx_header.ordinal,
410                protocol_name: <ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
411            }),
412        }
413    }
414}
415
416/// A Stream of incoming requests for fuchsia.blackout.test/Controller.
417pub struct ControllerRequestStream {
418    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
419    is_terminated: bool,
420}
421
422impl std::marker::Unpin for ControllerRequestStream {}
423
424impl futures::stream::FusedStream for ControllerRequestStream {
425    fn is_terminated(&self) -> bool {
426        self.is_terminated
427    }
428}
429
430impl fidl::endpoints::RequestStream for ControllerRequestStream {
431    type Protocol = ControllerMarker;
432    type ControlHandle = ControllerControlHandle;
433
434    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
435        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
436    }
437
438    fn control_handle(&self) -> Self::ControlHandle {
439        ControllerControlHandle { inner: self.inner.clone() }
440    }
441
442    fn into_inner(
443        self,
444    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
445    {
446        (self.inner, self.is_terminated)
447    }
448
449    fn from_inner(
450        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
451        is_terminated: bool,
452    ) -> Self {
453        Self { inner, is_terminated }
454    }
455}
456
457impl futures::Stream for ControllerRequestStream {
458    type Item = Result<ControllerRequest, fidl::Error>;
459
460    fn poll_next(
461        mut self: std::pin::Pin<&mut Self>,
462        cx: &mut std::task::Context<'_>,
463    ) -> std::task::Poll<Option<Self::Item>> {
464        let this = &mut *self;
465        if this.inner.check_shutdown(cx) {
466            this.is_terminated = true;
467            return std::task::Poll::Ready(None);
468        }
469        if this.is_terminated {
470            panic!("polled ControllerRequestStream after completion");
471        }
472        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
473            |bytes, handles| {
474                match this.inner.channel().read_etc(cx, bytes, handles) {
475                    std::task::Poll::Ready(Ok(())) => {}
476                    std::task::Poll::Pending => return std::task::Poll::Pending,
477                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
478                        this.is_terminated = true;
479                        return std::task::Poll::Ready(None);
480                    }
481                    std::task::Poll::Ready(Err(e)) => {
482                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
483                            e.into(),
484                        ))));
485                    }
486                }
487
488                // A message has been received from the channel
489                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
490
491                std::task::Poll::Ready(Some(match header.ordinal {
492                    0x764c5a319190bb48 => {
493                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
494                        let mut req = fidl::new_empty!(
495                            ControllerSetupRequest,
496                            fidl::encoding::DefaultFuchsiaResourceDialect
497                        );
498                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControllerSetupRequest>(&header, _body_bytes, handles, &mut req)?;
499                        let control_handle = ControllerControlHandle { inner: this.inner.clone() };
500                        Ok(ControllerRequest::Setup {
501                            device_label: req.device_label,
502                            device_path: req.device_path,
503                            seed: req.seed,
504
505                            responder: ControllerSetupResponder {
506                                control_handle: std::mem::ManuallyDrop::new(control_handle),
507                                tx_id: header.tx_id,
508                            },
509                        })
510                    }
511                    0x3bbfd404364ff799 => {
512                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
513                        let mut req = fidl::new_empty!(
514                            ControllerTestRequest,
515                            fidl::encoding::DefaultFuchsiaResourceDialect
516                        );
517                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControllerTestRequest>(&header, _body_bytes, handles, &mut req)?;
518                        let control_handle = ControllerControlHandle { inner: this.inner.clone() };
519                        Ok(ControllerRequest::Test {
520                            device_label: req.device_label,
521                            device_path: req.device_path,
522                            seed: req.seed,
523                            duration: req.duration,
524
525                            responder: ControllerTestResponder {
526                                control_handle: std::mem::ManuallyDrop::new(control_handle),
527                                tx_id: header.tx_id,
528                            },
529                        })
530                    }
531                    0x83fd280ed680d48 => {
532                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
533                        let mut req = fidl::new_empty!(
534                            ControllerVerifyRequest,
535                            fidl::encoding::DefaultFuchsiaResourceDialect
536                        );
537                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControllerVerifyRequest>(&header, _body_bytes, handles, &mut req)?;
538                        let control_handle = ControllerControlHandle { inner: this.inner.clone() };
539                        Ok(ControllerRequest::Verify {
540                            device_label: req.device_label,
541                            device_path: req.device_path,
542                            seed: req.seed,
543
544                            responder: ControllerVerifyResponder {
545                                control_handle: std::mem::ManuallyDrop::new(control_handle),
546                                tx_id: header.tx_id,
547                            },
548                        })
549                    }
550                    _ => Err(fidl::Error::UnknownOrdinal {
551                        ordinal: header.ordinal,
552                        protocol_name:
553                            <ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
554                    }),
555                }))
556            },
557        )
558    }
559}
560
561/// Protocol to control the target-side component of power failure tests for the filesystems.
562#[derive(Debug)]
563pub enum ControllerRequest {
564    /// Run the setup step for this test. Often, this involves formatting the filesystem of choice
565    /// onto the block device, and perhaps setting up a base of files to work with.
566    Setup {
567        device_label: String,
568        device_path: Option<String>,
569        seed: u64,
570        responder: ControllerSetupResponder,
571    },
572    /// Run the test step for this test. This kicks off the load generation algorithm for this
573    /// test, which will run indefinitely. It's expected that this load will be interrupted by a
574    /// power cycle. If the provided duration is non-zero, this protocol will return after
575    /// approximately that amount of time, but the load will continue to run. If the duration
576    /// provided is zero, then the test will return when it's done, which for a lot of normal
577    /// blackout tests might be never.
578    Test {
579        device_label: String,
580        device_path: Option<String>,
581        seed: u64,
582        duration: u64,
583        responder: ControllerTestResponder,
584    },
585    /// Run the verify step for this test. Most of the time it involves running fsck on the block
586    /// device and returning the result.
587    Verify {
588        device_label: String,
589        device_path: Option<String>,
590        seed: u64,
591        responder: ControllerVerifyResponder,
592    },
593}
594
595impl ControllerRequest {
596    #[allow(irrefutable_let_patterns)]
597    pub fn into_setup(self) -> Option<(String, Option<String>, u64, ControllerSetupResponder)> {
598        if let ControllerRequest::Setup { device_label, device_path, seed, responder } = self {
599            Some((device_label, device_path, seed, responder))
600        } else {
601            None
602        }
603    }
604
605    #[allow(irrefutable_let_patterns)]
606    pub fn into_test(self) -> Option<(String, Option<String>, u64, u64, ControllerTestResponder)> {
607        if let ControllerRequest::Test { device_label, device_path, seed, duration, responder } =
608            self
609        {
610            Some((device_label, device_path, seed, duration, responder))
611        } else {
612            None
613        }
614    }
615
616    #[allow(irrefutable_let_patterns)]
617    pub fn into_verify(self) -> Option<(String, Option<String>, u64, ControllerVerifyResponder)> {
618        if let ControllerRequest::Verify { device_label, device_path, seed, responder } = self {
619            Some((device_label, device_path, seed, responder))
620        } else {
621            None
622        }
623    }
624
625    /// Name of the method defined in FIDL
626    pub fn method_name(&self) -> &'static str {
627        match *self {
628            ControllerRequest::Setup { .. } => "setup",
629            ControllerRequest::Test { .. } => "test",
630            ControllerRequest::Verify { .. } => "verify",
631        }
632    }
633}
634
635#[derive(Debug, Clone)]
636pub struct ControllerControlHandle {
637    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
638}
639
640impl fidl::endpoints::ControlHandle for ControllerControlHandle {
641    fn shutdown(&self) {
642        self.inner.shutdown()
643    }
644
645    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
646        self.inner.shutdown_with_epitaph(status)
647    }
648
649    fn is_closed(&self) -> bool {
650        self.inner.channel().is_closed()
651    }
652    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
653        self.inner.channel().on_closed()
654    }
655
656    #[cfg(target_os = "fuchsia")]
657    fn signal_peer(
658        &self,
659        clear_mask: zx::Signals,
660        set_mask: zx::Signals,
661    ) -> Result<(), zx_status::Status> {
662        use fidl::Peered;
663        self.inner.channel().signal_peer(clear_mask, set_mask)
664    }
665}
666
667impl ControllerControlHandle {}
668
669#[must_use = "FIDL methods require a response to be sent"]
670#[derive(Debug)]
671pub struct ControllerSetupResponder {
672    control_handle: std::mem::ManuallyDrop<ControllerControlHandle>,
673    tx_id: u32,
674}
675
676/// Set the the channel to be shutdown (see [`ControllerControlHandle::shutdown`])
677/// if the responder is dropped without sending a response, so that the client
678/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
679impl std::ops::Drop for ControllerSetupResponder {
680    fn drop(&mut self) {
681        self.control_handle.shutdown();
682        // Safety: drops once, never accessed again
683        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
684    }
685}
686
687impl fidl::endpoints::Responder for ControllerSetupResponder {
688    type ControlHandle = ControllerControlHandle;
689
690    fn control_handle(&self) -> &ControllerControlHandle {
691        &self.control_handle
692    }
693
694    fn drop_without_shutdown(mut self) {
695        // Safety: drops once, never accessed again due to mem::forget
696        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
697        // Prevent Drop from running (which would shut down the channel)
698        std::mem::forget(self);
699    }
700}
701
702impl ControllerSetupResponder {
703    /// Sends a response to the FIDL transaction.
704    ///
705    /// Sets the channel to shutdown if an error occurs.
706    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
707        let _result = self.send_raw(result);
708        if _result.is_err() {
709            self.control_handle.shutdown();
710        }
711        self.drop_without_shutdown();
712        _result
713    }
714
715    /// Similar to "send" but does not shutdown the channel if an error occurs.
716    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
717        let _result = self.send_raw(result);
718        self.drop_without_shutdown();
719        _result
720    }
721
722    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
723        self.control_handle
724            .inner
725            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
726                result,
727                self.tx_id,
728                0x764c5a319190bb48,
729                fidl::encoding::DynamicFlags::empty(),
730            )
731    }
732}
733
734#[must_use = "FIDL methods require a response to be sent"]
735#[derive(Debug)]
736pub struct ControllerTestResponder {
737    control_handle: std::mem::ManuallyDrop<ControllerControlHandle>,
738    tx_id: u32,
739}
740
741/// Set the the channel to be shutdown (see [`ControllerControlHandle::shutdown`])
742/// if the responder is dropped without sending a response, so that the client
743/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
744impl std::ops::Drop for ControllerTestResponder {
745    fn drop(&mut self) {
746        self.control_handle.shutdown();
747        // Safety: drops once, never accessed again
748        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
749    }
750}
751
752impl fidl::endpoints::Responder for ControllerTestResponder {
753    type ControlHandle = ControllerControlHandle;
754
755    fn control_handle(&self) -> &ControllerControlHandle {
756        &self.control_handle
757    }
758
759    fn drop_without_shutdown(mut self) {
760        // Safety: drops once, never accessed again due to mem::forget
761        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
762        // Prevent Drop from running (which would shut down the channel)
763        std::mem::forget(self);
764    }
765}
766
767impl ControllerTestResponder {
768    /// Sends a response to the FIDL transaction.
769    ///
770    /// Sets the channel to shutdown if an error occurs.
771    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
772        let _result = self.send_raw(result);
773        if _result.is_err() {
774            self.control_handle.shutdown();
775        }
776        self.drop_without_shutdown();
777        _result
778    }
779
780    /// Similar to "send" but does not shutdown the channel if an error occurs.
781    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
782        let _result = self.send_raw(result);
783        self.drop_without_shutdown();
784        _result
785    }
786
787    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
788        self.control_handle
789            .inner
790            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
791                result,
792                self.tx_id,
793                0x3bbfd404364ff799,
794                fidl::encoding::DynamicFlags::empty(),
795            )
796    }
797}
798
799#[must_use = "FIDL methods require a response to be sent"]
800#[derive(Debug)]
801pub struct ControllerVerifyResponder {
802    control_handle: std::mem::ManuallyDrop<ControllerControlHandle>,
803    tx_id: u32,
804}
805
806/// Set the the channel to be shutdown (see [`ControllerControlHandle::shutdown`])
807/// if the responder is dropped without sending a response, so that the client
808/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
809impl std::ops::Drop for ControllerVerifyResponder {
810    fn drop(&mut self) {
811        self.control_handle.shutdown();
812        // Safety: drops once, never accessed again
813        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
814    }
815}
816
817impl fidl::endpoints::Responder for ControllerVerifyResponder {
818    type ControlHandle = ControllerControlHandle;
819
820    fn control_handle(&self) -> &ControllerControlHandle {
821        &self.control_handle
822    }
823
824    fn drop_without_shutdown(mut self) {
825        // Safety: drops once, never accessed again due to mem::forget
826        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
827        // Prevent Drop from running (which would shut down the channel)
828        std::mem::forget(self);
829    }
830}
831
832impl ControllerVerifyResponder {
833    /// Sends a response to the FIDL transaction.
834    ///
835    /// Sets the channel to shutdown if an error occurs.
836    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
837        let _result = self.send_raw(result);
838        if _result.is_err() {
839            self.control_handle.shutdown();
840        }
841        self.drop_without_shutdown();
842        _result
843    }
844
845    /// Similar to "send" but does not shutdown the channel if an error occurs.
846    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
847        let _result = self.send_raw(result);
848        self.drop_without_shutdown();
849        _result
850    }
851
852    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
853        self.control_handle
854            .inner
855            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
856                result,
857                self.tx_id,
858                0x83fd280ed680d48,
859                fidl::encoding::DynamicFlags::empty(),
860            )
861    }
862}
863
864mod internal {
865    use super::*;
866}