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