Skip to main content

fdomain_fuchsia_unknown/
fdomain_fuchsia_unknown.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 fdomain_client::fidl::{ControlHandle as _, FDomainFlexibleIntoResult as _, Responder as _};
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9pub use fidl_fuchsia_unknown_common::*;
10use futures::future::{self, MaybeDone, TryFutureExt};
11use zx_status;
12
13#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
14pub struct CloneableCloneRequest {
15    pub request: fdomain_client::fidl::ServerEnd<CloneableMarker>,
16}
17
18impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for CloneableCloneRequest {}
19
20#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
21pub struct CloneableMarker;
22
23impl fdomain_client::fidl::ProtocolMarker for CloneableMarker {
24    type Proxy = CloneableProxy;
25    type RequestStream = CloneableRequestStream;
26
27    const DEBUG_NAME: &'static str = "(anonymous) Cloneable";
28}
29
30pub trait CloneableProxyInterface: Send + Sync {
31    fn r#clone(
32        &self,
33        request: fdomain_client::fidl::ServerEnd<CloneableMarker>,
34    ) -> Result<(), fidl::Error>;
35}
36
37#[derive(Debug, Clone)]
38pub struct CloneableProxy {
39    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
40}
41
42impl fdomain_client::fidl::Proxy for CloneableProxy {
43    type Protocol = CloneableMarker;
44
45    fn from_channel(inner: fdomain_client::Channel) -> Self {
46        Self::new(inner)
47    }
48
49    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
50        self.client.into_channel().map_err(|client| Self { client })
51    }
52
53    fn as_channel(&self) -> &fdomain_client::Channel {
54        self.client.as_channel()
55    }
56}
57
58impl CloneableProxy {
59    /// Create a new Proxy for fuchsia.unknown/Cloneable.
60    pub fn new(channel: fdomain_client::Channel) -> Self {
61        let protocol_name = <CloneableMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
62        Self { client: fidl::client::Client::new(channel, protocol_name) }
63    }
64
65    /// Get a Stream of events from the remote end of the protocol.
66    ///
67    /// # Panics
68    ///
69    /// Panics if the event stream was already taken.
70    pub fn take_event_stream(&self) -> CloneableEventStream {
71        CloneableEventStream { event_receiver: self.client.take_event_receiver() }
72    }
73
74    pub fn r#clone(
75        &self,
76        mut request: fdomain_client::fidl::ServerEnd<CloneableMarker>,
77    ) -> Result<(), fidl::Error> {
78        CloneableProxyInterface::r#clone(self, request)
79    }
80}
81
82impl CloneableProxyInterface for CloneableProxy {
83    fn r#clone(
84        &self,
85        mut request: fdomain_client::fidl::ServerEnd<CloneableMarker>,
86    ) -> Result<(), fidl::Error> {
87        self.client.send::<CloneableCloneRequest>(
88            (request,),
89            0x20d8a7aba2168a79,
90            fidl::encoding::DynamicFlags::empty(),
91        )
92    }
93}
94
95pub struct CloneableEventStream {
96    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
97}
98
99impl std::marker::Unpin for CloneableEventStream {}
100
101impl futures::stream::FusedStream for CloneableEventStream {
102    fn is_terminated(&self) -> bool {
103        self.event_receiver.is_terminated()
104    }
105}
106
107impl futures::Stream for CloneableEventStream {
108    type Item = Result<CloneableEvent, fidl::Error>;
109
110    fn poll_next(
111        mut self: std::pin::Pin<&mut Self>,
112        cx: &mut std::task::Context<'_>,
113    ) -> std::task::Poll<Option<Self::Item>> {
114        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
115            &mut self.event_receiver,
116            cx
117        )?) {
118            Some(buf) => std::task::Poll::Ready(Some(CloneableEvent::decode(buf))),
119            None => std::task::Poll::Ready(None),
120        }
121    }
122}
123
124#[derive(Debug)]
125pub enum CloneableEvent {}
126
127impl CloneableEvent {
128    /// Decodes a message buffer as a [`CloneableEvent`].
129    fn decode(
130        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
131    ) -> Result<CloneableEvent, fidl::Error> {
132        let (bytes, _handles) = buf.split_mut();
133        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
134        debug_assert_eq!(tx_header.tx_id, 0);
135        match tx_header.ordinal {
136            _ => Err(fidl::Error::UnknownOrdinal {
137                ordinal: tx_header.ordinal,
138                protocol_name:
139                    <CloneableMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
140            }),
141        }
142    }
143}
144
145/// A Stream of incoming requests for fuchsia.unknown/Cloneable.
146pub struct CloneableRequestStream {
147    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
148    is_terminated: bool,
149}
150
151impl std::marker::Unpin for CloneableRequestStream {}
152
153impl futures::stream::FusedStream for CloneableRequestStream {
154    fn is_terminated(&self) -> bool {
155        self.is_terminated
156    }
157}
158
159impl fdomain_client::fidl::RequestStream for CloneableRequestStream {
160    type Protocol = CloneableMarker;
161    type ControlHandle = CloneableControlHandle;
162
163    fn from_channel(channel: fdomain_client::Channel) -> Self {
164        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
165    }
166
167    fn control_handle(&self) -> Self::ControlHandle {
168        CloneableControlHandle { inner: self.inner.clone() }
169    }
170
171    fn into_inner(
172        self,
173    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
174    {
175        (self.inner, self.is_terminated)
176    }
177
178    fn from_inner(
179        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
180        is_terminated: bool,
181    ) -> Self {
182        Self { inner, is_terminated }
183    }
184}
185
186impl futures::Stream for CloneableRequestStream {
187    type Item = Result<CloneableRequest, fidl::Error>;
188
189    fn poll_next(
190        mut self: std::pin::Pin<&mut Self>,
191        cx: &mut std::task::Context<'_>,
192    ) -> std::task::Poll<Option<Self::Item>> {
193        let this = &mut *self;
194        if this.inner.check_shutdown(cx) {
195            this.is_terminated = true;
196            return std::task::Poll::Ready(None);
197        }
198        if this.is_terminated {
199            panic!("polled CloneableRequestStream after completion");
200        }
201        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
202            |bytes, handles| {
203                match this.inner.channel().read_etc(cx, bytes, handles) {
204                    std::task::Poll::Ready(Ok(())) => {}
205                    std::task::Poll::Pending => return std::task::Poll::Pending,
206                    std::task::Poll::Ready(Err(None)) => {
207                        this.is_terminated = true;
208                        return std::task::Poll::Ready(None);
209                    }
210                    std::task::Poll::Ready(Err(Some(e))) => {
211                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
212                            e.into(),
213                        ))));
214                    }
215                }
216
217                // A message has been received from the channel
218                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
219
220                std::task::Poll::Ready(Some(match header.ordinal {
221                    0x20d8a7aba2168a79 => {
222                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
223                        let mut req = fidl::new_empty!(
224                            CloneableCloneRequest,
225                            fdomain_client::fidl::FDomainResourceDialect
226                        );
227                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<CloneableCloneRequest>(&header, _body_bytes, handles, &mut req)?;
228                        let control_handle = CloneableControlHandle { inner: this.inner.clone() };
229                        Ok(CloneableRequest::Clone { request: req.request, control_handle })
230                    }
231                    _ => Err(fidl::Error::UnknownOrdinal {
232                        ordinal: header.ordinal,
233                        protocol_name:
234                            <CloneableMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
235                    }),
236                }))
237            },
238        )
239    }
240}
241
242/// Provides a means of duplicating a connection.
243///
244/// See the composing protocol's documentation for a description of
245/// connection-scoped state, if any.
246#[derive(Debug)]
247pub enum CloneableRequest {
248    Clone {
249        request: fdomain_client::fidl::ServerEnd<CloneableMarker>,
250        control_handle: CloneableControlHandle,
251    },
252}
253
254impl CloneableRequest {
255    #[allow(irrefutable_let_patterns)]
256    pub fn into_clone(
257        self,
258    ) -> Option<(fdomain_client::fidl::ServerEnd<CloneableMarker>, CloneableControlHandle)> {
259        if let CloneableRequest::Clone { request, control_handle } = self {
260            Some((request, control_handle))
261        } else {
262            None
263        }
264    }
265
266    /// Name of the method defined in FIDL
267    pub fn method_name(&self) -> &'static str {
268        match *self {
269            CloneableRequest::Clone { .. } => "clone",
270        }
271    }
272}
273
274#[derive(Debug, Clone)]
275pub struct CloneableControlHandle {
276    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
277}
278
279impl CloneableControlHandle {
280    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
281        self.inner.shutdown_with_epitaph(status.into())
282    }
283}
284
285impl fdomain_client::fidl::ControlHandle for CloneableControlHandle {
286    fn shutdown(&self) {
287        self.inner.shutdown()
288    }
289
290    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
291        self.inner.shutdown_with_epitaph(status)
292    }
293
294    fn is_closed(&self) -> bool {
295        self.inner.channel().is_closed()
296    }
297    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
298        self.inner.channel().on_closed()
299    }
300}
301
302impl CloneableControlHandle {}
303
304#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
305pub struct CloseableMarker;
306
307impl fdomain_client::fidl::ProtocolMarker for CloseableMarker {
308    type Proxy = CloseableProxy;
309    type RequestStream = CloseableRequestStream;
310
311    const DEBUG_NAME: &'static str = "(anonymous) Closeable";
312}
313pub type CloseableCloseResult = Result<(), i32>;
314
315pub trait CloseableProxyInterface: Send + Sync {
316    type CloseResponseFut: std::future::Future<Output = Result<CloseableCloseResult, fidl::Error>>
317        + Send;
318    fn r#close(&self) -> Self::CloseResponseFut;
319}
320
321#[derive(Debug, Clone)]
322pub struct CloseableProxy {
323    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
324}
325
326impl fdomain_client::fidl::Proxy for CloseableProxy {
327    type Protocol = CloseableMarker;
328
329    fn from_channel(inner: fdomain_client::Channel) -> Self {
330        Self::new(inner)
331    }
332
333    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
334        self.client.into_channel().map_err(|client| Self { client })
335    }
336
337    fn as_channel(&self) -> &fdomain_client::Channel {
338        self.client.as_channel()
339    }
340}
341
342impl CloseableProxy {
343    /// Create a new Proxy for fuchsia.unknown/Closeable.
344    pub fn new(channel: fdomain_client::Channel) -> Self {
345        let protocol_name = <CloseableMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
346        Self { client: fidl::client::Client::new(channel, protocol_name) }
347    }
348
349    /// Get a Stream of events from the remote end of the protocol.
350    ///
351    /// # Panics
352    ///
353    /// Panics if the event stream was already taken.
354    pub fn take_event_stream(&self) -> CloseableEventStream {
355        CloseableEventStream { event_receiver: self.client.take_event_receiver() }
356    }
357
358    /// Terminates the connection.
359    ///
360    /// After calling `Close`, the client must not send any other requests.
361    ///
362    /// Servers, after sending the status response, should close the connection
363    /// regardless of status and without sending an epitaph.
364    ///
365    /// Closing the client end of the channel should be semantically equivalent
366    /// to calling `Close` without knowing when the close has completed or its
367    /// status.
368    pub fn r#close(
369        &self,
370    ) -> fidl::client::QueryResponseFut<
371        CloseableCloseResult,
372        fdomain_client::fidl::FDomainResourceDialect,
373    > {
374        CloseableProxyInterface::r#close(self)
375    }
376}
377
378impl CloseableProxyInterface for CloseableProxy {
379    type CloseResponseFut = fidl::client::QueryResponseFut<
380        CloseableCloseResult,
381        fdomain_client::fidl::FDomainResourceDialect,
382    >;
383    fn r#close(&self) -> Self::CloseResponseFut {
384        fn _decode(
385            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
386        ) -> Result<CloseableCloseResult, fidl::Error> {
387            let _response = fidl::client::decode_transaction_body::<
388                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
389                fdomain_client::fidl::FDomainResourceDialect,
390                0x5ac5d459ad7f657e,
391            >(_buf?)?;
392            Ok(_response.map(|x| x))
393        }
394        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, CloseableCloseResult>(
395            (),
396            0x5ac5d459ad7f657e,
397            fidl::encoding::DynamicFlags::empty(),
398            _decode,
399        )
400    }
401}
402
403pub struct CloseableEventStream {
404    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
405}
406
407impl std::marker::Unpin for CloseableEventStream {}
408
409impl futures::stream::FusedStream for CloseableEventStream {
410    fn is_terminated(&self) -> bool {
411        self.event_receiver.is_terminated()
412    }
413}
414
415impl futures::Stream for CloseableEventStream {
416    type Item = Result<CloseableEvent, fidl::Error>;
417
418    fn poll_next(
419        mut self: std::pin::Pin<&mut Self>,
420        cx: &mut std::task::Context<'_>,
421    ) -> std::task::Poll<Option<Self::Item>> {
422        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
423            &mut self.event_receiver,
424            cx
425        )?) {
426            Some(buf) => std::task::Poll::Ready(Some(CloseableEvent::decode(buf))),
427            None => std::task::Poll::Ready(None),
428        }
429    }
430}
431
432#[derive(Debug)]
433pub enum CloseableEvent {}
434
435impl CloseableEvent {
436    /// Decodes a message buffer as a [`CloseableEvent`].
437    fn decode(
438        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
439    ) -> Result<CloseableEvent, fidl::Error> {
440        let (bytes, _handles) = buf.split_mut();
441        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
442        debug_assert_eq!(tx_header.tx_id, 0);
443        match tx_header.ordinal {
444            _ => Err(fidl::Error::UnknownOrdinal {
445                ordinal: tx_header.ordinal,
446                protocol_name:
447                    <CloseableMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
448            }),
449        }
450    }
451}
452
453/// A Stream of incoming requests for fuchsia.unknown/Closeable.
454pub struct CloseableRequestStream {
455    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
456    is_terminated: bool,
457}
458
459impl std::marker::Unpin for CloseableRequestStream {}
460
461impl futures::stream::FusedStream for CloseableRequestStream {
462    fn is_terminated(&self) -> bool {
463        self.is_terminated
464    }
465}
466
467impl fdomain_client::fidl::RequestStream for CloseableRequestStream {
468    type Protocol = CloseableMarker;
469    type ControlHandle = CloseableControlHandle;
470
471    fn from_channel(channel: fdomain_client::Channel) -> Self {
472        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
473    }
474
475    fn control_handle(&self) -> Self::ControlHandle {
476        CloseableControlHandle { inner: self.inner.clone() }
477    }
478
479    fn into_inner(
480        self,
481    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
482    {
483        (self.inner, self.is_terminated)
484    }
485
486    fn from_inner(
487        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
488        is_terminated: bool,
489    ) -> Self {
490        Self { inner, is_terminated }
491    }
492}
493
494impl futures::Stream for CloseableRequestStream {
495    type Item = Result<CloseableRequest, fidl::Error>;
496
497    fn poll_next(
498        mut self: std::pin::Pin<&mut Self>,
499        cx: &mut std::task::Context<'_>,
500    ) -> std::task::Poll<Option<Self::Item>> {
501        let this = &mut *self;
502        if this.inner.check_shutdown(cx) {
503            this.is_terminated = true;
504            return std::task::Poll::Ready(None);
505        }
506        if this.is_terminated {
507            panic!("polled CloseableRequestStream after completion");
508        }
509        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
510            |bytes, handles| {
511                match this.inner.channel().read_etc(cx, bytes, handles) {
512                    std::task::Poll::Ready(Ok(())) => {}
513                    std::task::Poll::Pending => return std::task::Poll::Pending,
514                    std::task::Poll::Ready(Err(None)) => {
515                        this.is_terminated = true;
516                        return std::task::Poll::Ready(None);
517                    }
518                    std::task::Poll::Ready(Err(Some(e))) => {
519                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
520                            e.into(),
521                        ))));
522                    }
523                }
524
525                // A message has been received from the channel
526                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
527
528                std::task::Poll::Ready(Some(match header.ordinal {
529                    0x5ac5d459ad7f657e => {
530                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
531                        let mut req = fidl::new_empty!(
532                            fidl::encoding::EmptyPayload,
533                            fdomain_client::fidl::FDomainResourceDialect
534                        );
535                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
536                        let control_handle = CloseableControlHandle { inner: this.inner.clone() };
537                        Ok(CloseableRequest::Close {
538                            responder: CloseableCloseResponder {
539                                control_handle: std::mem::ManuallyDrop::new(control_handle),
540                                tx_id: header.tx_id,
541                            },
542                        })
543                    }
544                    _ => Err(fidl::Error::UnknownOrdinal {
545                        ordinal: header.ordinal,
546                        protocol_name:
547                            <CloseableMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
548                    }),
549                }))
550            },
551        )
552    }
553}
554
555/// Provides a means of synchronously closing a connection.
556#[derive(Debug)]
557pub enum CloseableRequest {
558    /// Terminates the connection.
559    ///
560    /// After calling `Close`, the client must not send any other requests.
561    ///
562    /// Servers, after sending the status response, should close the connection
563    /// regardless of status and without sending an epitaph.
564    ///
565    /// Closing the client end of the channel should be semantically equivalent
566    /// to calling `Close` without knowing when the close has completed or its
567    /// status.
568    Close { responder: CloseableCloseResponder },
569}
570
571impl CloseableRequest {
572    #[allow(irrefutable_let_patterns)]
573    pub fn into_close(self) -> Option<(CloseableCloseResponder)> {
574        if let CloseableRequest::Close { responder } = self { Some((responder)) } else { None }
575    }
576
577    /// Name of the method defined in FIDL
578    pub fn method_name(&self) -> &'static str {
579        match *self {
580            CloseableRequest::Close { .. } => "close",
581        }
582    }
583}
584
585#[derive(Debug, Clone)]
586pub struct CloseableControlHandle {
587    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
588}
589
590impl CloseableControlHandle {
591    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
592        self.inner.shutdown_with_epitaph(status.into())
593    }
594}
595
596impl fdomain_client::fidl::ControlHandle for CloseableControlHandle {
597    fn shutdown(&self) {
598        self.inner.shutdown()
599    }
600
601    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
602        self.inner.shutdown_with_epitaph(status)
603    }
604
605    fn is_closed(&self) -> bool {
606        self.inner.channel().is_closed()
607    }
608    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
609        self.inner.channel().on_closed()
610    }
611}
612
613impl CloseableControlHandle {}
614
615#[must_use = "FIDL methods require a response to be sent"]
616#[derive(Debug)]
617pub struct CloseableCloseResponder {
618    control_handle: std::mem::ManuallyDrop<CloseableControlHandle>,
619    tx_id: u32,
620}
621
622/// Set the the channel to be shutdown (see [`CloseableControlHandle::shutdown`])
623/// if the responder is dropped without sending a response, so that the client
624/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
625impl std::ops::Drop for CloseableCloseResponder {
626    fn drop(&mut self) {
627        self.control_handle.shutdown();
628        // Safety: drops once, never accessed again
629        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
630    }
631}
632
633impl fdomain_client::fidl::Responder for CloseableCloseResponder {
634    type ControlHandle = CloseableControlHandle;
635
636    fn control_handle(&self) -> &CloseableControlHandle {
637        &self.control_handle
638    }
639
640    fn drop_without_shutdown(mut self) {
641        // Safety: drops once, never accessed again due to mem::forget
642        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
643        // Prevent Drop from running (which would shut down the channel)
644        std::mem::forget(self);
645    }
646}
647
648impl CloseableCloseResponder {
649    /// Sends a response to the FIDL transaction.
650    ///
651    /// Sets the channel to shutdown if an error occurs.
652    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
653        let _result = self.send_raw(result);
654        if _result.is_err() {
655            self.control_handle.shutdown();
656        }
657        self.drop_without_shutdown();
658        _result
659    }
660
661    /// Similar to "send" but does not shutdown the channel if an error occurs.
662    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
663        let _result = self.send_raw(result);
664        self.drop_without_shutdown();
665        _result
666    }
667
668    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
669        self.control_handle
670            .inner
671            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
672                result,
673                self.tx_id,
674                0x5ac5d459ad7f657e,
675                fidl::encoding::DynamicFlags::empty(),
676            )
677    }
678}
679
680#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
681pub struct QueryableMarker;
682
683impl fdomain_client::fidl::ProtocolMarker for QueryableMarker {
684    type Proxy = QueryableProxy;
685    type RequestStream = QueryableRequestStream;
686
687    const DEBUG_NAME: &'static str = "(anonymous) Queryable";
688}
689
690pub trait QueryableProxyInterface: Send + Sync {
691    type QueryResponseFut: std::future::Future<Output = Result<Vec<u8>, fidl::Error>> + Send;
692    fn r#query(&self) -> Self::QueryResponseFut;
693}
694
695#[derive(Debug, Clone)]
696pub struct QueryableProxy {
697    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
698}
699
700impl fdomain_client::fidl::Proxy for QueryableProxy {
701    type Protocol = QueryableMarker;
702
703    fn from_channel(inner: fdomain_client::Channel) -> Self {
704        Self::new(inner)
705    }
706
707    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
708        self.client.into_channel().map_err(|client| Self { client })
709    }
710
711    fn as_channel(&self) -> &fdomain_client::Channel {
712        self.client.as_channel()
713    }
714}
715
716impl QueryableProxy {
717    /// Create a new Proxy for fuchsia.unknown/Queryable.
718    pub fn new(channel: fdomain_client::Channel) -> Self {
719        let protocol_name = <QueryableMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
720        Self { client: fidl::client::Client::new(channel, protocol_name) }
721    }
722
723    /// Get a Stream of events from the remote end of the protocol.
724    ///
725    /// # Panics
726    ///
727    /// Panics if the event stream was already taken.
728    pub fn take_event_stream(&self) -> QueryableEventStream {
729        QueryableEventStream { event_receiver: self.client.take_event_receiver() }
730    }
731
732    pub fn r#query(
733        &self,
734    ) -> fidl::client::QueryResponseFut<Vec<u8>, fdomain_client::fidl::FDomainResourceDialect> {
735        QueryableProxyInterface::r#query(self)
736    }
737}
738
739impl QueryableProxyInterface for QueryableProxy {
740    type QueryResponseFut =
741        fidl::client::QueryResponseFut<Vec<u8>, fdomain_client::fidl::FDomainResourceDialect>;
742    fn r#query(&self) -> Self::QueryResponseFut {
743        fn _decode(
744            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
745        ) -> Result<Vec<u8>, fidl::Error> {
746            let _response = fidl::client::decode_transaction_body::<
747                QueryableQueryResponse,
748                fdomain_client::fidl::FDomainResourceDialect,
749                0x2658edee9decfc06,
750            >(_buf?)?;
751            Ok(_response.protocol)
752        }
753        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<u8>>(
754            (),
755            0x2658edee9decfc06,
756            fidl::encoding::DynamicFlags::empty(),
757            _decode,
758        )
759    }
760}
761
762pub struct QueryableEventStream {
763    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
764}
765
766impl std::marker::Unpin for QueryableEventStream {}
767
768impl futures::stream::FusedStream for QueryableEventStream {
769    fn is_terminated(&self) -> bool {
770        self.event_receiver.is_terminated()
771    }
772}
773
774impl futures::Stream for QueryableEventStream {
775    type Item = Result<QueryableEvent, fidl::Error>;
776
777    fn poll_next(
778        mut self: std::pin::Pin<&mut Self>,
779        cx: &mut std::task::Context<'_>,
780    ) -> std::task::Poll<Option<Self::Item>> {
781        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
782            &mut self.event_receiver,
783            cx
784        )?) {
785            Some(buf) => std::task::Poll::Ready(Some(QueryableEvent::decode(buf))),
786            None => std::task::Poll::Ready(None),
787        }
788    }
789}
790
791#[derive(Debug)]
792pub enum QueryableEvent {}
793
794impl QueryableEvent {
795    /// Decodes a message buffer as a [`QueryableEvent`].
796    fn decode(
797        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
798    ) -> Result<QueryableEvent, fidl::Error> {
799        let (bytes, _handles) = buf.split_mut();
800        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
801        debug_assert_eq!(tx_header.tx_id, 0);
802        match tx_header.ordinal {
803            _ => Err(fidl::Error::UnknownOrdinal {
804                ordinal: tx_header.ordinal,
805                protocol_name:
806                    <QueryableMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
807            }),
808        }
809    }
810}
811
812/// A Stream of incoming requests for fuchsia.unknown/Queryable.
813pub struct QueryableRequestStream {
814    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
815    is_terminated: bool,
816}
817
818impl std::marker::Unpin for QueryableRequestStream {}
819
820impl futures::stream::FusedStream for QueryableRequestStream {
821    fn is_terminated(&self) -> bool {
822        self.is_terminated
823    }
824}
825
826impl fdomain_client::fidl::RequestStream for QueryableRequestStream {
827    type Protocol = QueryableMarker;
828    type ControlHandle = QueryableControlHandle;
829
830    fn from_channel(channel: fdomain_client::Channel) -> Self {
831        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
832    }
833
834    fn control_handle(&self) -> Self::ControlHandle {
835        QueryableControlHandle { inner: self.inner.clone() }
836    }
837
838    fn into_inner(
839        self,
840    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
841    {
842        (self.inner, self.is_terminated)
843    }
844
845    fn from_inner(
846        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
847        is_terminated: bool,
848    ) -> Self {
849        Self { inner, is_terminated }
850    }
851}
852
853impl futures::Stream for QueryableRequestStream {
854    type Item = Result<QueryableRequest, fidl::Error>;
855
856    fn poll_next(
857        mut self: std::pin::Pin<&mut Self>,
858        cx: &mut std::task::Context<'_>,
859    ) -> std::task::Poll<Option<Self::Item>> {
860        let this = &mut *self;
861        if this.inner.check_shutdown(cx) {
862            this.is_terminated = true;
863            return std::task::Poll::Ready(None);
864        }
865        if this.is_terminated {
866            panic!("polled QueryableRequestStream after completion");
867        }
868        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
869            |bytes, handles| {
870                match this.inner.channel().read_etc(cx, bytes, handles) {
871                    std::task::Poll::Ready(Ok(())) => {}
872                    std::task::Poll::Pending => return std::task::Poll::Pending,
873                    std::task::Poll::Ready(Err(None)) => {
874                        this.is_terminated = true;
875                        return std::task::Poll::Ready(None);
876                    }
877                    std::task::Poll::Ready(Err(Some(e))) => {
878                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
879                            e.into(),
880                        ))));
881                    }
882                }
883
884                // A message has been received from the channel
885                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
886
887                std::task::Poll::Ready(Some(match header.ordinal {
888                    0x2658edee9decfc06 => {
889                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
890                        let mut req = fidl::new_empty!(
891                            fidl::encoding::EmptyPayload,
892                            fdomain_client::fidl::FDomainResourceDialect
893                        );
894                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
895                        let control_handle = QueryableControlHandle { inner: this.inner.clone() };
896                        Ok(QueryableRequest::Query {
897                            responder: QueryableQueryResponder {
898                                control_handle: std::mem::ManuallyDrop::new(control_handle),
899                                tx_id: header.tx_id,
900                            },
901                        })
902                    }
903                    _ => Err(fidl::Error::UnknownOrdinal {
904                        ordinal: header.ordinal,
905                        protocol_name:
906                            <QueryableMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
907                    }),
908                }))
909            },
910        )
911    }
912}
913
914/// Provides a means of identifying a type-erased protocol.
915#[derive(Debug)]
916pub enum QueryableRequest {
917    Query { responder: QueryableQueryResponder },
918}
919
920impl QueryableRequest {
921    #[allow(irrefutable_let_patterns)]
922    pub fn into_query(self) -> Option<(QueryableQueryResponder)> {
923        if let QueryableRequest::Query { responder } = self { Some((responder)) } else { None }
924    }
925
926    /// Name of the method defined in FIDL
927    pub fn method_name(&self) -> &'static str {
928        match *self {
929            QueryableRequest::Query { .. } => "query",
930        }
931    }
932}
933
934#[derive(Debug, Clone)]
935pub struct QueryableControlHandle {
936    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
937}
938
939impl QueryableControlHandle {
940    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
941        self.inner.shutdown_with_epitaph(status.into())
942    }
943}
944
945impl fdomain_client::fidl::ControlHandle for QueryableControlHandle {
946    fn shutdown(&self) {
947        self.inner.shutdown()
948    }
949
950    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
951        self.inner.shutdown_with_epitaph(status)
952    }
953
954    fn is_closed(&self) -> bool {
955        self.inner.channel().is_closed()
956    }
957    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
958        self.inner.channel().on_closed()
959    }
960}
961
962impl QueryableControlHandle {}
963
964#[must_use = "FIDL methods require a response to be sent"]
965#[derive(Debug)]
966pub struct QueryableQueryResponder {
967    control_handle: std::mem::ManuallyDrop<QueryableControlHandle>,
968    tx_id: u32,
969}
970
971/// Set the the channel to be shutdown (see [`QueryableControlHandle::shutdown`])
972/// if the responder is dropped without sending a response, so that the client
973/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
974impl std::ops::Drop for QueryableQueryResponder {
975    fn drop(&mut self) {
976        self.control_handle.shutdown();
977        // Safety: drops once, never accessed again
978        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
979    }
980}
981
982impl fdomain_client::fidl::Responder for QueryableQueryResponder {
983    type ControlHandle = QueryableControlHandle;
984
985    fn control_handle(&self) -> &QueryableControlHandle {
986        &self.control_handle
987    }
988
989    fn drop_without_shutdown(mut self) {
990        // Safety: drops once, never accessed again due to mem::forget
991        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
992        // Prevent Drop from running (which would shut down the channel)
993        std::mem::forget(self);
994    }
995}
996
997impl QueryableQueryResponder {
998    /// Sends a response to the FIDL transaction.
999    ///
1000    /// Sets the channel to shutdown if an error occurs.
1001    pub fn send(self, mut protocol: &[u8]) -> Result<(), fidl::Error> {
1002        let _result = self.send_raw(protocol);
1003        if _result.is_err() {
1004            self.control_handle.shutdown();
1005        }
1006        self.drop_without_shutdown();
1007        _result
1008    }
1009
1010    /// Similar to "send" but does not shutdown the channel if an error occurs.
1011    pub fn send_no_shutdown_on_err(self, mut protocol: &[u8]) -> Result<(), fidl::Error> {
1012        let _result = self.send_raw(protocol);
1013        self.drop_without_shutdown();
1014        _result
1015    }
1016
1017    fn send_raw(&self, mut protocol: &[u8]) -> Result<(), fidl::Error> {
1018        self.control_handle.inner.send::<QueryableQueryResponse>(
1019            (protocol,),
1020            self.tx_id,
1021            0x2658edee9decfc06,
1022            fidl::encoding::DynamicFlags::empty(),
1023        )
1024    }
1025}
1026
1027mod internal {
1028    use super::*;
1029
1030    impl fidl::encoding::ResourceTypeMarker for CloneableCloneRequest {
1031        type Borrowed<'a> = &'a mut Self;
1032        fn take_or_borrow<'a>(
1033            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1034        ) -> Self::Borrowed<'a> {
1035            value
1036        }
1037    }
1038
1039    unsafe impl fidl::encoding::TypeMarker for CloneableCloneRequest {
1040        type Owned = Self;
1041
1042        #[inline(always)]
1043        fn inline_align(_context: fidl::encoding::Context) -> usize {
1044            4
1045        }
1046
1047        #[inline(always)]
1048        fn inline_size(_context: fidl::encoding::Context) -> usize {
1049            4
1050        }
1051    }
1052
1053    unsafe impl
1054        fidl::encoding::Encode<CloneableCloneRequest, fdomain_client::fidl::FDomainResourceDialect>
1055        for &mut CloneableCloneRequest
1056    {
1057        #[inline]
1058        unsafe fn encode(
1059            self,
1060            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
1061            offset: usize,
1062            _depth: fidl::encoding::Depth,
1063        ) -> fidl::Result<()> {
1064            encoder.debug_check_bounds::<CloneableCloneRequest>(offset);
1065            // Delegate to tuple encoding.
1066            fidl::encoding::Encode::<CloneableCloneRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
1067                (
1068                    <fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<CloneableMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.request),
1069                ),
1070                encoder, offset, _depth
1071            )
1072        }
1073    }
1074    unsafe impl<
1075        T0: fidl::encoding::Encode<
1076                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<CloneableMarker>>,
1077                fdomain_client::fidl::FDomainResourceDialect,
1078            >,
1079    >
1080        fidl::encoding::Encode<CloneableCloneRequest, fdomain_client::fidl::FDomainResourceDialect>
1081        for (T0,)
1082    {
1083        #[inline]
1084        unsafe fn encode(
1085            self,
1086            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
1087            offset: usize,
1088            depth: fidl::encoding::Depth,
1089        ) -> fidl::Result<()> {
1090            encoder.debug_check_bounds::<CloneableCloneRequest>(offset);
1091            // Zero out padding regions. There's no need to apply masks
1092            // because the unmasked parts will be overwritten by fields.
1093            // Write the fields.
1094            self.0.encode(encoder, offset + 0, depth)?;
1095            Ok(())
1096        }
1097    }
1098
1099    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
1100        for CloneableCloneRequest
1101    {
1102        #[inline(always)]
1103        fn new_empty() -> Self {
1104            Self {
1105                request: fidl::new_empty!(
1106                    fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<CloneableMarker>>,
1107                    fdomain_client::fidl::FDomainResourceDialect
1108                ),
1109            }
1110        }
1111
1112        #[inline]
1113        unsafe fn decode(
1114            &mut self,
1115            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
1116            offset: usize,
1117            _depth: fidl::encoding::Depth,
1118        ) -> fidl::Result<()> {
1119            decoder.debug_check_bounds::<Self>(offset);
1120            // Verify that padding bytes are zero.
1121            fidl::decode!(
1122                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<CloneableMarker>>,
1123                fdomain_client::fidl::FDomainResourceDialect,
1124                &mut self.request,
1125                decoder,
1126                offset + 0,
1127                _depth
1128            )?;
1129            Ok(())
1130        }
1131    }
1132}