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