fidl_fuchsia_testing_sl4f/
fidl_fuchsia_testing_sl4f.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_testing_sl4f_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct FacadeProviderExecuteRequest {
16    pub facade: String,
17    pub command: String,
18    pub params_blob: fidl::Vmo,
19}
20
21impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
22    for FacadeProviderExecuteRequest
23{
24}
25
26#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
27pub struct FacadeProviderExecuteResponse {
28    pub result_blob: Option<fidl::Vmo>,
29    pub error: Option<String>,
30}
31
32impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
33    for FacadeProviderExecuteResponse
34{
35}
36
37#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
38pub struct FacadeProviderGetFacadesRequest {
39    pub iterator: fidl::endpoints::ServerEnd<FacadeIteratorMarker>,
40}
41
42impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
43    for FacadeProviderGetFacadesRequest
44{
45}
46
47#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
48pub struct FacadeIteratorMarker;
49
50impl fidl::endpoints::ProtocolMarker for FacadeIteratorMarker {
51    type Proxy = FacadeIteratorProxy;
52    type RequestStream = FacadeIteratorRequestStream;
53    #[cfg(target_os = "fuchsia")]
54    type SynchronousProxy = FacadeIteratorSynchronousProxy;
55
56    const DEBUG_NAME: &'static str = "(anonymous) FacadeIterator";
57}
58
59pub trait FacadeIteratorProxyInterface: Send + Sync {
60    type GetNextResponseFut: std::future::Future<Output = Result<Vec<String>, fidl::Error>> + Send;
61    fn r#get_next(&self) -> Self::GetNextResponseFut;
62}
63#[derive(Debug)]
64#[cfg(target_os = "fuchsia")]
65pub struct FacadeIteratorSynchronousProxy {
66    client: fidl::client::sync::Client,
67}
68
69#[cfg(target_os = "fuchsia")]
70impl fidl::endpoints::SynchronousProxy for FacadeIteratorSynchronousProxy {
71    type Proxy = FacadeIteratorProxy;
72    type Protocol = FacadeIteratorMarker;
73
74    fn from_channel(inner: fidl::Channel) -> Self {
75        Self::new(inner)
76    }
77
78    fn into_channel(self) -> fidl::Channel {
79        self.client.into_channel()
80    }
81
82    fn as_channel(&self) -> &fidl::Channel {
83        self.client.as_channel()
84    }
85}
86
87#[cfg(target_os = "fuchsia")]
88impl FacadeIteratorSynchronousProxy {
89    pub fn new(channel: fidl::Channel) -> Self {
90        let protocol_name = <FacadeIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
91        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
92    }
93
94    pub fn into_channel(self) -> fidl::Channel {
95        self.client.into_channel()
96    }
97
98    /// Waits until an event arrives and returns it. It is safe for other
99    /// threads to make concurrent requests while waiting for an event.
100    pub fn wait_for_event(
101        &self,
102        deadline: zx::MonotonicInstant,
103    ) -> Result<FacadeIteratorEvent, fidl::Error> {
104        FacadeIteratorEvent::decode(self.client.wait_for_event(deadline)?)
105    }
106
107    pub fn r#get_next(
108        &self,
109        ___deadline: zx::MonotonicInstant,
110    ) -> Result<Vec<String>, fidl::Error> {
111        let _response =
112            self.client.send_query::<fidl::encoding::EmptyPayload, FacadeIteratorGetNextResponse>(
113                (),
114                0x1d22c13a17449134,
115                fidl::encoding::DynamicFlags::empty(),
116                ___deadline,
117            )?;
118        Ok(_response.facades)
119    }
120}
121
122#[cfg(target_os = "fuchsia")]
123impl From<FacadeIteratorSynchronousProxy> for zx::Handle {
124    fn from(value: FacadeIteratorSynchronousProxy) -> Self {
125        value.into_channel().into()
126    }
127}
128
129#[cfg(target_os = "fuchsia")]
130impl From<fidl::Channel> for FacadeIteratorSynchronousProxy {
131    fn from(value: fidl::Channel) -> Self {
132        Self::new(value)
133    }
134}
135
136#[derive(Debug, Clone)]
137pub struct FacadeIteratorProxy {
138    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
139}
140
141impl fidl::endpoints::Proxy for FacadeIteratorProxy {
142    type Protocol = FacadeIteratorMarker;
143
144    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
145        Self::new(inner)
146    }
147
148    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
149        self.client.into_channel().map_err(|client| Self { client })
150    }
151
152    fn as_channel(&self) -> &::fidl::AsyncChannel {
153        self.client.as_channel()
154    }
155}
156
157impl FacadeIteratorProxy {
158    /// Create a new Proxy for fuchsia.testing.sl4f/FacadeIterator.
159    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
160        let protocol_name = <FacadeIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
161        Self { client: fidl::client::Client::new(channel, protocol_name) }
162    }
163
164    /// Get a Stream of events from the remote end of the protocol.
165    ///
166    /// # Panics
167    ///
168    /// Panics if the event stream was already taken.
169    pub fn take_event_stream(&self) -> FacadeIteratorEventStream {
170        FacadeIteratorEventStream { event_receiver: self.client.take_event_receiver() }
171    }
172
173    pub fn r#get_next(
174        &self,
175    ) -> fidl::client::QueryResponseFut<Vec<String>, fidl::encoding::DefaultFuchsiaResourceDialect>
176    {
177        FacadeIteratorProxyInterface::r#get_next(self)
178    }
179}
180
181impl FacadeIteratorProxyInterface for FacadeIteratorProxy {
182    type GetNextResponseFut =
183        fidl::client::QueryResponseFut<Vec<String>, fidl::encoding::DefaultFuchsiaResourceDialect>;
184    fn r#get_next(&self) -> Self::GetNextResponseFut {
185        fn _decode(
186            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
187        ) -> Result<Vec<String>, fidl::Error> {
188            let _response = fidl::client::decode_transaction_body::<
189                FacadeIteratorGetNextResponse,
190                fidl::encoding::DefaultFuchsiaResourceDialect,
191                0x1d22c13a17449134,
192            >(_buf?)?;
193            Ok(_response.facades)
194        }
195        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<String>>(
196            (),
197            0x1d22c13a17449134,
198            fidl::encoding::DynamicFlags::empty(),
199            _decode,
200        )
201    }
202}
203
204pub struct FacadeIteratorEventStream {
205    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
206}
207
208impl std::marker::Unpin for FacadeIteratorEventStream {}
209
210impl futures::stream::FusedStream for FacadeIteratorEventStream {
211    fn is_terminated(&self) -> bool {
212        self.event_receiver.is_terminated()
213    }
214}
215
216impl futures::Stream for FacadeIteratorEventStream {
217    type Item = Result<FacadeIteratorEvent, fidl::Error>;
218
219    fn poll_next(
220        mut self: std::pin::Pin<&mut Self>,
221        cx: &mut std::task::Context<'_>,
222    ) -> std::task::Poll<Option<Self::Item>> {
223        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
224            &mut self.event_receiver,
225            cx
226        )?) {
227            Some(buf) => std::task::Poll::Ready(Some(FacadeIteratorEvent::decode(buf))),
228            None => std::task::Poll::Ready(None),
229        }
230    }
231}
232
233#[derive(Debug)]
234pub enum FacadeIteratorEvent {}
235
236impl FacadeIteratorEvent {
237    /// Decodes a message buffer as a [`FacadeIteratorEvent`].
238    fn decode(
239        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
240    ) -> Result<FacadeIteratorEvent, fidl::Error> {
241        let (bytes, _handles) = buf.split_mut();
242        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
243        debug_assert_eq!(tx_header.tx_id, 0);
244        match tx_header.ordinal {
245            _ => Err(fidl::Error::UnknownOrdinal {
246                ordinal: tx_header.ordinal,
247                protocol_name:
248                    <FacadeIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
249            }),
250        }
251    }
252}
253
254/// A Stream of incoming requests for fuchsia.testing.sl4f/FacadeIterator.
255pub struct FacadeIteratorRequestStream {
256    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
257    is_terminated: bool,
258}
259
260impl std::marker::Unpin for FacadeIteratorRequestStream {}
261
262impl futures::stream::FusedStream for FacadeIteratorRequestStream {
263    fn is_terminated(&self) -> bool {
264        self.is_terminated
265    }
266}
267
268impl fidl::endpoints::RequestStream for FacadeIteratorRequestStream {
269    type Protocol = FacadeIteratorMarker;
270    type ControlHandle = FacadeIteratorControlHandle;
271
272    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
273        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
274    }
275
276    fn control_handle(&self) -> Self::ControlHandle {
277        FacadeIteratorControlHandle { inner: self.inner.clone() }
278    }
279
280    fn into_inner(
281        self,
282    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
283    {
284        (self.inner, self.is_terminated)
285    }
286
287    fn from_inner(
288        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
289        is_terminated: bool,
290    ) -> Self {
291        Self { inner, is_terminated }
292    }
293}
294
295impl futures::Stream for FacadeIteratorRequestStream {
296    type Item = Result<FacadeIteratorRequest, fidl::Error>;
297
298    fn poll_next(
299        mut self: std::pin::Pin<&mut Self>,
300        cx: &mut std::task::Context<'_>,
301    ) -> std::task::Poll<Option<Self::Item>> {
302        let this = &mut *self;
303        if this.inner.check_shutdown(cx) {
304            this.is_terminated = true;
305            return std::task::Poll::Ready(None);
306        }
307        if this.is_terminated {
308            panic!("polled FacadeIteratorRequestStream after completion");
309        }
310        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
311            |bytes, handles| {
312                match this.inner.channel().read_etc(cx, bytes, handles) {
313                    std::task::Poll::Ready(Ok(())) => {}
314                    std::task::Poll::Pending => return std::task::Poll::Pending,
315                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
316                        this.is_terminated = true;
317                        return std::task::Poll::Ready(None);
318                    }
319                    std::task::Poll::Ready(Err(e)) => {
320                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
321                            e.into(),
322                        ))))
323                    }
324                }
325
326                // A message has been received from the channel
327                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
328
329                std::task::Poll::Ready(Some(match header.ordinal {
330                    0x1d22c13a17449134 => {
331                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
332                        let mut req = fidl::new_empty!(
333                            fidl::encoding::EmptyPayload,
334                            fidl::encoding::DefaultFuchsiaResourceDialect
335                        );
336                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
337                        let control_handle =
338                            FacadeIteratorControlHandle { inner: this.inner.clone() };
339                        Ok(FacadeIteratorRequest::GetNext {
340                            responder: FacadeIteratorGetNextResponder {
341                                control_handle: std::mem::ManuallyDrop::new(control_handle),
342                                tx_id: header.tx_id,
343                            },
344                        })
345                    }
346                    _ => Err(fidl::Error::UnknownOrdinal {
347                        ordinal: header.ordinal,
348                        protocol_name:
349                            <FacadeIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
350                    }),
351                }))
352            },
353        )
354    }
355}
356
357/// Implemented by a backend component hosting one or more facades. Used to acquire the list of
358/// facades hosted by a `FacadeProvider` instance.
359#[derive(Debug)]
360pub enum FacadeIteratorRequest {
361    GetNext { responder: FacadeIteratorGetNextResponder },
362}
363
364impl FacadeIteratorRequest {
365    #[allow(irrefutable_let_patterns)]
366    pub fn into_get_next(self) -> Option<(FacadeIteratorGetNextResponder)> {
367        if let FacadeIteratorRequest::GetNext { responder } = self {
368            Some((responder))
369        } else {
370            None
371        }
372    }
373
374    /// Name of the method defined in FIDL
375    pub fn method_name(&self) -> &'static str {
376        match *self {
377            FacadeIteratorRequest::GetNext { .. } => "get_next",
378        }
379    }
380}
381
382#[derive(Debug, Clone)]
383pub struct FacadeIteratorControlHandle {
384    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
385}
386
387impl fidl::endpoints::ControlHandle for FacadeIteratorControlHandle {
388    fn shutdown(&self) {
389        self.inner.shutdown()
390    }
391    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
392        self.inner.shutdown_with_epitaph(status)
393    }
394
395    fn is_closed(&self) -> bool {
396        self.inner.channel().is_closed()
397    }
398    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
399        self.inner.channel().on_closed()
400    }
401
402    #[cfg(target_os = "fuchsia")]
403    fn signal_peer(
404        &self,
405        clear_mask: zx::Signals,
406        set_mask: zx::Signals,
407    ) -> Result<(), zx_status::Status> {
408        use fidl::Peered;
409        self.inner.channel().signal_peer(clear_mask, set_mask)
410    }
411}
412
413impl FacadeIteratorControlHandle {}
414
415#[must_use = "FIDL methods require a response to be sent"]
416#[derive(Debug)]
417pub struct FacadeIteratorGetNextResponder {
418    control_handle: std::mem::ManuallyDrop<FacadeIteratorControlHandle>,
419    tx_id: u32,
420}
421
422/// Set the the channel to be shutdown (see [`FacadeIteratorControlHandle::shutdown`])
423/// if the responder is dropped without sending a response, so that the client
424/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
425impl std::ops::Drop for FacadeIteratorGetNextResponder {
426    fn drop(&mut self) {
427        self.control_handle.shutdown();
428        // Safety: drops once, never accessed again
429        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
430    }
431}
432
433impl fidl::endpoints::Responder for FacadeIteratorGetNextResponder {
434    type ControlHandle = FacadeIteratorControlHandle;
435
436    fn control_handle(&self) -> &FacadeIteratorControlHandle {
437        &self.control_handle
438    }
439
440    fn drop_without_shutdown(mut self) {
441        // Safety: drops once, never accessed again due to mem::forget
442        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
443        // Prevent Drop from running (which would shut down the channel)
444        std::mem::forget(self);
445    }
446}
447
448impl FacadeIteratorGetNextResponder {
449    /// Sends a response to the FIDL transaction.
450    ///
451    /// Sets the channel to shutdown if an error occurs.
452    pub fn send(self, mut facades: &[String]) -> Result<(), fidl::Error> {
453        let _result = self.send_raw(facades);
454        if _result.is_err() {
455            self.control_handle.shutdown();
456        }
457        self.drop_without_shutdown();
458        _result
459    }
460
461    /// Similar to "send" but does not shutdown the channel if an error occurs.
462    pub fn send_no_shutdown_on_err(self, mut facades: &[String]) -> Result<(), fidl::Error> {
463        let _result = self.send_raw(facades);
464        self.drop_without_shutdown();
465        _result
466    }
467
468    fn send_raw(&self, mut facades: &[String]) -> Result<(), fidl::Error> {
469        self.control_handle.inner.send::<FacadeIteratorGetNextResponse>(
470            (facades,),
471            self.tx_id,
472            0x1d22c13a17449134,
473            fidl::encoding::DynamicFlags::empty(),
474        )
475    }
476}
477
478#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
479pub struct FacadeProviderMarker;
480
481impl fidl::endpoints::ProtocolMarker for FacadeProviderMarker {
482    type Proxy = FacadeProviderProxy;
483    type RequestStream = FacadeProviderRequestStream;
484    #[cfg(target_os = "fuchsia")]
485    type SynchronousProxy = FacadeProviderSynchronousProxy;
486
487    const DEBUG_NAME: &'static str = "fuchsia.testing.sl4f.FacadeProvider";
488}
489impl fidl::endpoints::DiscoverableProtocolMarker for FacadeProviderMarker {}
490
491pub trait FacadeProviderProxyInterface: Send + Sync {
492    fn r#get_facades(
493        &self,
494        iterator: fidl::endpoints::ServerEnd<FacadeIteratorMarker>,
495    ) -> Result<(), fidl::Error>;
496    type ExecuteResponseFut: std::future::Future<Output = Result<(Option<fidl::Vmo>, Option<String>), fidl::Error>>
497        + Send;
498    fn r#execute(
499        &self,
500        facade: &str,
501        command: &str,
502        params_blob: fidl::Vmo,
503    ) -> Self::ExecuteResponseFut;
504    type CleanupResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
505    fn r#cleanup(&self) -> Self::CleanupResponseFut;
506    type PrintResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
507    fn r#print(&self) -> Self::PrintResponseFut;
508}
509#[derive(Debug)]
510#[cfg(target_os = "fuchsia")]
511pub struct FacadeProviderSynchronousProxy {
512    client: fidl::client::sync::Client,
513}
514
515#[cfg(target_os = "fuchsia")]
516impl fidl::endpoints::SynchronousProxy for FacadeProviderSynchronousProxy {
517    type Proxy = FacadeProviderProxy;
518    type Protocol = FacadeProviderMarker;
519
520    fn from_channel(inner: fidl::Channel) -> Self {
521        Self::new(inner)
522    }
523
524    fn into_channel(self) -> fidl::Channel {
525        self.client.into_channel()
526    }
527
528    fn as_channel(&self) -> &fidl::Channel {
529        self.client.as_channel()
530    }
531}
532
533#[cfg(target_os = "fuchsia")]
534impl FacadeProviderSynchronousProxy {
535    pub fn new(channel: fidl::Channel) -> Self {
536        let protocol_name = <FacadeProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
537        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
538    }
539
540    pub fn into_channel(self) -> fidl::Channel {
541        self.client.into_channel()
542    }
543
544    /// Waits until an event arrives and returns it. It is safe for other
545    /// threads to make concurrent requests while waiting for an event.
546    pub fn wait_for_event(
547        &self,
548        deadline: zx::MonotonicInstant,
549    ) -> Result<FacadeProviderEvent, fidl::Error> {
550        FacadeProviderEvent::decode(self.client.wait_for_event(deadline)?)
551    }
552
553    /// Connect to a `FacadeIterator` to obtain the list of facades hosted by this `FacadeProvider`.
554    pub fn r#get_facades(
555        &self,
556        mut iterator: fidl::endpoints::ServerEnd<FacadeIteratorMarker>,
557    ) -> Result<(), fidl::Error> {
558        self.client.send::<FacadeProviderGetFacadesRequest>(
559            (iterator,),
560            0xe3f63eb545df361,
561            fidl::encoding::DynamicFlags::empty(),
562        )
563    }
564
565    /// Executes 'command' on 'facade'. Returns an optional result JSON blob and error string.
566    pub fn r#execute(
567        &self,
568        mut facade: &str,
569        mut command: &str,
570        mut params_blob: fidl::Vmo,
571        ___deadline: zx::MonotonicInstant,
572    ) -> Result<(Option<fidl::Vmo>, Option<String>), fidl::Error> {
573        let _response =
574            self.client.send_query::<FacadeProviderExecuteRequest, FacadeProviderExecuteResponse>(
575                (facade, command, params_blob),
576                0x7d6de537b3caf392,
577                fidl::encoding::DynamicFlags::empty(),
578                ___deadline,
579            )?;
580        Ok((_response.result_blob, _response.error))
581    }
582
583    /// Cleans up any resources and transient state associated with SL4F facades hosted by this
584    /// `FacadeProvider`. Returns on completion.
585    pub fn r#cleanup(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
586        let _response =
587            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
588                (),
589                0x3d3accf7ad309712,
590                fidl::encoding::DynamicFlags::empty(),
591                ___deadline,
592            )?;
593        Ok(_response)
594    }
595
596    /// Prints the state of all facades hosted by this `FacadeProvider`. Returns on completion.
597    pub fn r#print(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
598        let _response =
599            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
600                (),
601                0x3e8853ac2d3a18d7,
602                fidl::encoding::DynamicFlags::empty(),
603                ___deadline,
604            )?;
605        Ok(_response)
606    }
607}
608
609#[cfg(target_os = "fuchsia")]
610impl From<FacadeProviderSynchronousProxy> for zx::Handle {
611    fn from(value: FacadeProviderSynchronousProxy) -> Self {
612        value.into_channel().into()
613    }
614}
615
616#[cfg(target_os = "fuchsia")]
617impl From<fidl::Channel> for FacadeProviderSynchronousProxy {
618    fn from(value: fidl::Channel) -> Self {
619        Self::new(value)
620    }
621}
622
623#[derive(Debug, Clone)]
624pub struct FacadeProviderProxy {
625    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
626}
627
628impl fidl::endpoints::Proxy for FacadeProviderProxy {
629    type Protocol = FacadeProviderMarker;
630
631    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
632        Self::new(inner)
633    }
634
635    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
636        self.client.into_channel().map_err(|client| Self { client })
637    }
638
639    fn as_channel(&self) -> &::fidl::AsyncChannel {
640        self.client.as_channel()
641    }
642}
643
644impl FacadeProviderProxy {
645    /// Create a new Proxy for fuchsia.testing.sl4f/FacadeProvider.
646    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
647        let protocol_name = <FacadeProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
648        Self { client: fidl::client::Client::new(channel, protocol_name) }
649    }
650
651    /// Get a Stream of events from the remote end of the protocol.
652    ///
653    /// # Panics
654    ///
655    /// Panics if the event stream was already taken.
656    pub fn take_event_stream(&self) -> FacadeProviderEventStream {
657        FacadeProviderEventStream { event_receiver: self.client.take_event_receiver() }
658    }
659
660    /// Connect to a `FacadeIterator` to obtain the list of facades hosted by this `FacadeProvider`.
661    pub fn r#get_facades(
662        &self,
663        mut iterator: fidl::endpoints::ServerEnd<FacadeIteratorMarker>,
664    ) -> Result<(), fidl::Error> {
665        FacadeProviderProxyInterface::r#get_facades(self, iterator)
666    }
667
668    /// Executes 'command' on 'facade'. Returns an optional result JSON blob and error string.
669    pub fn r#execute(
670        &self,
671        mut facade: &str,
672        mut command: &str,
673        mut params_blob: fidl::Vmo,
674    ) -> fidl::client::QueryResponseFut<
675        (Option<fidl::Vmo>, Option<String>),
676        fidl::encoding::DefaultFuchsiaResourceDialect,
677    > {
678        FacadeProviderProxyInterface::r#execute(self, facade, command, params_blob)
679    }
680
681    /// Cleans up any resources and transient state associated with SL4F facades hosted by this
682    /// `FacadeProvider`. Returns on completion.
683    pub fn r#cleanup(
684        &self,
685    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
686        FacadeProviderProxyInterface::r#cleanup(self)
687    }
688
689    /// Prints the state of all facades hosted by this `FacadeProvider`. Returns on completion.
690    pub fn r#print(
691        &self,
692    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
693        FacadeProviderProxyInterface::r#print(self)
694    }
695}
696
697impl FacadeProviderProxyInterface for FacadeProviderProxy {
698    fn r#get_facades(
699        &self,
700        mut iterator: fidl::endpoints::ServerEnd<FacadeIteratorMarker>,
701    ) -> Result<(), fidl::Error> {
702        self.client.send::<FacadeProviderGetFacadesRequest>(
703            (iterator,),
704            0xe3f63eb545df361,
705            fidl::encoding::DynamicFlags::empty(),
706        )
707    }
708
709    type ExecuteResponseFut = fidl::client::QueryResponseFut<
710        (Option<fidl::Vmo>, Option<String>),
711        fidl::encoding::DefaultFuchsiaResourceDialect,
712    >;
713    fn r#execute(
714        &self,
715        mut facade: &str,
716        mut command: &str,
717        mut params_blob: fidl::Vmo,
718    ) -> Self::ExecuteResponseFut {
719        fn _decode(
720            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
721        ) -> Result<(Option<fidl::Vmo>, Option<String>), fidl::Error> {
722            let _response = fidl::client::decode_transaction_body::<
723                FacadeProviderExecuteResponse,
724                fidl::encoding::DefaultFuchsiaResourceDialect,
725                0x7d6de537b3caf392,
726            >(_buf?)?;
727            Ok((_response.result_blob, _response.error))
728        }
729        self.client.send_query_and_decode::<
730            FacadeProviderExecuteRequest,
731            (Option<fidl::Vmo>, Option<String>),
732        >(
733            (facade, command, params_blob,),
734            0x7d6de537b3caf392,
735            fidl::encoding::DynamicFlags::empty(),
736            _decode,
737        )
738    }
739
740    type CleanupResponseFut =
741        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
742    fn r#cleanup(&self) -> Self::CleanupResponseFut {
743        fn _decode(
744            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
745        ) -> Result<(), fidl::Error> {
746            let _response = fidl::client::decode_transaction_body::<
747                fidl::encoding::EmptyPayload,
748                fidl::encoding::DefaultFuchsiaResourceDialect,
749                0x3d3accf7ad309712,
750            >(_buf?)?;
751            Ok(_response)
752        }
753        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
754            (),
755            0x3d3accf7ad309712,
756            fidl::encoding::DynamicFlags::empty(),
757            _decode,
758        )
759    }
760
761    type PrintResponseFut =
762        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
763    fn r#print(&self) -> Self::PrintResponseFut {
764        fn _decode(
765            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
766        ) -> Result<(), fidl::Error> {
767            let _response = fidl::client::decode_transaction_body::<
768                fidl::encoding::EmptyPayload,
769                fidl::encoding::DefaultFuchsiaResourceDialect,
770                0x3e8853ac2d3a18d7,
771            >(_buf?)?;
772            Ok(_response)
773        }
774        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
775            (),
776            0x3e8853ac2d3a18d7,
777            fidl::encoding::DynamicFlags::empty(),
778            _decode,
779        )
780    }
781}
782
783pub struct FacadeProviderEventStream {
784    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
785}
786
787impl std::marker::Unpin for FacadeProviderEventStream {}
788
789impl futures::stream::FusedStream for FacadeProviderEventStream {
790    fn is_terminated(&self) -> bool {
791        self.event_receiver.is_terminated()
792    }
793}
794
795impl futures::Stream for FacadeProviderEventStream {
796    type Item = Result<FacadeProviderEvent, fidl::Error>;
797
798    fn poll_next(
799        mut self: std::pin::Pin<&mut Self>,
800        cx: &mut std::task::Context<'_>,
801    ) -> std::task::Poll<Option<Self::Item>> {
802        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
803            &mut self.event_receiver,
804            cx
805        )?) {
806            Some(buf) => std::task::Poll::Ready(Some(FacadeProviderEvent::decode(buf))),
807            None => std::task::Poll::Ready(None),
808        }
809    }
810}
811
812#[derive(Debug)]
813pub enum FacadeProviderEvent {}
814
815impl FacadeProviderEvent {
816    /// Decodes a message buffer as a [`FacadeProviderEvent`].
817    fn decode(
818        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
819    ) -> Result<FacadeProviderEvent, fidl::Error> {
820        let (bytes, _handles) = buf.split_mut();
821        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
822        debug_assert_eq!(tx_header.tx_id, 0);
823        match tx_header.ordinal {
824            _ => Err(fidl::Error::UnknownOrdinal {
825                ordinal: tx_header.ordinal,
826                protocol_name:
827                    <FacadeProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
828            }),
829        }
830    }
831}
832
833/// A Stream of incoming requests for fuchsia.testing.sl4f/FacadeProvider.
834pub struct FacadeProviderRequestStream {
835    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
836    is_terminated: bool,
837}
838
839impl std::marker::Unpin for FacadeProviderRequestStream {}
840
841impl futures::stream::FusedStream for FacadeProviderRequestStream {
842    fn is_terminated(&self) -> bool {
843        self.is_terminated
844    }
845}
846
847impl fidl::endpoints::RequestStream for FacadeProviderRequestStream {
848    type Protocol = FacadeProviderMarker;
849    type ControlHandle = FacadeProviderControlHandle;
850
851    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
852        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
853    }
854
855    fn control_handle(&self) -> Self::ControlHandle {
856        FacadeProviderControlHandle { inner: self.inner.clone() }
857    }
858
859    fn into_inner(
860        self,
861    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
862    {
863        (self.inner, self.is_terminated)
864    }
865
866    fn from_inner(
867        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
868        is_terminated: bool,
869    ) -> Self {
870        Self { inner, is_terminated }
871    }
872}
873
874impl futures::Stream for FacadeProviderRequestStream {
875    type Item = Result<FacadeProviderRequest, fidl::Error>;
876
877    fn poll_next(
878        mut self: std::pin::Pin<&mut Self>,
879        cx: &mut std::task::Context<'_>,
880    ) -> std::task::Poll<Option<Self::Item>> {
881        let this = &mut *self;
882        if this.inner.check_shutdown(cx) {
883            this.is_terminated = true;
884            return std::task::Poll::Ready(None);
885        }
886        if this.is_terminated {
887            panic!("polled FacadeProviderRequestStream after completion");
888        }
889        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
890            |bytes, handles| {
891                match this.inner.channel().read_etc(cx, bytes, handles) {
892                    std::task::Poll::Ready(Ok(())) => {}
893                    std::task::Poll::Pending => return std::task::Poll::Pending,
894                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
895                        this.is_terminated = true;
896                        return std::task::Poll::Ready(None);
897                    }
898                    std::task::Poll::Ready(Err(e)) => {
899                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
900                            e.into(),
901                        ))))
902                    }
903                }
904
905                // A message has been received from the channel
906                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
907
908                std::task::Poll::Ready(Some(match header.ordinal {
909                    0xe3f63eb545df361 => {
910                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
911                        let mut req = fidl::new_empty!(
912                            FacadeProviderGetFacadesRequest,
913                            fidl::encoding::DefaultFuchsiaResourceDialect
914                        );
915                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FacadeProviderGetFacadesRequest>(&header, _body_bytes, handles, &mut req)?;
916                        let control_handle =
917                            FacadeProviderControlHandle { inner: this.inner.clone() };
918                        Ok(FacadeProviderRequest::GetFacades {
919                            iterator: req.iterator,
920
921                            control_handle,
922                        })
923                    }
924                    0x7d6de537b3caf392 => {
925                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
926                        let mut req = fidl::new_empty!(
927                            FacadeProviderExecuteRequest,
928                            fidl::encoding::DefaultFuchsiaResourceDialect
929                        );
930                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FacadeProviderExecuteRequest>(&header, _body_bytes, handles, &mut req)?;
931                        let control_handle =
932                            FacadeProviderControlHandle { inner: this.inner.clone() };
933                        Ok(FacadeProviderRequest::Execute {
934                            facade: req.facade,
935                            command: req.command,
936                            params_blob: req.params_blob,
937
938                            responder: FacadeProviderExecuteResponder {
939                                control_handle: std::mem::ManuallyDrop::new(control_handle),
940                                tx_id: header.tx_id,
941                            },
942                        })
943                    }
944                    0x3d3accf7ad309712 => {
945                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
946                        let mut req = fidl::new_empty!(
947                            fidl::encoding::EmptyPayload,
948                            fidl::encoding::DefaultFuchsiaResourceDialect
949                        );
950                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
951                        let control_handle =
952                            FacadeProviderControlHandle { inner: this.inner.clone() };
953                        Ok(FacadeProviderRequest::Cleanup {
954                            responder: FacadeProviderCleanupResponder {
955                                control_handle: std::mem::ManuallyDrop::new(control_handle),
956                                tx_id: header.tx_id,
957                            },
958                        })
959                    }
960                    0x3e8853ac2d3a18d7 => {
961                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
962                        let mut req = fidl::new_empty!(
963                            fidl::encoding::EmptyPayload,
964                            fidl::encoding::DefaultFuchsiaResourceDialect
965                        );
966                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
967                        let control_handle =
968                            FacadeProviderControlHandle { inner: this.inner.clone() };
969                        Ok(FacadeProviderRequest::Print {
970                            responder: FacadeProviderPrintResponder {
971                                control_handle: std::mem::ManuallyDrop::new(control_handle),
972                                tx_id: header.tx_id,
973                            },
974                        })
975                    }
976                    _ => Err(fidl::Error::UnknownOrdinal {
977                        ordinal: header.ordinal,
978                        protocol_name:
979                            <FacadeProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
980                    }),
981                }))
982            },
983        )
984    }
985}
986
987/// Implemented by a backend component hosting one or more facades. A facade must only be hosted by
988/// a signel `FacadeProvider` instance.
989/// NOTE: The current implementation uses ComponentsV1 and only supports a single `FacadeProvider`
990/// instance. This is intended to change and may result in changes to the protocol.
991#[derive(Debug)]
992pub enum FacadeProviderRequest {
993    /// Connect to a `FacadeIterator` to obtain the list of facades hosted by this `FacadeProvider`.
994    GetFacades {
995        iterator: fidl::endpoints::ServerEnd<FacadeIteratorMarker>,
996        control_handle: FacadeProviderControlHandle,
997    },
998    /// Executes 'command' on 'facade'. Returns an optional result JSON blob and error string.
999    Execute {
1000        facade: String,
1001        command: String,
1002        params_blob: fidl::Vmo,
1003        responder: FacadeProviderExecuteResponder,
1004    },
1005    /// Cleans up any resources and transient state associated with SL4F facades hosted by this
1006    /// `FacadeProvider`. Returns on completion.
1007    Cleanup { responder: FacadeProviderCleanupResponder },
1008    /// Prints the state of all facades hosted by this `FacadeProvider`. Returns on completion.
1009    Print { responder: FacadeProviderPrintResponder },
1010}
1011
1012impl FacadeProviderRequest {
1013    #[allow(irrefutable_let_patterns)]
1014    pub fn into_get_facades(
1015        self,
1016    ) -> Option<(fidl::endpoints::ServerEnd<FacadeIteratorMarker>, FacadeProviderControlHandle)>
1017    {
1018        if let FacadeProviderRequest::GetFacades { iterator, control_handle } = self {
1019            Some((iterator, control_handle))
1020        } else {
1021            None
1022        }
1023    }
1024
1025    #[allow(irrefutable_let_patterns)]
1026    pub fn into_execute(
1027        self,
1028    ) -> Option<(String, String, fidl::Vmo, FacadeProviderExecuteResponder)> {
1029        if let FacadeProviderRequest::Execute { facade, command, params_blob, responder } = self {
1030            Some((facade, command, params_blob, responder))
1031        } else {
1032            None
1033        }
1034    }
1035
1036    #[allow(irrefutable_let_patterns)]
1037    pub fn into_cleanup(self) -> Option<(FacadeProviderCleanupResponder)> {
1038        if let FacadeProviderRequest::Cleanup { responder } = self {
1039            Some((responder))
1040        } else {
1041            None
1042        }
1043    }
1044
1045    #[allow(irrefutable_let_patterns)]
1046    pub fn into_print(self) -> Option<(FacadeProviderPrintResponder)> {
1047        if let FacadeProviderRequest::Print { responder } = self {
1048            Some((responder))
1049        } else {
1050            None
1051        }
1052    }
1053
1054    /// Name of the method defined in FIDL
1055    pub fn method_name(&self) -> &'static str {
1056        match *self {
1057            FacadeProviderRequest::GetFacades { .. } => "get_facades",
1058            FacadeProviderRequest::Execute { .. } => "execute",
1059            FacadeProviderRequest::Cleanup { .. } => "cleanup",
1060            FacadeProviderRequest::Print { .. } => "print",
1061        }
1062    }
1063}
1064
1065#[derive(Debug, Clone)]
1066pub struct FacadeProviderControlHandle {
1067    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1068}
1069
1070impl fidl::endpoints::ControlHandle for FacadeProviderControlHandle {
1071    fn shutdown(&self) {
1072        self.inner.shutdown()
1073    }
1074    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1075        self.inner.shutdown_with_epitaph(status)
1076    }
1077
1078    fn is_closed(&self) -> bool {
1079        self.inner.channel().is_closed()
1080    }
1081    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1082        self.inner.channel().on_closed()
1083    }
1084
1085    #[cfg(target_os = "fuchsia")]
1086    fn signal_peer(
1087        &self,
1088        clear_mask: zx::Signals,
1089        set_mask: zx::Signals,
1090    ) -> Result<(), zx_status::Status> {
1091        use fidl::Peered;
1092        self.inner.channel().signal_peer(clear_mask, set_mask)
1093    }
1094}
1095
1096impl FacadeProviderControlHandle {}
1097
1098#[must_use = "FIDL methods require a response to be sent"]
1099#[derive(Debug)]
1100pub struct FacadeProviderExecuteResponder {
1101    control_handle: std::mem::ManuallyDrop<FacadeProviderControlHandle>,
1102    tx_id: u32,
1103}
1104
1105/// Set the the channel to be shutdown (see [`FacadeProviderControlHandle::shutdown`])
1106/// if the responder is dropped without sending a response, so that the client
1107/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1108impl std::ops::Drop for FacadeProviderExecuteResponder {
1109    fn drop(&mut self) {
1110        self.control_handle.shutdown();
1111        // Safety: drops once, never accessed again
1112        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1113    }
1114}
1115
1116impl fidl::endpoints::Responder for FacadeProviderExecuteResponder {
1117    type ControlHandle = FacadeProviderControlHandle;
1118
1119    fn control_handle(&self) -> &FacadeProviderControlHandle {
1120        &self.control_handle
1121    }
1122
1123    fn drop_without_shutdown(mut self) {
1124        // Safety: drops once, never accessed again due to mem::forget
1125        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1126        // Prevent Drop from running (which would shut down the channel)
1127        std::mem::forget(self);
1128    }
1129}
1130
1131impl FacadeProviderExecuteResponder {
1132    /// Sends a response to the FIDL transaction.
1133    ///
1134    /// Sets the channel to shutdown if an error occurs.
1135    pub fn send(
1136        self,
1137        mut result_blob: Option<fidl::Vmo>,
1138        mut error: Option<&str>,
1139    ) -> Result<(), fidl::Error> {
1140        let _result = self.send_raw(result_blob, error);
1141        if _result.is_err() {
1142            self.control_handle.shutdown();
1143        }
1144        self.drop_without_shutdown();
1145        _result
1146    }
1147
1148    /// Similar to "send" but does not shutdown the channel if an error occurs.
1149    pub fn send_no_shutdown_on_err(
1150        self,
1151        mut result_blob: Option<fidl::Vmo>,
1152        mut error: Option<&str>,
1153    ) -> Result<(), fidl::Error> {
1154        let _result = self.send_raw(result_blob, error);
1155        self.drop_without_shutdown();
1156        _result
1157    }
1158
1159    fn send_raw(
1160        &self,
1161        mut result_blob: Option<fidl::Vmo>,
1162        mut error: Option<&str>,
1163    ) -> Result<(), fidl::Error> {
1164        self.control_handle.inner.send::<FacadeProviderExecuteResponse>(
1165            (result_blob, error),
1166            self.tx_id,
1167            0x7d6de537b3caf392,
1168            fidl::encoding::DynamicFlags::empty(),
1169        )
1170    }
1171}
1172
1173#[must_use = "FIDL methods require a response to be sent"]
1174#[derive(Debug)]
1175pub struct FacadeProviderCleanupResponder {
1176    control_handle: std::mem::ManuallyDrop<FacadeProviderControlHandle>,
1177    tx_id: u32,
1178}
1179
1180/// Set the the channel to be shutdown (see [`FacadeProviderControlHandle::shutdown`])
1181/// if the responder is dropped without sending a response, so that the client
1182/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1183impl std::ops::Drop for FacadeProviderCleanupResponder {
1184    fn drop(&mut self) {
1185        self.control_handle.shutdown();
1186        // Safety: drops once, never accessed again
1187        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1188    }
1189}
1190
1191impl fidl::endpoints::Responder for FacadeProviderCleanupResponder {
1192    type ControlHandle = FacadeProviderControlHandle;
1193
1194    fn control_handle(&self) -> &FacadeProviderControlHandle {
1195        &self.control_handle
1196    }
1197
1198    fn drop_without_shutdown(mut self) {
1199        // Safety: drops once, never accessed again due to mem::forget
1200        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1201        // Prevent Drop from running (which would shut down the channel)
1202        std::mem::forget(self);
1203    }
1204}
1205
1206impl FacadeProviderCleanupResponder {
1207    /// Sends a response to the FIDL transaction.
1208    ///
1209    /// Sets the channel to shutdown if an error occurs.
1210    pub fn send(self) -> Result<(), fidl::Error> {
1211        let _result = self.send_raw();
1212        if _result.is_err() {
1213            self.control_handle.shutdown();
1214        }
1215        self.drop_without_shutdown();
1216        _result
1217    }
1218
1219    /// Similar to "send" but does not shutdown the channel if an error occurs.
1220    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1221        let _result = self.send_raw();
1222        self.drop_without_shutdown();
1223        _result
1224    }
1225
1226    fn send_raw(&self) -> Result<(), fidl::Error> {
1227        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1228            (),
1229            self.tx_id,
1230            0x3d3accf7ad309712,
1231            fidl::encoding::DynamicFlags::empty(),
1232        )
1233    }
1234}
1235
1236#[must_use = "FIDL methods require a response to be sent"]
1237#[derive(Debug)]
1238pub struct FacadeProviderPrintResponder {
1239    control_handle: std::mem::ManuallyDrop<FacadeProviderControlHandle>,
1240    tx_id: u32,
1241}
1242
1243/// Set the the channel to be shutdown (see [`FacadeProviderControlHandle::shutdown`])
1244/// if the responder is dropped without sending a response, so that the client
1245/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1246impl std::ops::Drop for FacadeProviderPrintResponder {
1247    fn drop(&mut self) {
1248        self.control_handle.shutdown();
1249        // Safety: drops once, never accessed again
1250        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1251    }
1252}
1253
1254impl fidl::endpoints::Responder for FacadeProviderPrintResponder {
1255    type ControlHandle = FacadeProviderControlHandle;
1256
1257    fn control_handle(&self) -> &FacadeProviderControlHandle {
1258        &self.control_handle
1259    }
1260
1261    fn drop_without_shutdown(mut self) {
1262        // Safety: drops once, never accessed again due to mem::forget
1263        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1264        // Prevent Drop from running (which would shut down the channel)
1265        std::mem::forget(self);
1266    }
1267}
1268
1269impl FacadeProviderPrintResponder {
1270    /// Sends a response to the FIDL transaction.
1271    ///
1272    /// Sets the channel to shutdown if an error occurs.
1273    pub fn send(self) -> Result<(), fidl::Error> {
1274        let _result = self.send_raw();
1275        if _result.is_err() {
1276            self.control_handle.shutdown();
1277        }
1278        self.drop_without_shutdown();
1279        _result
1280    }
1281
1282    /// Similar to "send" but does not shutdown the channel if an error occurs.
1283    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1284        let _result = self.send_raw();
1285        self.drop_without_shutdown();
1286        _result
1287    }
1288
1289    fn send_raw(&self) -> Result<(), fidl::Error> {
1290        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1291            (),
1292            self.tx_id,
1293            0x3e8853ac2d3a18d7,
1294            fidl::encoding::DynamicFlags::empty(),
1295        )
1296    }
1297}
1298
1299mod internal {
1300    use super::*;
1301
1302    impl fidl::encoding::ResourceTypeMarker for FacadeProviderExecuteRequest {
1303        type Borrowed<'a> = &'a mut Self;
1304        fn take_or_borrow<'a>(
1305            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1306        ) -> Self::Borrowed<'a> {
1307            value
1308        }
1309    }
1310
1311    unsafe impl fidl::encoding::TypeMarker for FacadeProviderExecuteRequest {
1312        type Owned = Self;
1313
1314        #[inline(always)]
1315        fn inline_align(_context: fidl::encoding::Context) -> usize {
1316            8
1317        }
1318
1319        #[inline(always)]
1320        fn inline_size(_context: fidl::encoding::Context) -> usize {
1321            40
1322        }
1323    }
1324
1325    unsafe impl
1326        fidl::encoding::Encode<
1327            FacadeProviderExecuteRequest,
1328            fidl::encoding::DefaultFuchsiaResourceDialect,
1329        > for &mut FacadeProviderExecuteRequest
1330    {
1331        #[inline]
1332        unsafe fn encode(
1333            self,
1334            encoder: &mut fidl::encoding::Encoder<
1335                '_,
1336                fidl::encoding::DefaultFuchsiaResourceDialect,
1337            >,
1338            offset: usize,
1339            _depth: fidl::encoding::Depth,
1340        ) -> fidl::Result<()> {
1341            encoder.debug_check_bounds::<FacadeProviderExecuteRequest>(offset);
1342            // Delegate to tuple encoding.
1343            fidl::encoding::Encode::<
1344                FacadeProviderExecuteRequest,
1345                fidl::encoding::DefaultFuchsiaResourceDialect,
1346            >::encode(
1347                (
1348                    <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(
1349                        &self.facade,
1350                    ),
1351                    <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(
1352                        &self.command,
1353                    ),
1354                    <fidl::encoding::HandleType<
1355                        fidl::Vmo,
1356                        { fidl::ObjectType::VMO.into_raw() },
1357                        2147483648,
1358                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1359                        &mut self.params_blob
1360                    ),
1361                ),
1362                encoder,
1363                offset,
1364                _depth,
1365            )
1366        }
1367    }
1368    unsafe impl<
1369            T0: fidl::encoding::Encode<
1370                fidl::encoding::UnboundedString,
1371                fidl::encoding::DefaultFuchsiaResourceDialect,
1372            >,
1373            T1: fidl::encoding::Encode<
1374                fidl::encoding::UnboundedString,
1375                fidl::encoding::DefaultFuchsiaResourceDialect,
1376            >,
1377            T2: fidl::encoding::Encode<
1378                fidl::encoding::HandleType<
1379                    fidl::Vmo,
1380                    { fidl::ObjectType::VMO.into_raw() },
1381                    2147483648,
1382                >,
1383                fidl::encoding::DefaultFuchsiaResourceDialect,
1384            >,
1385        >
1386        fidl::encoding::Encode<
1387            FacadeProviderExecuteRequest,
1388            fidl::encoding::DefaultFuchsiaResourceDialect,
1389        > for (T0, T1, T2)
1390    {
1391        #[inline]
1392        unsafe fn encode(
1393            self,
1394            encoder: &mut fidl::encoding::Encoder<
1395                '_,
1396                fidl::encoding::DefaultFuchsiaResourceDialect,
1397            >,
1398            offset: usize,
1399            depth: fidl::encoding::Depth,
1400        ) -> fidl::Result<()> {
1401            encoder.debug_check_bounds::<FacadeProviderExecuteRequest>(offset);
1402            // Zero out padding regions. There's no need to apply masks
1403            // because the unmasked parts will be overwritten by fields.
1404            unsafe {
1405                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
1406                (ptr as *mut u64).write_unaligned(0);
1407            }
1408            // Write the fields.
1409            self.0.encode(encoder, offset + 0, depth)?;
1410            self.1.encode(encoder, offset + 16, depth)?;
1411            self.2.encode(encoder, offset + 32, depth)?;
1412            Ok(())
1413        }
1414    }
1415
1416    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1417        for FacadeProviderExecuteRequest
1418    {
1419        #[inline(always)]
1420        fn new_empty() -> Self {
1421            Self {
1422                facade: fidl::new_empty!(
1423                    fidl::encoding::UnboundedString,
1424                    fidl::encoding::DefaultFuchsiaResourceDialect
1425                ),
1426                command: fidl::new_empty!(
1427                    fidl::encoding::UnboundedString,
1428                    fidl::encoding::DefaultFuchsiaResourceDialect
1429                ),
1430                params_blob: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
1431            }
1432        }
1433
1434        #[inline]
1435        unsafe fn decode(
1436            &mut self,
1437            decoder: &mut fidl::encoding::Decoder<
1438                '_,
1439                fidl::encoding::DefaultFuchsiaResourceDialect,
1440            >,
1441            offset: usize,
1442            _depth: fidl::encoding::Depth,
1443        ) -> fidl::Result<()> {
1444            decoder.debug_check_bounds::<Self>(offset);
1445            // Verify that padding bytes are zero.
1446            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
1447            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1448            let mask = 0xffffffff00000000u64;
1449            let maskedval = padval & mask;
1450            if maskedval != 0 {
1451                return Err(fidl::Error::NonZeroPadding {
1452                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
1453                });
1454            }
1455            fidl::decode!(
1456                fidl::encoding::UnboundedString,
1457                fidl::encoding::DefaultFuchsiaResourceDialect,
1458                &mut self.facade,
1459                decoder,
1460                offset + 0,
1461                _depth
1462            )?;
1463            fidl::decode!(
1464                fidl::encoding::UnboundedString,
1465                fidl::encoding::DefaultFuchsiaResourceDialect,
1466                &mut self.command,
1467                decoder,
1468                offset + 16,
1469                _depth
1470            )?;
1471            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.params_blob, decoder, offset + 32, _depth)?;
1472            Ok(())
1473        }
1474    }
1475
1476    impl fidl::encoding::ResourceTypeMarker for FacadeProviderExecuteResponse {
1477        type Borrowed<'a> = &'a mut Self;
1478        fn take_or_borrow<'a>(
1479            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1480        ) -> Self::Borrowed<'a> {
1481            value
1482        }
1483    }
1484
1485    unsafe impl fidl::encoding::TypeMarker for FacadeProviderExecuteResponse {
1486        type Owned = Self;
1487
1488        #[inline(always)]
1489        fn inline_align(_context: fidl::encoding::Context) -> usize {
1490            8
1491        }
1492
1493        #[inline(always)]
1494        fn inline_size(_context: fidl::encoding::Context) -> usize {
1495            24
1496        }
1497    }
1498
1499    unsafe impl
1500        fidl::encoding::Encode<
1501            FacadeProviderExecuteResponse,
1502            fidl::encoding::DefaultFuchsiaResourceDialect,
1503        > for &mut FacadeProviderExecuteResponse
1504    {
1505        #[inline]
1506        unsafe fn encode(
1507            self,
1508            encoder: &mut fidl::encoding::Encoder<
1509                '_,
1510                fidl::encoding::DefaultFuchsiaResourceDialect,
1511            >,
1512            offset: usize,
1513            _depth: fidl::encoding::Depth,
1514        ) -> fidl::Result<()> {
1515            encoder.debug_check_bounds::<FacadeProviderExecuteResponse>(offset);
1516            // Delegate to tuple encoding.
1517            fidl::encoding::Encode::<FacadeProviderExecuteResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1518                (
1519                    <fidl::encoding::Optional<fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.result_blob),
1520                    <fidl::encoding::Optional<fidl::encoding::UnboundedString> as fidl::encoding::ValueTypeMarker>::borrow(&self.error),
1521                ),
1522                encoder, offset, _depth
1523            )
1524        }
1525    }
1526    unsafe impl<
1527            T0: fidl::encoding::Encode<
1528                fidl::encoding::Optional<
1529                    fidl::encoding::HandleType<
1530                        fidl::Vmo,
1531                        { fidl::ObjectType::VMO.into_raw() },
1532                        2147483648,
1533                    >,
1534                >,
1535                fidl::encoding::DefaultFuchsiaResourceDialect,
1536            >,
1537            T1: fidl::encoding::Encode<
1538                fidl::encoding::Optional<fidl::encoding::UnboundedString>,
1539                fidl::encoding::DefaultFuchsiaResourceDialect,
1540            >,
1541        >
1542        fidl::encoding::Encode<
1543            FacadeProviderExecuteResponse,
1544            fidl::encoding::DefaultFuchsiaResourceDialect,
1545        > for (T0, T1)
1546    {
1547        #[inline]
1548        unsafe fn encode(
1549            self,
1550            encoder: &mut fidl::encoding::Encoder<
1551                '_,
1552                fidl::encoding::DefaultFuchsiaResourceDialect,
1553            >,
1554            offset: usize,
1555            depth: fidl::encoding::Depth,
1556        ) -> fidl::Result<()> {
1557            encoder.debug_check_bounds::<FacadeProviderExecuteResponse>(offset);
1558            // Zero out padding regions. There's no need to apply masks
1559            // because the unmasked parts will be overwritten by fields.
1560            unsafe {
1561                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
1562                (ptr as *mut u64).write_unaligned(0);
1563            }
1564            // Write the fields.
1565            self.0.encode(encoder, offset + 0, depth)?;
1566            self.1.encode(encoder, offset + 8, depth)?;
1567            Ok(())
1568        }
1569    }
1570
1571    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1572        for FacadeProviderExecuteResponse
1573    {
1574        #[inline(always)]
1575        fn new_empty() -> Self {
1576            Self {
1577                result_blob: fidl::new_empty!(
1578                    fidl::encoding::Optional<
1579                        fidl::encoding::HandleType<
1580                            fidl::Vmo,
1581                            { fidl::ObjectType::VMO.into_raw() },
1582                            2147483648,
1583                        >,
1584                    >,
1585                    fidl::encoding::DefaultFuchsiaResourceDialect
1586                ),
1587                error: fidl::new_empty!(
1588                    fidl::encoding::Optional<fidl::encoding::UnboundedString>,
1589                    fidl::encoding::DefaultFuchsiaResourceDialect
1590                ),
1591            }
1592        }
1593
1594        #[inline]
1595        unsafe fn decode(
1596            &mut self,
1597            decoder: &mut fidl::encoding::Decoder<
1598                '_,
1599                fidl::encoding::DefaultFuchsiaResourceDialect,
1600            >,
1601            offset: usize,
1602            _depth: fidl::encoding::Depth,
1603        ) -> fidl::Result<()> {
1604            decoder.debug_check_bounds::<Self>(offset);
1605            // Verify that padding bytes are zero.
1606            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
1607            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1608            let mask = 0xffffffff00000000u64;
1609            let maskedval = padval & mask;
1610            if maskedval != 0 {
1611                return Err(fidl::Error::NonZeroPadding {
1612                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
1613                });
1614            }
1615            fidl::decode!(
1616                fidl::encoding::Optional<
1617                    fidl::encoding::HandleType<
1618                        fidl::Vmo,
1619                        { fidl::ObjectType::VMO.into_raw() },
1620                        2147483648,
1621                    >,
1622                >,
1623                fidl::encoding::DefaultFuchsiaResourceDialect,
1624                &mut self.result_blob,
1625                decoder,
1626                offset + 0,
1627                _depth
1628            )?;
1629            fidl::decode!(
1630                fidl::encoding::Optional<fidl::encoding::UnboundedString>,
1631                fidl::encoding::DefaultFuchsiaResourceDialect,
1632                &mut self.error,
1633                decoder,
1634                offset + 8,
1635                _depth
1636            )?;
1637            Ok(())
1638        }
1639    }
1640
1641    impl fidl::encoding::ResourceTypeMarker for FacadeProviderGetFacadesRequest {
1642        type Borrowed<'a> = &'a mut Self;
1643        fn take_or_borrow<'a>(
1644            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1645        ) -> Self::Borrowed<'a> {
1646            value
1647        }
1648    }
1649
1650    unsafe impl fidl::encoding::TypeMarker for FacadeProviderGetFacadesRequest {
1651        type Owned = Self;
1652
1653        #[inline(always)]
1654        fn inline_align(_context: fidl::encoding::Context) -> usize {
1655            4
1656        }
1657
1658        #[inline(always)]
1659        fn inline_size(_context: fidl::encoding::Context) -> usize {
1660            4
1661        }
1662    }
1663
1664    unsafe impl
1665        fidl::encoding::Encode<
1666            FacadeProviderGetFacadesRequest,
1667            fidl::encoding::DefaultFuchsiaResourceDialect,
1668        > for &mut FacadeProviderGetFacadesRequest
1669    {
1670        #[inline]
1671        unsafe fn encode(
1672            self,
1673            encoder: &mut fidl::encoding::Encoder<
1674                '_,
1675                fidl::encoding::DefaultFuchsiaResourceDialect,
1676            >,
1677            offset: usize,
1678            _depth: fidl::encoding::Depth,
1679        ) -> fidl::Result<()> {
1680            encoder.debug_check_bounds::<FacadeProviderGetFacadesRequest>(offset);
1681            // Delegate to tuple encoding.
1682            fidl::encoding::Encode::<FacadeProviderGetFacadesRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1683                (
1684                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<FacadeIteratorMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.iterator),
1685                ),
1686                encoder, offset, _depth
1687            )
1688        }
1689    }
1690    unsafe impl<
1691            T0: fidl::encoding::Encode<
1692                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<FacadeIteratorMarker>>,
1693                fidl::encoding::DefaultFuchsiaResourceDialect,
1694            >,
1695        >
1696        fidl::encoding::Encode<
1697            FacadeProviderGetFacadesRequest,
1698            fidl::encoding::DefaultFuchsiaResourceDialect,
1699        > for (T0,)
1700    {
1701        #[inline]
1702        unsafe fn encode(
1703            self,
1704            encoder: &mut fidl::encoding::Encoder<
1705                '_,
1706                fidl::encoding::DefaultFuchsiaResourceDialect,
1707            >,
1708            offset: usize,
1709            depth: fidl::encoding::Depth,
1710        ) -> fidl::Result<()> {
1711            encoder.debug_check_bounds::<FacadeProviderGetFacadesRequest>(offset);
1712            // Zero out padding regions. There's no need to apply masks
1713            // because the unmasked parts will be overwritten by fields.
1714            // Write the fields.
1715            self.0.encode(encoder, offset + 0, depth)?;
1716            Ok(())
1717        }
1718    }
1719
1720    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1721        for FacadeProviderGetFacadesRequest
1722    {
1723        #[inline(always)]
1724        fn new_empty() -> Self {
1725            Self {
1726                iterator: fidl::new_empty!(
1727                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<FacadeIteratorMarker>>,
1728                    fidl::encoding::DefaultFuchsiaResourceDialect
1729                ),
1730            }
1731        }
1732
1733        #[inline]
1734        unsafe fn decode(
1735            &mut self,
1736            decoder: &mut fidl::encoding::Decoder<
1737                '_,
1738                fidl::encoding::DefaultFuchsiaResourceDialect,
1739            >,
1740            offset: usize,
1741            _depth: fidl::encoding::Depth,
1742        ) -> fidl::Result<()> {
1743            decoder.debug_check_bounds::<Self>(offset);
1744            // Verify that padding bytes are zero.
1745            fidl::decode!(
1746                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<FacadeIteratorMarker>>,
1747                fidl::encoding::DefaultFuchsiaResourceDialect,
1748                &mut self.iterator,
1749                decoder,
1750                offset + 0,
1751                _depth
1752            )?;
1753            Ok(())
1754        }
1755    }
1756}