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 ControllerControlHandle {
641    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
642        self.inner.shutdown_with_epitaph(status.into())
643    }
644}
645
646impl fidl::endpoints::ControlHandle for ControllerControlHandle {
647    fn shutdown(&self) {
648        self.inner.shutdown()
649    }
650
651    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
652        self.inner.shutdown_with_epitaph(status)
653    }
654
655    fn is_closed(&self) -> bool {
656        self.inner.channel().is_closed()
657    }
658    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
659        self.inner.channel().on_closed()
660    }
661
662    #[cfg(target_os = "fuchsia")]
663    fn signal_peer(
664        &self,
665        clear_mask: zx::Signals,
666        set_mask: zx::Signals,
667    ) -> Result<(), zx_status::Status> {
668        use fidl::Peered;
669        self.inner.channel().signal_peer(clear_mask, set_mask)
670    }
671}
672
673impl ControllerControlHandle {}
674
675#[must_use = "FIDL methods require a response to be sent"]
676#[derive(Debug)]
677pub struct ControllerSetupResponder {
678    control_handle: std::mem::ManuallyDrop<ControllerControlHandle>,
679    tx_id: u32,
680}
681
682/// Set the the channel to be shutdown (see [`ControllerControlHandle::shutdown`])
683/// if the responder is dropped without sending a response, so that the client
684/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
685impl std::ops::Drop for ControllerSetupResponder {
686    fn drop(&mut self) {
687        self.control_handle.shutdown();
688        // Safety: drops once, never accessed again
689        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
690    }
691}
692
693impl fidl::endpoints::Responder for ControllerSetupResponder {
694    type ControlHandle = ControllerControlHandle;
695
696    fn control_handle(&self) -> &ControllerControlHandle {
697        &self.control_handle
698    }
699
700    fn drop_without_shutdown(mut self) {
701        // Safety: drops once, never accessed again due to mem::forget
702        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
703        // Prevent Drop from running (which would shut down the channel)
704        std::mem::forget(self);
705    }
706}
707
708impl ControllerSetupResponder {
709    /// Sends a response to the FIDL transaction.
710    ///
711    /// Sets the channel to shutdown if an error occurs.
712    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
713        let _result = self.send_raw(result);
714        if _result.is_err() {
715            self.control_handle.shutdown();
716        }
717        self.drop_without_shutdown();
718        _result
719    }
720
721    /// Similar to "send" but does not shutdown the channel if an error occurs.
722    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
723        let _result = self.send_raw(result);
724        self.drop_without_shutdown();
725        _result
726    }
727
728    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
729        self.control_handle
730            .inner
731            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
732                result,
733                self.tx_id,
734                0x764c5a319190bb48,
735                fidl::encoding::DynamicFlags::empty(),
736            )
737    }
738}
739
740#[must_use = "FIDL methods require a response to be sent"]
741#[derive(Debug)]
742pub struct ControllerTestResponder {
743    control_handle: std::mem::ManuallyDrop<ControllerControlHandle>,
744    tx_id: u32,
745}
746
747/// Set the the channel to be shutdown (see [`ControllerControlHandle::shutdown`])
748/// if the responder is dropped without sending a response, so that the client
749/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
750impl std::ops::Drop for ControllerTestResponder {
751    fn drop(&mut self) {
752        self.control_handle.shutdown();
753        // Safety: drops once, never accessed again
754        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
755    }
756}
757
758impl fidl::endpoints::Responder for ControllerTestResponder {
759    type ControlHandle = ControllerControlHandle;
760
761    fn control_handle(&self) -> &ControllerControlHandle {
762        &self.control_handle
763    }
764
765    fn drop_without_shutdown(mut self) {
766        // Safety: drops once, never accessed again due to mem::forget
767        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
768        // Prevent Drop from running (which would shut down the channel)
769        std::mem::forget(self);
770    }
771}
772
773impl ControllerTestResponder {
774    /// Sends a response to the FIDL transaction.
775    ///
776    /// Sets the channel to shutdown if an error occurs.
777    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
778        let _result = self.send_raw(result);
779        if _result.is_err() {
780            self.control_handle.shutdown();
781        }
782        self.drop_without_shutdown();
783        _result
784    }
785
786    /// Similar to "send" but does not shutdown the channel if an error occurs.
787    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
788        let _result = self.send_raw(result);
789        self.drop_without_shutdown();
790        _result
791    }
792
793    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
794        self.control_handle
795            .inner
796            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
797                result,
798                self.tx_id,
799                0x3bbfd404364ff799,
800                fidl::encoding::DynamicFlags::empty(),
801            )
802    }
803}
804
805#[must_use = "FIDL methods require a response to be sent"]
806#[derive(Debug)]
807pub struct ControllerVerifyResponder {
808    control_handle: std::mem::ManuallyDrop<ControllerControlHandle>,
809    tx_id: u32,
810}
811
812/// Set the the channel to be shutdown (see [`ControllerControlHandle::shutdown`])
813/// if the responder is dropped without sending a response, so that the client
814/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
815impl std::ops::Drop for ControllerVerifyResponder {
816    fn drop(&mut self) {
817        self.control_handle.shutdown();
818        // Safety: drops once, never accessed again
819        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
820    }
821}
822
823impl fidl::endpoints::Responder for ControllerVerifyResponder {
824    type ControlHandle = ControllerControlHandle;
825
826    fn control_handle(&self) -> &ControllerControlHandle {
827        &self.control_handle
828    }
829
830    fn drop_without_shutdown(mut self) {
831        // Safety: drops once, never accessed again due to mem::forget
832        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
833        // Prevent Drop from running (which would shut down the channel)
834        std::mem::forget(self);
835    }
836}
837
838impl ControllerVerifyResponder {
839    /// Sends a response to the FIDL transaction.
840    ///
841    /// Sets the channel to shutdown if an error occurs.
842    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
843        let _result = self.send_raw(result);
844        if _result.is_err() {
845            self.control_handle.shutdown();
846        }
847        self.drop_without_shutdown();
848        _result
849    }
850
851    /// Similar to "send" but does not shutdown the channel if an error occurs.
852    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
853        let _result = self.send_raw(result);
854        self.drop_without_shutdown();
855        _result
856    }
857
858    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
859        self.control_handle
860            .inner
861            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
862                result,
863                self.tx_id,
864                0x83fd280ed680d48,
865                fidl::encoding::DynamicFlags::empty(),
866            )
867    }
868}
869
870mod internal {
871    use super::*;
872}