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 fdomain_client::fidl::ControlHandle for CloneableControlHandle {
280    fn shutdown(&self) {
281        self.inner.shutdown()
282    }
283
284    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
285        self.inner.shutdown_with_epitaph(status)
286    }
287
288    fn is_closed(&self) -> bool {
289        self.inner.channel().is_closed()
290    }
291    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
292        self.inner.channel().on_closed()
293    }
294}
295
296impl CloneableControlHandle {}
297
298#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
299pub struct CloseableMarker;
300
301impl fdomain_client::fidl::ProtocolMarker for CloseableMarker {
302    type Proxy = CloseableProxy;
303    type RequestStream = CloseableRequestStream;
304
305    const DEBUG_NAME: &'static str = "(anonymous) Closeable";
306}
307pub type CloseableCloseResult = Result<(), i32>;
308
309pub trait CloseableProxyInterface: Send + Sync {
310    type CloseResponseFut: std::future::Future<Output = Result<CloseableCloseResult, fidl::Error>>
311        + Send;
312    fn r#close(&self) -> Self::CloseResponseFut;
313}
314
315#[derive(Debug, Clone)]
316pub struct CloseableProxy {
317    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
318}
319
320impl fdomain_client::fidl::Proxy for CloseableProxy {
321    type Protocol = CloseableMarker;
322
323    fn from_channel(inner: fdomain_client::Channel) -> Self {
324        Self::new(inner)
325    }
326
327    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
328        self.client.into_channel().map_err(|client| Self { client })
329    }
330
331    fn as_channel(&self) -> &fdomain_client::Channel {
332        self.client.as_channel()
333    }
334}
335
336impl CloseableProxy {
337    /// Create a new Proxy for fuchsia.unknown/Closeable.
338    pub fn new(channel: fdomain_client::Channel) -> Self {
339        let protocol_name = <CloseableMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
340        Self { client: fidl::client::Client::new(channel, protocol_name) }
341    }
342
343    /// Get a Stream of events from the remote end of the protocol.
344    ///
345    /// # Panics
346    ///
347    /// Panics if the event stream was already taken.
348    pub fn take_event_stream(&self) -> CloseableEventStream {
349        CloseableEventStream { event_receiver: self.client.take_event_receiver() }
350    }
351
352    /// Terminates the connection.
353    ///
354    /// After calling `Close`, the client must not send any other requests.
355    ///
356    /// Servers, after sending the status response, should close the connection
357    /// regardless of status and without sending an epitaph.
358    ///
359    /// Closing the client end of the channel should be semantically equivalent
360    /// to calling `Close` without knowing when the close has completed or its
361    /// status.
362    pub fn r#close(
363        &self,
364    ) -> fidl::client::QueryResponseFut<
365        CloseableCloseResult,
366        fdomain_client::fidl::FDomainResourceDialect,
367    > {
368        CloseableProxyInterface::r#close(self)
369    }
370}
371
372impl CloseableProxyInterface for CloseableProxy {
373    type CloseResponseFut = fidl::client::QueryResponseFut<
374        CloseableCloseResult,
375        fdomain_client::fidl::FDomainResourceDialect,
376    >;
377    fn r#close(&self) -> Self::CloseResponseFut {
378        fn _decode(
379            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
380        ) -> Result<CloseableCloseResult, fidl::Error> {
381            let _response = fidl::client::decode_transaction_body::<
382                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
383                fdomain_client::fidl::FDomainResourceDialect,
384                0x5ac5d459ad7f657e,
385            >(_buf?)?;
386            Ok(_response.map(|x| x))
387        }
388        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, CloseableCloseResult>(
389            (),
390            0x5ac5d459ad7f657e,
391            fidl::encoding::DynamicFlags::empty(),
392            _decode,
393        )
394    }
395}
396
397pub struct CloseableEventStream {
398    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
399}
400
401impl std::marker::Unpin for CloseableEventStream {}
402
403impl futures::stream::FusedStream for CloseableEventStream {
404    fn is_terminated(&self) -> bool {
405        self.event_receiver.is_terminated()
406    }
407}
408
409impl futures::Stream for CloseableEventStream {
410    type Item = Result<CloseableEvent, fidl::Error>;
411
412    fn poll_next(
413        mut self: std::pin::Pin<&mut Self>,
414        cx: &mut std::task::Context<'_>,
415    ) -> std::task::Poll<Option<Self::Item>> {
416        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
417            &mut self.event_receiver,
418            cx
419        )?) {
420            Some(buf) => std::task::Poll::Ready(Some(CloseableEvent::decode(buf))),
421            None => std::task::Poll::Ready(None),
422        }
423    }
424}
425
426#[derive(Debug)]
427pub enum CloseableEvent {}
428
429impl CloseableEvent {
430    /// Decodes a message buffer as a [`CloseableEvent`].
431    fn decode(
432        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
433    ) -> Result<CloseableEvent, fidl::Error> {
434        let (bytes, _handles) = buf.split_mut();
435        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
436        debug_assert_eq!(tx_header.tx_id, 0);
437        match tx_header.ordinal {
438            _ => Err(fidl::Error::UnknownOrdinal {
439                ordinal: tx_header.ordinal,
440                protocol_name:
441                    <CloseableMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
442            }),
443        }
444    }
445}
446
447/// A Stream of incoming requests for fuchsia.unknown/Closeable.
448pub struct CloseableRequestStream {
449    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
450    is_terminated: bool,
451}
452
453impl std::marker::Unpin for CloseableRequestStream {}
454
455impl futures::stream::FusedStream for CloseableRequestStream {
456    fn is_terminated(&self) -> bool {
457        self.is_terminated
458    }
459}
460
461impl fdomain_client::fidl::RequestStream for CloseableRequestStream {
462    type Protocol = CloseableMarker;
463    type ControlHandle = CloseableControlHandle;
464
465    fn from_channel(channel: fdomain_client::Channel) -> Self {
466        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
467    }
468
469    fn control_handle(&self) -> Self::ControlHandle {
470        CloseableControlHandle { inner: self.inner.clone() }
471    }
472
473    fn into_inner(
474        self,
475    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
476    {
477        (self.inner, self.is_terminated)
478    }
479
480    fn from_inner(
481        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
482        is_terminated: bool,
483    ) -> Self {
484        Self { inner, is_terminated }
485    }
486}
487
488impl futures::Stream for CloseableRequestStream {
489    type Item = Result<CloseableRequest, fidl::Error>;
490
491    fn poll_next(
492        mut self: std::pin::Pin<&mut Self>,
493        cx: &mut std::task::Context<'_>,
494    ) -> std::task::Poll<Option<Self::Item>> {
495        let this = &mut *self;
496        if this.inner.check_shutdown(cx) {
497            this.is_terminated = true;
498            return std::task::Poll::Ready(None);
499        }
500        if this.is_terminated {
501            panic!("polled CloseableRequestStream after completion");
502        }
503        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
504            |bytes, handles| {
505                match this.inner.channel().read_etc(cx, bytes, handles) {
506                    std::task::Poll::Ready(Ok(())) => {}
507                    std::task::Poll::Pending => return std::task::Poll::Pending,
508                    std::task::Poll::Ready(Err(None)) => {
509                        this.is_terminated = true;
510                        return std::task::Poll::Ready(None);
511                    }
512                    std::task::Poll::Ready(Err(Some(e))) => {
513                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
514                            e.into(),
515                        ))));
516                    }
517                }
518
519                // A message has been received from the channel
520                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
521
522                std::task::Poll::Ready(Some(match header.ordinal {
523                    0x5ac5d459ad7f657e => {
524                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
525                        let mut req = fidl::new_empty!(
526                            fidl::encoding::EmptyPayload,
527                            fdomain_client::fidl::FDomainResourceDialect
528                        );
529                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
530                        let control_handle = CloseableControlHandle { inner: this.inner.clone() };
531                        Ok(CloseableRequest::Close {
532                            responder: CloseableCloseResponder {
533                                control_handle: std::mem::ManuallyDrop::new(control_handle),
534                                tx_id: header.tx_id,
535                            },
536                        })
537                    }
538                    _ => Err(fidl::Error::UnknownOrdinal {
539                        ordinal: header.ordinal,
540                        protocol_name:
541                            <CloseableMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
542                    }),
543                }))
544            },
545        )
546    }
547}
548
549/// Provides a means of synchronously closing a connection.
550#[derive(Debug)]
551pub enum CloseableRequest {
552    /// Terminates the connection.
553    ///
554    /// After calling `Close`, the client must not send any other requests.
555    ///
556    /// Servers, after sending the status response, should close the connection
557    /// regardless of status and without sending an epitaph.
558    ///
559    /// Closing the client end of the channel should be semantically equivalent
560    /// to calling `Close` without knowing when the close has completed or its
561    /// status.
562    Close { responder: CloseableCloseResponder },
563}
564
565impl CloseableRequest {
566    #[allow(irrefutable_let_patterns)]
567    pub fn into_close(self) -> Option<(CloseableCloseResponder)> {
568        if let CloseableRequest::Close { responder } = self { Some((responder)) } else { None }
569    }
570
571    /// Name of the method defined in FIDL
572    pub fn method_name(&self) -> &'static str {
573        match *self {
574            CloseableRequest::Close { .. } => "close",
575        }
576    }
577}
578
579#[derive(Debug, Clone)]
580pub struct CloseableControlHandle {
581    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
582}
583
584impl fdomain_client::fidl::ControlHandle for CloseableControlHandle {
585    fn shutdown(&self) {
586        self.inner.shutdown()
587    }
588
589    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
590        self.inner.shutdown_with_epitaph(status)
591    }
592
593    fn is_closed(&self) -> bool {
594        self.inner.channel().is_closed()
595    }
596    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
597        self.inner.channel().on_closed()
598    }
599}
600
601impl CloseableControlHandle {}
602
603#[must_use = "FIDL methods require a response to be sent"]
604#[derive(Debug)]
605pub struct CloseableCloseResponder {
606    control_handle: std::mem::ManuallyDrop<CloseableControlHandle>,
607    tx_id: u32,
608}
609
610/// Set the the channel to be shutdown (see [`CloseableControlHandle::shutdown`])
611/// if the responder is dropped without sending a response, so that the client
612/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
613impl std::ops::Drop for CloseableCloseResponder {
614    fn drop(&mut self) {
615        self.control_handle.shutdown();
616        // Safety: drops once, never accessed again
617        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
618    }
619}
620
621impl fdomain_client::fidl::Responder for CloseableCloseResponder {
622    type ControlHandle = CloseableControlHandle;
623
624    fn control_handle(&self) -> &CloseableControlHandle {
625        &self.control_handle
626    }
627
628    fn drop_without_shutdown(mut self) {
629        // Safety: drops once, never accessed again due to mem::forget
630        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
631        // Prevent Drop from running (which would shut down the channel)
632        std::mem::forget(self);
633    }
634}
635
636impl CloseableCloseResponder {
637    /// Sends a response to the FIDL transaction.
638    ///
639    /// Sets the channel to shutdown if an error occurs.
640    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
641        let _result = self.send_raw(result);
642        if _result.is_err() {
643            self.control_handle.shutdown();
644        }
645        self.drop_without_shutdown();
646        _result
647    }
648
649    /// Similar to "send" but does not shutdown the channel if an error occurs.
650    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
651        let _result = self.send_raw(result);
652        self.drop_without_shutdown();
653        _result
654    }
655
656    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
657        self.control_handle
658            .inner
659            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
660                result,
661                self.tx_id,
662                0x5ac5d459ad7f657e,
663                fidl::encoding::DynamicFlags::empty(),
664            )
665    }
666}
667
668#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
669pub struct QueryableMarker;
670
671impl fdomain_client::fidl::ProtocolMarker for QueryableMarker {
672    type Proxy = QueryableProxy;
673    type RequestStream = QueryableRequestStream;
674
675    const DEBUG_NAME: &'static str = "(anonymous) Queryable";
676}
677
678pub trait QueryableProxyInterface: Send + Sync {
679    type QueryResponseFut: std::future::Future<Output = Result<Vec<u8>, fidl::Error>> + Send;
680    fn r#query(&self) -> Self::QueryResponseFut;
681}
682
683#[derive(Debug, Clone)]
684pub struct QueryableProxy {
685    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
686}
687
688impl fdomain_client::fidl::Proxy for QueryableProxy {
689    type Protocol = QueryableMarker;
690
691    fn from_channel(inner: fdomain_client::Channel) -> Self {
692        Self::new(inner)
693    }
694
695    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
696        self.client.into_channel().map_err(|client| Self { client })
697    }
698
699    fn as_channel(&self) -> &fdomain_client::Channel {
700        self.client.as_channel()
701    }
702}
703
704impl QueryableProxy {
705    /// Create a new Proxy for fuchsia.unknown/Queryable.
706    pub fn new(channel: fdomain_client::Channel) -> Self {
707        let protocol_name = <QueryableMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
708        Self { client: fidl::client::Client::new(channel, protocol_name) }
709    }
710
711    /// Get a Stream of events from the remote end of the protocol.
712    ///
713    /// # Panics
714    ///
715    /// Panics if the event stream was already taken.
716    pub fn take_event_stream(&self) -> QueryableEventStream {
717        QueryableEventStream { event_receiver: self.client.take_event_receiver() }
718    }
719
720    pub fn r#query(
721        &self,
722    ) -> fidl::client::QueryResponseFut<Vec<u8>, fdomain_client::fidl::FDomainResourceDialect> {
723        QueryableProxyInterface::r#query(self)
724    }
725}
726
727impl QueryableProxyInterface for QueryableProxy {
728    type QueryResponseFut =
729        fidl::client::QueryResponseFut<Vec<u8>, fdomain_client::fidl::FDomainResourceDialect>;
730    fn r#query(&self) -> Self::QueryResponseFut {
731        fn _decode(
732            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
733        ) -> Result<Vec<u8>, fidl::Error> {
734            let _response = fidl::client::decode_transaction_body::<
735                QueryableQueryResponse,
736                fdomain_client::fidl::FDomainResourceDialect,
737                0x2658edee9decfc06,
738            >(_buf?)?;
739            Ok(_response.protocol)
740        }
741        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<u8>>(
742            (),
743            0x2658edee9decfc06,
744            fidl::encoding::DynamicFlags::empty(),
745            _decode,
746        )
747    }
748}
749
750pub struct QueryableEventStream {
751    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
752}
753
754impl std::marker::Unpin for QueryableEventStream {}
755
756impl futures::stream::FusedStream for QueryableEventStream {
757    fn is_terminated(&self) -> bool {
758        self.event_receiver.is_terminated()
759    }
760}
761
762impl futures::Stream for QueryableEventStream {
763    type Item = Result<QueryableEvent, fidl::Error>;
764
765    fn poll_next(
766        mut self: std::pin::Pin<&mut Self>,
767        cx: &mut std::task::Context<'_>,
768    ) -> std::task::Poll<Option<Self::Item>> {
769        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
770            &mut self.event_receiver,
771            cx
772        )?) {
773            Some(buf) => std::task::Poll::Ready(Some(QueryableEvent::decode(buf))),
774            None => std::task::Poll::Ready(None),
775        }
776    }
777}
778
779#[derive(Debug)]
780pub enum QueryableEvent {}
781
782impl QueryableEvent {
783    /// Decodes a message buffer as a [`QueryableEvent`].
784    fn decode(
785        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
786    ) -> Result<QueryableEvent, fidl::Error> {
787        let (bytes, _handles) = buf.split_mut();
788        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
789        debug_assert_eq!(tx_header.tx_id, 0);
790        match tx_header.ordinal {
791            _ => Err(fidl::Error::UnknownOrdinal {
792                ordinal: tx_header.ordinal,
793                protocol_name:
794                    <QueryableMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
795            }),
796        }
797    }
798}
799
800/// A Stream of incoming requests for fuchsia.unknown/Queryable.
801pub struct QueryableRequestStream {
802    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
803    is_terminated: bool,
804}
805
806impl std::marker::Unpin for QueryableRequestStream {}
807
808impl futures::stream::FusedStream for QueryableRequestStream {
809    fn is_terminated(&self) -> bool {
810        self.is_terminated
811    }
812}
813
814impl fdomain_client::fidl::RequestStream for QueryableRequestStream {
815    type Protocol = QueryableMarker;
816    type ControlHandle = QueryableControlHandle;
817
818    fn from_channel(channel: fdomain_client::Channel) -> Self {
819        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
820    }
821
822    fn control_handle(&self) -> Self::ControlHandle {
823        QueryableControlHandle { inner: self.inner.clone() }
824    }
825
826    fn into_inner(
827        self,
828    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
829    {
830        (self.inner, self.is_terminated)
831    }
832
833    fn from_inner(
834        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
835        is_terminated: bool,
836    ) -> Self {
837        Self { inner, is_terminated }
838    }
839}
840
841impl futures::Stream for QueryableRequestStream {
842    type Item = Result<QueryableRequest, fidl::Error>;
843
844    fn poll_next(
845        mut self: std::pin::Pin<&mut Self>,
846        cx: &mut std::task::Context<'_>,
847    ) -> std::task::Poll<Option<Self::Item>> {
848        let this = &mut *self;
849        if this.inner.check_shutdown(cx) {
850            this.is_terminated = true;
851            return std::task::Poll::Ready(None);
852        }
853        if this.is_terminated {
854            panic!("polled QueryableRequestStream after completion");
855        }
856        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
857            |bytes, handles| {
858                match this.inner.channel().read_etc(cx, bytes, handles) {
859                    std::task::Poll::Ready(Ok(())) => {}
860                    std::task::Poll::Pending => return std::task::Poll::Pending,
861                    std::task::Poll::Ready(Err(None)) => {
862                        this.is_terminated = true;
863                        return std::task::Poll::Ready(None);
864                    }
865                    std::task::Poll::Ready(Err(Some(e))) => {
866                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
867                            e.into(),
868                        ))));
869                    }
870                }
871
872                // A message has been received from the channel
873                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
874
875                std::task::Poll::Ready(Some(match header.ordinal {
876                    0x2658edee9decfc06 => {
877                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
878                        let mut req = fidl::new_empty!(
879                            fidl::encoding::EmptyPayload,
880                            fdomain_client::fidl::FDomainResourceDialect
881                        );
882                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
883                        let control_handle = QueryableControlHandle { inner: this.inner.clone() };
884                        Ok(QueryableRequest::Query {
885                            responder: QueryableQueryResponder {
886                                control_handle: std::mem::ManuallyDrop::new(control_handle),
887                                tx_id: header.tx_id,
888                            },
889                        })
890                    }
891                    _ => Err(fidl::Error::UnknownOrdinal {
892                        ordinal: header.ordinal,
893                        protocol_name:
894                            <QueryableMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
895                    }),
896                }))
897            },
898        )
899    }
900}
901
902/// Provides a means of identifying a type-erased protocol.
903#[derive(Debug)]
904pub enum QueryableRequest {
905    Query { responder: QueryableQueryResponder },
906}
907
908impl QueryableRequest {
909    #[allow(irrefutable_let_patterns)]
910    pub fn into_query(self) -> Option<(QueryableQueryResponder)> {
911        if let QueryableRequest::Query { responder } = self { Some((responder)) } else { None }
912    }
913
914    /// Name of the method defined in FIDL
915    pub fn method_name(&self) -> &'static str {
916        match *self {
917            QueryableRequest::Query { .. } => "query",
918        }
919    }
920}
921
922#[derive(Debug, Clone)]
923pub struct QueryableControlHandle {
924    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
925}
926
927impl fdomain_client::fidl::ControlHandle for QueryableControlHandle {
928    fn shutdown(&self) {
929        self.inner.shutdown()
930    }
931
932    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
933        self.inner.shutdown_with_epitaph(status)
934    }
935
936    fn is_closed(&self) -> bool {
937        self.inner.channel().is_closed()
938    }
939    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
940        self.inner.channel().on_closed()
941    }
942}
943
944impl QueryableControlHandle {}
945
946#[must_use = "FIDL methods require a response to be sent"]
947#[derive(Debug)]
948pub struct QueryableQueryResponder {
949    control_handle: std::mem::ManuallyDrop<QueryableControlHandle>,
950    tx_id: u32,
951}
952
953/// Set the the channel to be shutdown (see [`QueryableControlHandle::shutdown`])
954/// if the responder is dropped without sending a response, so that the client
955/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
956impl std::ops::Drop for QueryableQueryResponder {
957    fn drop(&mut self) {
958        self.control_handle.shutdown();
959        // Safety: drops once, never accessed again
960        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
961    }
962}
963
964impl fdomain_client::fidl::Responder for QueryableQueryResponder {
965    type ControlHandle = QueryableControlHandle;
966
967    fn control_handle(&self) -> &QueryableControlHandle {
968        &self.control_handle
969    }
970
971    fn drop_without_shutdown(mut self) {
972        // Safety: drops once, never accessed again due to mem::forget
973        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
974        // Prevent Drop from running (which would shut down the channel)
975        std::mem::forget(self);
976    }
977}
978
979impl QueryableQueryResponder {
980    /// Sends a response to the FIDL transaction.
981    ///
982    /// Sets the channel to shutdown if an error occurs.
983    pub fn send(self, mut protocol: &[u8]) -> Result<(), fidl::Error> {
984        let _result = self.send_raw(protocol);
985        if _result.is_err() {
986            self.control_handle.shutdown();
987        }
988        self.drop_without_shutdown();
989        _result
990    }
991
992    /// Similar to "send" but does not shutdown the channel if an error occurs.
993    pub fn send_no_shutdown_on_err(self, mut protocol: &[u8]) -> Result<(), fidl::Error> {
994        let _result = self.send_raw(protocol);
995        self.drop_without_shutdown();
996        _result
997    }
998
999    fn send_raw(&self, mut protocol: &[u8]) -> Result<(), fidl::Error> {
1000        self.control_handle.inner.send::<QueryableQueryResponse>(
1001            (protocol,),
1002            self.tx_id,
1003            0x2658edee9decfc06,
1004            fidl::encoding::DynamicFlags::empty(),
1005        )
1006    }
1007}
1008
1009mod internal {
1010    use super::*;
1011
1012    impl fidl::encoding::ResourceTypeMarker for CloneableCloneRequest {
1013        type Borrowed<'a> = &'a mut Self;
1014        fn take_or_borrow<'a>(
1015            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1016        ) -> Self::Borrowed<'a> {
1017            value
1018        }
1019    }
1020
1021    unsafe impl fidl::encoding::TypeMarker for CloneableCloneRequest {
1022        type Owned = Self;
1023
1024        #[inline(always)]
1025        fn inline_align(_context: fidl::encoding::Context) -> usize {
1026            4
1027        }
1028
1029        #[inline(always)]
1030        fn inline_size(_context: fidl::encoding::Context) -> usize {
1031            4
1032        }
1033    }
1034
1035    unsafe impl
1036        fidl::encoding::Encode<CloneableCloneRequest, fdomain_client::fidl::FDomainResourceDialect>
1037        for &mut CloneableCloneRequest
1038    {
1039        #[inline]
1040        unsafe fn encode(
1041            self,
1042            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
1043            offset: usize,
1044            _depth: fidl::encoding::Depth,
1045        ) -> fidl::Result<()> {
1046            encoder.debug_check_bounds::<CloneableCloneRequest>(offset);
1047            // Delegate to tuple encoding.
1048            fidl::encoding::Encode::<CloneableCloneRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
1049                (
1050                    <fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<CloneableMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.request),
1051                ),
1052                encoder, offset, _depth
1053            )
1054        }
1055    }
1056    unsafe impl<
1057        T0: fidl::encoding::Encode<
1058                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<CloneableMarker>>,
1059                fdomain_client::fidl::FDomainResourceDialect,
1060            >,
1061    >
1062        fidl::encoding::Encode<CloneableCloneRequest, fdomain_client::fidl::FDomainResourceDialect>
1063        for (T0,)
1064    {
1065        #[inline]
1066        unsafe fn encode(
1067            self,
1068            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
1069            offset: usize,
1070            depth: fidl::encoding::Depth,
1071        ) -> fidl::Result<()> {
1072            encoder.debug_check_bounds::<CloneableCloneRequest>(offset);
1073            // Zero out padding regions. There's no need to apply masks
1074            // because the unmasked parts will be overwritten by fields.
1075            // Write the fields.
1076            self.0.encode(encoder, offset + 0, depth)?;
1077            Ok(())
1078        }
1079    }
1080
1081    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
1082        for CloneableCloneRequest
1083    {
1084        #[inline(always)]
1085        fn new_empty() -> Self {
1086            Self {
1087                request: fidl::new_empty!(
1088                    fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<CloneableMarker>>,
1089                    fdomain_client::fidl::FDomainResourceDialect
1090                ),
1091            }
1092        }
1093
1094        #[inline]
1095        unsafe fn decode(
1096            &mut self,
1097            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
1098            offset: usize,
1099            _depth: fidl::encoding::Depth,
1100        ) -> fidl::Result<()> {
1101            decoder.debug_check_bounds::<Self>(offset);
1102            // Verify that padding bytes are zero.
1103            fidl::decode!(
1104                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<CloneableMarker>>,
1105                fdomain_client::fidl::FDomainResourceDialect,
1106                &mut self.request,
1107                decoder,
1108                offset + 0,
1109                _depth
1110            )?;
1111            Ok(())
1112        }
1113    }
1114}