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