Skip to main content

fidl_fuchsia_fdomain/
fidl_fuchsia_fdomain.rs

1// WARNING: This file is machine generated by fidlgen.
2
3// fidl_experiment = allow_arbitrary_error_types
4// fidl_experiment = no_resource_attribute
5
6#![warn(clippy::all)]
7#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
8
9use bitflags::bitflags;
10use fidl::client::QueryResponseFut;
11use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
12use fidl::endpoints::{ControlHandle as _, Responder as _};
13pub use fidl_fuchsia_fdomain_common::*;
14use futures::future::{self, MaybeDone, TryFutureExt};
15use zx_status;
16
17#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
18pub struct ChannelMarker;
19
20impl fidl::endpoints::ProtocolMarker for ChannelMarker {
21    type Proxy = ChannelProxy;
22    type RequestStream = ChannelRequestStream;
23    #[cfg(target_os = "fuchsia")]
24    type SynchronousProxy = ChannelSynchronousProxy;
25
26    const DEBUG_NAME: &'static str = "(anonymous) Channel";
27}
28pub type ChannelCreateChannelResult = Result<(), Error>;
29pub type ChannelReadChannelResult = Result<(Vec<u8>, Vec<HandleInfo>), Error>;
30pub type ChannelWriteChannelResult = Result<(), WriteChannelError>;
31pub type ChannelReadChannelStreamingStartResult = Result<(), Error>;
32pub type ChannelReadChannelStreamingStopResult = Result<(), Error>;
33
34pub trait ChannelProxyInterface: Send + Sync {
35    type CreateChannelResponseFut: std::future::Future<Output = Result<ChannelCreateChannelResult, fidl::Error>>
36        + Send;
37    fn r#create_channel(&self, handles: &[NewHandleId; 2]) -> Self::CreateChannelResponseFut;
38    type ReadChannelResponseFut: std::future::Future<Output = Result<ChannelReadChannelResult, fidl::Error>>
39        + Send;
40    fn r#read_channel(&self, handle: &HandleId) -> Self::ReadChannelResponseFut;
41    type WriteChannelResponseFut: std::future::Future<Output = Result<ChannelWriteChannelResult, fidl::Error>>
42        + Send;
43    fn r#write_channel(
44        &self,
45        handle: &HandleId,
46        data: &[u8],
47        handles: &Handles,
48    ) -> Self::WriteChannelResponseFut;
49    type ReadChannelStreamingStartResponseFut: std::future::Future<Output = Result<ChannelReadChannelStreamingStartResult, fidl::Error>>
50        + Send;
51    fn r#read_channel_streaming_start(
52        &self,
53        handle: &HandleId,
54    ) -> Self::ReadChannelStreamingStartResponseFut;
55    type ReadChannelStreamingStopResponseFut: std::future::Future<Output = Result<ChannelReadChannelStreamingStopResult, fidl::Error>>
56        + Send;
57    fn r#read_channel_streaming_stop(
58        &self,
59        handle: &HandleId,
60    ) -> Self::ReadChannelStreamingStopResponseFut;
61}
62#[derive(Debug)]
63#[cfg(target_os = "fuchsia")]
64pub struct ChannelSynchronousProxy {
65    client: fidl::client::sync::Client,
66}
67
68#[cfg(target_os = "fuchsia")]
69impl fidl::endpoints::SynchronousProxy for ChannelSynchronousProxy {
70    type Proxy = ChannelProxy;
71    type Protocol = ChannelMarker;
72
73    fn from_channel(inner: fidl::Channel) -> Self {
74        Self::new(inner)
75    }
76
77    fn into_channel(self) -> fidl::Channel {
78        self.client.into_channel()
79    }
80
81    fn as_channel(&self) -> &fidl::Channel {
82        self.client.as_channel()
83    }
84}
85
86#[cfg(target_os = "fuchsia")]
87impl ChannelSynchronousProxy {
88    pub fn new(channel: fidl::Channel) -> Self {
89        Self { client: fidl::client::sync::Client::new(channel) }
90    }
91
92    pub fn into_channel(self) -> fidl::Channel {
93        self.client.into_channel()
94    }
95
96    /// Waits until an event arrives and returns it. It is safe for other
97    /// threads to make concurrent requests while waiting for an event.
98    pub fn wait_for_event(
99        &self,
100        deadline: zx::MonotonicInstant,
101    ) -> Result<ChannelEvent, fidl::Error> {
102        ChannelEvent::decode(self.client.wait_for_event::<ChannelMarker>(deadline)?)
103    }
104
105    /// Create a new channel in this FDomain and return both its ends.
106    pub fn r#create_channel(
107        &self,
108        mut handles: &[NewHandleId; 2],
109        ___deadline: zx::MonotonicInstant,
110    ) -> Result<ChannelCreateChannelResult, fidl::Error> {
111        let _response = self.client.send_query::<
112            ChannelCreateChannelRequest,
113            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
114            ChannelMarker,
115        >(
116            (handles,),
117            0x182d38bfe88673b5,
118            fidl::encoding::DynamicFlags::FLEXIBLE,
119            ___deadline,
120        )?
121        .into_result::<ChannelMarker>("create_channel")?;
122        Ok(_response.map(|x| x))
123    }
124
125    /// Read a message from a channel. This method will fail if the channel is currently being read
126    /// using the streaming read functions.
127    ///
128    /// Note that this method is not like zx_channel_read in that it will not
129    /// return `SHOULD_WAIT` but will instead delay returning until there is data
130    /// to return.
131    pub fn r#read_channel(
132        &self,
133        mut handle: &HandleId,
134        ___deadline: zx::MonotonicInstant,
135    ) -> Result<ChannelReadChannelResult, fidl::Error> {
136        let _response = self.client.send_query::<
137            ChannelReadChannelRequest,
138            fidl::encoding::FlexibleResultType<ChannelMessage, Error>,
139            ChannelMarker,
140        >(
141            (handle,),
142            0x6ef47bf27bf7d050,
143            fidl::encoding::DynamicFlags::FLEXIBLE,
144            ___deadline,
145        )?
146        .into_result::<ChannelMarker>("read_channel")?;
147        Ok(_response.map(|x| (x.data, x.handles)))
148    }
149
150    /// Write to a channel. Handles are always consumed.
151    pub fn r#write_channel(
152        &self,
153        mut handle: &HandleId,
154        mut data: &[u8],
155        mut handles: &Handles,
156        ___deadline: zx::MonotonicInstant,
157    ) -> Result<ChannelWriteChannelResult, fidl::Error> {
158        let _response = self.client.send_query::<
159            ChannelWriteChannelRequest,
160            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, WriteChannelError>,
161            ChannelMarker,
162        >(
163            (handle, data, handles,),
164            0x75a2559b945d5eb5,
165            fidl::encoding::DynamicFlags::FLEXIBLE,
166            ___deadline,
167        )?
168        .into_result::<ChannelMarker>("write_channel")?;
169        Ok(_response.map(|x| x))
170    }
171
172    /// Starts reading from the given channel. Data is returned via the `ChannelStreamingData` event.
173    /// That event will occur repeatedly until `ReadChannelStreamingStop` is called for the same handle
174    /// or the event indicates the handle is closed.
175    pub fn r#read_channel_streaming_start(
176        &self,
177        mut handle: &HandleId,
178        ___deadline: zx::MonotonicInstant,
179    ) -> Result<ChannelReadChannelStreamingStartResult, fidl::Error> {
180        let _response = self.client.send_query::<
181            ChannelReadChannelStreamingStartRequest,
182            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
183            ChannelMarker,
184        >(
185            (handle,),
186            0x3c73e85476a203df,
187            fidl::encoding::DynamicFlags::FLEXIBLE,
188            ___deadline,
189        )?
190        .into_result::<ChannelMarker>("read_channel_streaming_start")?;
191        Ok(_response.map(|x| x))
192    }
193
194    /// Stop asynchronous reading from the given channel.
195    pub fn r#read_channel_streaming_stop(
196        &self,
197        mut handle: &HandleId,
198        ___deadline: zx::MonotonicInstant,
199    ) -> Result<ChannelReadChannelStreamingStopResult, fidl::Error> {
200        let _response = self.client.send_query::<
201            ChannelReadChannelStreamingStopRequest,
202            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
203            ChannelMarker,
204        >(
205            (handle,),
206            0x56f21d6ed68186e0,
207            fidl::encoding::DynamicFlags::FLEXIBLE,
208            ___deadline,
209        )?
210        .into_result::<ChannelMarker>("read_channel_streaming_stop")?;
211        Ok(_response.map(|x| x))
212    }
213}
214
215#[cfg(target_os = "fuchsia")]
216impl From<ChannelSynchronousProxy> for zx::NullableHandle {
217    fn from(value: ChannelSynchronousProxy) -> Self {
218        value.into_channel().into()
219    }
220}
221
222#[cfg(target_os = "fuchsia")]
223impl From<fidl::Channel> for ChannelSynchronousProxy {
224    fn from(value: fidl::Channel) -> Self {
225        Self::new(value)
226    }
227}
228
229#[cfg(target_os = "fuchsia")]
230impl fidl::endpoints::FromClient for ChannelSynchronousProxy {
231    type Protocol = ChannelMarker;
232
233    fn from_client(value: fidl::endpoints::ClientEnd<ChannelMarker>) -> Self {
234        Self::new(value.into_channel())
235    }
236}
237
238#[derive(Debug, Clone)]
239pub struct ChannelProxy {
240    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
241}
242
243impl fidl::endpoints::Proxy for ChannelProxy {
244    type Protocol = ChannelMarker;
245
246    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
247        Self::new(inner)
248    }
249
250    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
251        self.client.into_channel().map_err(|client| Self { client })
252    }
253
254    fn as_channel(&self) -> &::fidl::AsyncChannel {
255        self.client.as_channel()
256    }
257}
258
259impl ChannelProxy {
260    /// Create a new Proxy for fuchsia.fdomain/Channel.
261    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
262        let protocol_name = <ChannelMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
263        Self { client: fidl::client::Client::new(channel, protocol_name) }
264    }
265
266    /// Get a Stream of events from the remote end of the protocol.
267    ///
268    /// # Panics
269    ///
270    /// Panics if the event stream was already taken.
271    pub fn take_event_stream(&self) -> ChannelEventStream {
272        ChannelEventStream { event_receiver: self.client.take_event_receiver() }
273    }
274
275    /// Create a new channel in this FDomain and return both its ends.
276    pub fn r#create_channel(
277        &self,
278        mut handles: &[NewHandleId; 2],
279    ) -> fidl::client::QueryResponseFut<
280        ChannelCreateChannelResult,
281        fidl::encoding::DefaultFuchsiaResourceDialect,
282    > {
283        ChannelProxyInterface::r#create_channel(self, handles)
284    }
285
286    /// Read a message from a channel. This method will fail if the channel is currently being read
287    /// using the streaming read functions.
288    ///
289    /// Note that this method is not like zx_channel_read in that it will not
290    /// return `SHOULD_WAIT` but will instead delay returning until there is data
291    /// to return.
292    pub fn r#read_channel(
293        &self,
294        mut handle: &HandleId,
295    ) -> fidl::client::QueryResponseFut<
296        ChannelReadChannelResult,
297        fidl::encoding::DefaultFuchsiaResourceDialect,
298    > {
299        ChannelProxyInterface::r#read_channel(self, handle)
300    }
301
302    /// Write to a channel. Handles are always consumed.
303    pub fn r#write_channel(
304        &self,
305        mut handle: &HandleId,
306        mut data: &[u8],
307        mut handles: &Handles,
308    ) -> fidl::client::QueryResponseFut<
309        ChannelWriteChannelResult,
310        fidl::encoding::DefaultFuchsiaResourceDialect,
311    > {
312        ChannelProxyInterface::r#write_channel(self, handle, data, handles)
313    }
314
315    /// Starts reading from the given channel. Data is returned via the `ChannelStreamingData` event.
316    /// That event will occur repeatedly until `ReadChannelStreamingStop` is called for the same handle
317    /// or the event indicates the handle is closed.
318    pub fn r#read_channel_streaming_start(
319        &self,
320        mut handle: &HandleId,
321    ) -> fidl::client::QueryResponseFut<
322        ChannelReadChannelStreamingStartResult,
323        fidl::encoding::DefaultFuchsiaResourceDialect,
324    > {
325        ChannelProxyInterface::r#read_channel_streaming_start(self, handle)
326    }
327
328    /// Stop asynchronous reading from the given channel.
329    pub fn r#read_channel_streaming_stop(
330        &self,
331        mut handle: &HandleId,
332    ) -> fidl::client::QueryResponseFut<
333        ChannelReadChannelStreamingStopResult,
334        fidl::encoding::DefaultFuchsiaResourceDialect,
335    > {
336        ChannelProxyInterface::r#read_channel_streaming_stop(self, handle)
337    }
338}
339
340impl ChannelProxyInterface for ChannelProxy {
341    type CreateChannelResponseFut = fidl::client::QueryResponseFut<
342        ChannelCreateChannelResult,
343        fidl::encoding::DefaultFuchsiaResourceDialect,
344    >;
345    fn r#create_channel(&self, mut handles: &[NewHandleId; 2]) -> Self::CreateChannelResponseFut {
346        fn _decode(
347            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
348        ) -> Result<ChannelCreateChannelResult, fidl::Error> {
349            let _response = fidl::client::decode_transaction_body::<
350                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
351                fidl::encoding::DefaultFuchsiaResourceDialect,
352                0x182d38bfe88673b5,
353            >(_buf?)?
354            .into_result::<ChannelMarker>("create_channel")?;
355            Ok(_response.map(|x| x))
356        }
357        self.client
358            .send_query_and_decode::<ChannelCreateChannelRequest, ChannelCreateChannelResult>(
359                (handles,),
360                0x182d38bfe88673b5,
361                fidl::encoding::DynamicFlags::FLEXIBLE,
362                _decode,
363            )
364    }
365
366    type ReadChannelResponseFut = fidl::client::QueryResponseFut<
367        ChannelReadChannelResult,
368        fidl::encoding::DefaultFuchsiaResourceDialect,
369    >;
370    fn r#read_channel(&self, mut handle: &HandleId) -> Self::ReadChannelResponseFut {
371        fn _decode(
372            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
373        ) -> Result<ChannelReadChannelResult, fidl::Error> {
374            let _response = fidl::client::decode_transaction_body::<
375                fidl::encoding::FlexibleResultType<ChannelMessage, Error>,
376                fidl::encoding::DefaultFuchsiaResourceDialect,
377                0x6ef47bf27bf7d050,
378            >(_buf?)?
379            .into_result::<ChannelMarker>("read_channel")?;
380            Ok(_response.map(|x| (x.data, x.handles)))
381        }
382        self.client.send_query_and_decode::<ChannelReadChannelRequest, ChannelReadChannelResult>(
383            (handle,),
384            0x6ef47bf27bf7d050,
385            fidl::encoding::DynamicFlags::FLEXIBLE,
386            _decode,
387        )
388    }
389
390    type WriteChannelResponseFut = fidl::client::QueryResponseFut<
391        ChannelWriteChannelResult,
392        fidl::encoding::DefaultFuchsiaResourceDialect,
393    >;
394    fn r#write_channel(
395        &self,
396        mut handle: &HandleId,
397        mut data: &[u8],
398        mut handles: &Handles,
399    ) -> Self::WriteChannelResponseFut {
400        fn _decode(
401            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
402        ) -> Result<ChannelWriteChannelResult, fidl::Error> {
403            let _response = fidl::client::decode_transaction_body::<
404                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, WriteChannelError>,
405                fidl::encoding::DefaultFuchsiaResourceDialect,
406                0x75a2559b945d5eb5,
407            >(_buf?)?
408            .into_result::<ChannelMarker>("write_channel")?;
409            Ok(_response.map(|x| x))
410        }
411        self.client.send_query_and_decode::<ChannelWriteChannelRequest, ChannelWriteChannelResult>(
412            (handle, data, handles),
413            0x75a2559b945d5eb5,
414            fidl::encoding::DynamicFlags::FLEXIBLE,
415            _decode,
416        )
417    }
418
419    type ReadChannelStreamingStartResponseFut = fidl::client::QueryResponseFut<
420        ChannelReadChannelStreamingStartResult,
421        fidl::encoding::DefaultFuchsiaResourceDialect,
422    >;
423    fn r#read_channel_streaming_start(
424        &self,
425        mut handle: &HandleId,
426    ) -> Self::ReadChannelStreamingStartResponseFut {
427        fn _decode(
428            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
429        ) -> Result<ChannelReadChannelStreamingStartResult, fidl::Error> {
430            let _response = fidl::client::decode_transaction_body::<
431                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
432                fidl::encoding::DefaultFuchsiaResourceDialect,
433                0x3c73e85476a203df,
434            >(_buf?)?
435            .into_result::<ChannelMarker>("read_channel_streaming_start")?;
436            Ok(_response.map(|x| x))
437        }
438        self.client.send_query_and_decode::<
439            ChannelReadChannelStreamingStartRequest,
440            ChannelReadChannelStreamingStartResult,
441        >(
442            (handle,),
443            0x3c73e85476a203df,
444            fidl::encoding::DynamicFlags::FLEXIBLE,
445            _decode,
446        )
447    }
448
449    type ReadChannelStreamingStopResponseFut = fidl::client::QueryResponseFut<
450        ChannelReadChannelStreamingStopResult,
451        fidl::encoding::DefaultFuchsiaResourceDialect,
452    >;
453    fn r#read_channel_streaming_stop(
454        &self,
455        mut handle: &HandleId,
456    ) -> Self::ReadChannelStreamingStopResponseFut {
457        fn _decode(
458            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
459        ) -> Result<ChannelReadChannelStreamingStopResult, fidl::Error> {
460            let _response = fidl::client::decode_transaction_body::<
461                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
462                fidl::encoding::DefaultFuchsiaResourceDialect,
463                0x56f21d6ed68186e0,
464            >(_buf?)?
465            .into_result::<ChannelMarker>("read_channel_streaming_stop")?;
466            Ok(_response.map(|x| x))
467        }
468        self.client.send_query_and_decode::<
469            ChannelReadChannelStreamingStopRequest,
470            ChannelReadChannelStreamingStopResult,
471        >(
472            (handle,),
473            0x56f21d6ed68186e0,
474            fidl::encoding::DynamicFlags::FLEXIBLE,
475            _decode,
476        )
477    }
478}
479
480pub struct ChannelEventStream {
481    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
482}
483
484impl std::marker::Unpin for ChannelEventStream {}
485
486impl futures::stream::FusedStream for ChannelEventStream {
487    fn is_terminated(&self) -> bool {
488        self.event_receiver.is_terminated()
489    }
490}
491
492impl futures::Stream for ChannelEventStream {
493    type Item = Result<ChannelEvent, fidl::Error>;
494
495    fn poll_next(
496        mut self: std::pin::Pin<&mut Self>,
497        cx: &mut std::task::Context<'_>,
498    ) -> std::task::Poll<Option<Self::Item>> {
499        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
500            &mut self.event_receiver,
501            cx
502        )?) {
503            Some(buf) => std::task::Poll::Ready(Some(ChannelEvent::decode(buf))),
504            None => std::task::Poll::Ready(None),
505        }
506    }
507}
508
509#[derive(Debug)]
510pub enum ChannelEvent {
511    OnChannelStreamingData {
512        handle: HandleId,
513        channel_sent: ChannelSent,
514    },
515    #[non_exhaustive]
516    _UnknownEvent {
517        /// Ordinal of the event that was sent.
518        ordinal: u64,
519    },
520}
521
522impl ChannelEvent {
523    #[allow(irrefutable_let_patterns)]
524    pub fn into_on_channel_streaming_data(self) -> Option<(HandleId, ChannelSent)> {
525        if let ChannelEvent::OnChannelStreamingData { handle, channel_sent } = self {
526            Some((handle, channel_sent))
527        } else {
528            None
529        }
530    }
531
532    /// Decodes a message buffer as a [`ChannelEvent`].
533    fn decode(
534        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
535    ) -> Result<ChannelEvent, fidl::Error> {
536        let (bytes, _handles) = buf.split_mut();
537        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
538        debug_assert_eq!(tx_header.tx_id, 0);
539        match tx_header.ordinal {
540            0x7d4431805202dfe1 => {
541                let mut out = fidl::new_empty!(
542                    ChannelOnChannelStreamingDataRequest,
543                    fidl::encoding::DefaultFuchsiaResourceDialect
544                );
545                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChannelOnChannelStreamingDataRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
546                Ok((ChannelEvent::OnChannelStreamingData {
547                    handle: out.handle,
548                    channel_sent: out.channel_sent,
549                }))
550            }
551            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
552                Ok(ChannelEvent::_UnknownEvent { ordinal: tx_header.ordinal })
553            }
554            _ => Err(fidl::Error::UnknownOrdinal {
555                ordinal: tx_header.ordinal,
556                protocol_name: <ChannelMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
557            }),
558        }
559    }
560}
561
562/// A Stream of incoming requests for fuchsia.fdomain/Channel.
563pub struct ChannelRequestStream {
564    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
565    is_terminated: bool,
566}
567
568impl std::marker::Unpin for ChannelRequestStream {}
569
570impl futures::stream::FusedStream for ChannelRequestStream {
571    fn is_terminated(&self) -> bool {
572        self.is_terminated
573    }
574}
575
576impl fidl::endpoints::RequestStream for ChannelRequestStream {
577    type Protocol = ChannelMarker;
578    type ControlHandle = ChannelControlHandle;
579
580    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
581        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
582    }
583
584    fn control_handle(&self) -> Self::ControlHandle {
585        ChannelControlHandle { inner: self.inner.clone() }
586    }
587
588    fn into_inner(
589        self,
590    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
591    {
592        (self.inner, self.is_terminated)
593    }
594
595    fn from_inner(
596        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
597        is_terminated: bool,
598    ) -> Self {
599        Self { inner, is_terminated }
600    }
601}
602
603impl futures::Stream for ChannelRequestStream {
604    type Item = Result<ChannelRequest, fidl::Error>;
605
606    fn poll_next(
607        mut self: std::pin::Pin<&mut Self>,
608        cx: &mut std::task::Context<'_>,
609    ) -> std::task::Poll<Option<Self::Item>> {
610        let this = &mut *self;
611        if this.inner.check_shutdown(cx) {
612            this.is_terminated = true;
613            return std::task::Poll::Ready(None);
614        }
615        if this.is_terminated {
616            panic!("polled ChannelRequestStream after completion");
617        }
618        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
619            |bytes, handles| {
620                match this.inner.channel().read_etc(cx, bytes, handles) {
621                    std::task::Poll::Ready(Ok(())) => {}
622                    std::task::Poll::Pending => return std::task::Poll::Pending,
623                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
624                        this.is_terminated = true;
625                        return std::task::Poll::Ready(None);
626                    }
627                    std::task::Poll::Ready(Err(e)) => {
628                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
629                            e.into(),
630                        ))));
631                    }
632                }
633
634                // A message has been received from the channel
635                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
636
637                std::task::Poll::Ready(Some(match header.ordinal {
638                    0x182d38bfe88673b5 => {
639                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
640                        let mut req = fidl::new_empty!(
641                            ChannelCreateChannelRequest,
642                            fidl::encoding::DefaultFuchsiaResourceDialect
643                        );
644                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChannelCreateChannelRequest>(&header, _body_bytes, handles, &mut req)?;
645                        let control_handle = ChannelControlHandle { inner: this.inner.clone() };
646                        Ok(ChannelRequest::CreateChannel {
647                            handles: req.handles,
648
649                            responder: ChannelCreateChannelResponder {
650                                control_handle: std::mem::ManuallyDrop::new(control_handle),
651                                tx_id: header.tx_id,
652                            },
653                        })
654                    }
655                    0x6ef47bf27bf7d050 => {
656                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
657                        let mut req = fidl::new_empty!(
658                            ChannelReadChannelRequest,
659                            fidl::encoding::DefaultFuchsiaResourceDialect
660                        );
661                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChannelReadChannelRequest>(&header, _body_bytes, handles, &mut req)?;
662                        let control_handle = ChannelControlHandle { inner: this.inner.clone() };
663                        Ok(ChannelRequest::ReadChannel {
664                            handle: req.handle,
665
666                            responder: ChannelReadChannelResponder {
667                                control_handle: std::mem::ManuallyDrop::new(control_handle),
668                                tx_id: header.tx_id,
669                            },
670                        })
671                    }
672                    0x75a2559b945d5eb5 => {
673                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
674                        let mut req = fidl::new_empty!(
675                            ChannelWriteChannelRequest,
676                            fidl::encoding::DefaultFuchsiaResourceDialect
677                        );
678                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChannelWriteChannelRequest>(&header, _body_bytes, handles, &mut req)?;
679                        let control_handle = ChannelControlHandle { inner: this.inner.clone() };
680                        Ok(ChannelRequest::WriteChannel {
681                            handle: req.handle,
682                            data: req.data,
683                            handles: req.handles,
684
685                            responder: ChannelWriteChannelResponder {
686                                control_handle: std::mem::ManuallyDrop::new(control_handle),
687                                tx_id: header.tx_id,
688                            },
689                        })
690                    }
691                    0x3c73e85476a203df => {
692                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
693                        let mut req = fidl::new_empty!(
694                            ChannelReadChannelStreamingStartRequest,
695                            fidl::encoding::DefaultFuchsiaResourceDialect
696                        );
697                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChannelReadChannelStreamingStartRequest>(&header, _body_bytes, handles, &mut req)?;
698                        let control_handle = ChannelControlHandle { inner: this.inner.clone() };
699                        Ok(ChannelRequest::ReadChannelStreamingStart {
700                            handle: req.handle,
701
702                            responder: ChannelReadChannelStreamingStartResponder {
703                                control_handle: std::mem::ManuallyDrop::new(control_handle),
704                                tx_id: header.tx_id,
705                            },
706                        })
707                    }
708                    0x56f21d6ed68186e0 => {
709                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
710                        let mut req = fidl::new_empty!(
711                            ChannelReadChannelStreamingStopRequest,
712                            fidl::encoding::DefaultFuchsiaResourceDialect
713                        );
714                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChannelReadChannelStreamingStopRequest>(&header, _body_bytes, handles, &mut req)?;
715                        let control_handle = ChannelControlHandle { inner: this.inner.clone() };
716                        Ok(ChannelRequest::ReadChannelStreamingStop {
717                            handle: req.handle,
718
719                            responder: ChannelReadChannelStreamingStopResponder {
720                                control_handle: std::mem::ManuallyDrop::new(control_handle),
721                                tx_id: header.tx_id,
722                            },
723                        })
724                    }
725                    _ if header.tx_id == 0
726                        && header
727                            .dynamic_flags()
728                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
729                    {
730                        Ok(ChannelRequest::_UnknownMethod {
731                            ordinal: header.ordinal,
732                            control_handle: ChannelControlHandle { inner: this.inner.clone() },
733                            method_type: fidl::MethodType::OneWay,
734                        })
735                    }
736                    _ if header
737                        .dynamic_flags()
738                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
739                    {
740                        this.inner.send_framework_err(
741                            fidl::encoding::FrameworkErr::UnknownMethod,
742                            header.tx_id,
743                            header.ordinal,
744                            header.dynamic_flags(),
745                            (bytes, handles),
746                        )?;
747                        Ok(ChannelRequest::_UnknownMethod {
748                            ordinal: header.ordinal,
749                            control_handle: ChannelControlHandle { inner: this.inner.clone() },
750                            method_type: fidl::MethodType::TwoWay,
751                        })
752                    }
753                    _ => Err(fidl::Error::UnknownOrdinal {
754                        ordinal: header.ordinal,
755                        protocol_name:
756                            <ChannelMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
757                    }),
758                }))
759            },
760        )
761    }
762}
763
764/// FDomain operations on Channels.
765#[derive(Debug)]
766pub enum ChannelRequest {
767    /// Create a new channel in this FDomain and return both its ends.
768    CreateChannel { handles: [NewHandleId; 2], responder: ChannelCreateChannelResponder },
769    /// Read a message from a channel. This method will fail if the channel is currently being read
770    /// using the streaming read functions.
771    ///
772    /// Note that this method is not like zx_channel_read in that it will not
773    /// return `SHOULD_WAIT` but will instead delay returning until there is data
774    /// to return.
775    ReadChannel { handle: HandleId, responder: ChannelReadChannelResponder },
776    /// Write to a channel. Handles are always consumed.
777    WriteChannel {
778        handle: HandleId,
779        data: Vec<u8>,
780        handles: Handles,
781        responder: ChannelWriteChannelResponder,
782    },
783    /// Starts reading from the given channel. Data is returned via the `ChannelStreamingData` event.
784    /// That event will occur repeatedly until `ReadChannelStreamingStop` is called for the same handle
785    /// or the event indicates the handle is closed.
786    ReadChannelStreamingStart {
787        handle: HandleId,
788        responder: ChannelReadChannelStreamingStartResponder,
789    },
790    /// Stop asynchronous reading from the given channel.
791    ReadChannelStreamingStop {
792        handle: HandleId,
793        responder: ChannelReadChannelStreamingStopResponder,
794    },
795    /// An interaction was received which does not match any known method.
796    #[non_exhaustive]
797    _UnknownMethod {
798        /// Ordinal of the method that was called.
799        ordinal: u64,
800        control_handle: ChannelControlHandle,
801        method_type: fidl::MethodType,
802    },
803}
804
805impl ChannelRequest {
806    #[allow(irrefutable_let_patterns)]
807    pub fn into_create_channel(self) -> Option<([NewHandleId; 2], ChannelCreateChannelResponder)> {
808        if let ChannelRequest::CreateChannel { handles, responder } = self {
809            Some((handles, responder))
810        } else {
811            None
812        }
813    }
814
815    #[allow(irrefutable_let_patterns)]
816    pub fn into_read_channel(self) -> Option<(HandleId, ChannelReadChannelResponder)> {
817        if let ChannelRequest::ReadChannel { handle, responder } = self {
818            Some((handle, responder))
819        } else {
820            None
821        }
822    }
823
824    #[allow(irrefutable_let_patterns)]
825    pub fn into_write_channel(
826        self,
827    ) -> Option<(HandleId, Vec<u8>, Handles, ChannelWriteChannelResponder)> {
828        if let ChannelRequest::WriteChannel { handle, data, handles, responder } = self {
829            Some((handle, data, handles, responder))
830        } else {
831            None
832        }
833    }
834
835    #[allow(irrefutable_let_patterns)]
836    pub fn into_read_channel_streaming_start(
837        self,
838    ) -> Option<(HandleId, ChannelReadChannelStreamingStartResponder)> {
839        if let ChannelRequest::ReadChannelStreamingStart { handle, responder } = self {
840            Some((handle, responder))
841        } else {
842            None
843        }
844    }
845
846    #[allow(irrefutable_let_patterns)]
847    pub fn into_read_channel_streaming_stop(
848        self,
849    ) -> Option<(HandleId, ChannelReadChannelStreamingStopResponder)> {
850        if let ChannelRequest::ReadChannelStreamingStop { handle, responder } = self {
851            Some((handle, responder))
852        } else {
853            None
854        }
855    }
856
857    /// Name of the method defined in FIDL
858    pub fn method_name(&self) -> &'static str {
859        match *self {
860            ChannelRequest::CreateChannel { .. } => "create_channel",
861            ChannelRequest::ReadChannel { .. } => "read_channel",
862            ChannelRequest::WriteChannel { .. } => "write_channel",
863            ChannelRequest::ReadChannelStreamingStart { .. } => "read_channel_streaming_start",
864            ChannelRequest::ReadChannelStreamingStop { .. } => "read_channel_streaming_stop",
865            ChannelRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
866                "unknown one-way method"
867            }
868            ChannelRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
869                "unknown two-way method"
870            }
871        }
872    }
873}
874
875#[derive(Debug, Clone)]
876pub struct ChannelControlHandle {
877    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
878}
879
880impl ChannelControlHandle {
881    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
882        self.inner.shutdown_with_epitaph(status.into())
883    }
884}
885
886impl fidl::endpoints::ControlHandle for ChannelControlHandle {
887    fn shutdown(&self) {
888        self.inner.shutdown()
889    }
890
891    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
892        self.inner.shutdown_with_epitaph(status)
893    }
894
895    fn is_closed(&self) -> bool {
896        self.inner.channel().is_closed()
897    }
898    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
899        self.inner.channel().on_closed()
900    }
901
902    #[cfg(target_os = "fuchsia")]
903    fn signal_peer(
904        &self,
905        clear_mask: zx::Signals,
906        set_mask: zx::Signals,
907    ) -> Result<(), zx_status::Status> {
908        use fidl::Peered;
909        self.inner.channel().signal_peer(clear_mask, set_mask)
910    }
911}
912
913impl ChannelControlHandle {
914    pub fn send_on_channel_streaming_data(
915        &self,
916        mut handle: &HandleId,
917        mut channel_sent: &ChannelSent,
918    ) -> Result<(), fidl::Error> {
919        self.inner.send::<ChannelOnChannelStreamingDataRequest>(
920            (handle, channel_sent),
921            0,
922            0x7d4431805202dfe1,
923            fidl::encoding::DynamicFlags::FLEXIBLE,
924        )
925    }
926}
927
928#[must_use = "FIDL methods require a response to be sent"]
929#[derive(Debug)]
930pub struct ChannelCreateChannelResponder {
931    control_handle: std::mem::ManuallyDrop<ChannelControlHandle>,
932    tx_id: u32,
933}
934
935/// Set the the channel to be shutdown (see [`ChannelControlHandle::shutdown`])
936/// if the responder is dropped without sending a response, so that the client
937/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
938impl std::ops::Drop for ChannelCreateChannelResponder {
939    fn drop(&mut self) {
940        self.control_handle.shutdown();
941        // Safety: drops once, never accessed again
942        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
943    }
944}
945
946impl fidl::endpoints::Responder for ChannelCreateChannelResponder {
947    type ControlHandle = ChannelControlHandle;
948
949    fn control_handle(&self) -> &ChannelControlHandle {
950        &self.control_handle
951    }
952
953    fn drop_without_shutdown(mut self) {
954        // Safety: drops once, never accessed again due to mem::forget
955        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
956        // Prevent Drop from running (which would shut down the channel)
957        std::mem::forget(self);
958    }
959}
960
961impl ChannelCreateChannelResponder {
962    /// Sends a response to the FIDL transaction.
963    ///
964    /// Sets the channel to shutdown if an error occurs.
965    pub fn send(self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
966        let _result = self.send_raw(result);
967        if _result.is_err() {
968            self.control_handle.shutdown();
969        }
970        self.drop_without_shutdown();
971        _result
972    }
973
974    /// Similar to "send" but does not shutdown the channel if an error occurs.
975    pub fn send_no_shutdown_on_err(
976        self,
977        mut result: Result<(), &Error>,
978    ) -> Result<(), fidl::Error> {
979        let _result = self.send_raw(result);
980        self.drop_without_shutdown();
981        _result
982    }
983
984    fn send_raw(&self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
985        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
986            fidl::encoding::EmptyStruct,
987            Error,
988        >>(
989            fidl::encoding::FlexibleResult::new(result),
990            self.tx_id,
991            0x182d38bfe88673b5,
992            fidl::encoding::DynamicFlags::FLEXIBLE,
993        )
994    }
995}
996
997#[must_use = "FIDL methods require a response to be sent"]
998#[derive(Debug)]
999pub struct ChannelReadChannelResponder {
1000    control_handle: std::mem::ManuallyDrop<ChannelControlHandle>,
1001    tx_id: u32,
1002}
1003
1004/// Set the the channel to be shutdown (see [`ChannelControlHandle::shutdown`])
1005/// if the responder is dropped without sending a response, so that the client
1006/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1007impl std::ops::Drop for ChannelReadChannelResponder {
1008    fn drop(&mut self) {
1009        self.control_handle.shutdown();
1010        // Safety: drops once, never accessed again
1011        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1012    }
1013}
1014
1015impl fidl::endpoints::Responder for ChannelReadChannelResponder {
1016    type ControlHandle = ChannelControlHandle;
1017
1018    fn control_handle(&self) -> &ChannelControlHandle {
1019        &self.control_handle
1020    }
1021
1022    fn drop_without_shutdown(mut self) {
1023        // Safety: drops once, never accessed again due to mem::forget
1024        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1025        // Prevent Drop from running (which would shut down the channel)
1026        std::mem::forget(self);
1027    }
1028}
1029
1030impl ChannelReadChannelResponder {
1031    /// Sends a response to the FIDL transaction.
1032    ///
1033    /// Sets the channel to shutdown if an error occurs.
1034    pub fn send(
1035        self,
1036        mut result: Result<(&[u8], &[HandleInfo]), &Error>,
1037    ) -> Result<(), fidl::Error> {
1038        let _result = self.send_raw(result);
1039        if _result.is_err() {
1040            self.control_handle.shutdown();
1041        }
1042        self.drop_without_shutdown();
1043        _result
1044    }
1045
1046    /// Similar to "send" but does not shutdown the channel if an error occurs.
1047    pub fn send_no_shutdown_on_err(
1048        self,
1049        mut result: Result<(&[u8], &[HandleInfo]), &Error>,
1050    ) -> Result<(), fidl::Error> {
1051        let _result = self.send_raw(result);
1052        self.drop_without_shutdown();
1053        _result
1054    }
1055
1056    fn send_raw(
1057        &self,
1058        mut result: Result<(&[u8], &[HandleInfo]), &Error>,
1059    ) -> Result<(), fidl::Error> {
1060        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<ChannelMessage, Error>>(
1061            fidl::encoding::FlexibleResult::new(result),
1062            self.tx_id,
1063            0x6ef47bf27bf7d050,
1064            fidl::encoding::DynamicFlags::FLEXIBLE,
1065        )
1066    }
1067}
1068
1069#[must_use = "FIDL methods require a response to be sent"]
1070#[derive(Debug)]
1071pub struct ChannelWriteChannelResponder {
1072    control_handle: std::mem::ManuallyDrop<ChannelControlHandle>,
1073    tx_id: u32,
1074}
1075
1076/// Set the the channel to be shutdown (see [`ChannelControlHandle::shutdown`])
1077/// if the responder is dropped without sending a response, so that the client
1078/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1079impl std::ops::Drop for ChannelWriteChannelResponder {
1080    fn drop(&mut self) {
1081        self.control_handle.shutdown();
1082        // Safety: drops once, never accessed again
1083        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1084    }
1085}
1086
1087impl fidl::endpoints::Responder for ChannelWriteChannelResponder {
1088    type ControlHandle = ChannelControlHandle;
1089
1090    fn control_handle(&self) -> &ChannelControlHandle {
1091        &self.control_handle
1092    }
1093
1094    fn drop_without_shutdown(mut self) {
1095        // Safety: drops once, never accessed again due to mem::forget
1096        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1097        // Prevent Drop from running (which would shut down the channel)
1098        std::mem::forget(self);
1099    }
1100}
1101
1102impl ChannelWriteChannelResponder {
1103    /// Sends a response to the FIDL transaction.
1104    ///
1105    /// Sets the channel to shutdown if an error occurs.
1106    pub fn send(self, mut result: Result<(), &WriteChannelError>) -> Result<(), fidl::Error> {
1107        let _result = self.send_raw(result);
1108        if _result.is_err() {
1109            self.control_handle.shutdown();
1110        }
1111        self.drop_without_shutdown();
1112        _result
1113    }
1114
1115    /// Similar to "send" but does not shutdown the channel if an error occurs.
1116    pub fn send_no_shutdown_on_err(
1117        self,
1118        mut result: Result<(), &WriteChannelError>,
1119    ) -> Result<(), fidl::Error> {
1120        let _result = self.send_raw(result);
1121        self.drop_without_shutdown();
1122        _result
1123    }
1124
1125    fn send_raw(&self, mut result: Result<(), &WriteChannelError>) -> Result<(), fidl::Error> {
1126        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1127            fidl::encoding::EmptyStruct,
1128            WriteChannelError,
1129        >>(
1130            fidl::encoding::FlexibleResult::new(result),
1131            self.tx_id,
1132            0x75a2559b945d5eb5,
1133            fidl::encoding::DynamicFlags::FLEXIBLE,
1134        )
1135    }
1136}
1137
1138#[must_use = "FIDL methods require a response to be sent"]
1139#[derive(Debug)]
1140pub struct ChannelReadChannelStreamingStartResponder {
1141    control_handle: std::mem::ManuallyDrop<ChannelControlHandle>,
1142    tx_id: u32,
1143}
1144
1145/// Set the the channel to be shutdown (see [`ChannelControlHandle::shutdown`])
1146/// if the responder is dropped without sending a response, so that the client
1147/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1148impl std::ops::Drop for ChannelReadChannelStreamingStartResponder {
1149    fn drop(&mut self) {
1150        self.control_handle.shutdown();
1151        // Safety: drops once, never accessed again
1152        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1153    }
1154}
1155
1156impl fidl::endpoints::Responder for ChannelReadChannelStreamingStartResponder {
1157    type ControlHandle = ChannelControlHandle;
1158
1159    fn control_handle(&self) -> &ChannelControlHandle {
1160        &self.control_handle
1161    }
1162
1163    fn drop_without_shutdown(mut self) {
1164        // Safety: drops once, never accessed again due to mem::forget
1165        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1166        // Prevent Drop from running (which would shut down the channel)
1167        std::mem::forget(self);
1168    }
1169}
1170
1171impl ChannelReadChannelStreamingStartResponder {
1172    /// Sends a response to the FIDL transaction.
1173    ///
1174    /// Sets the channel to shutdown if an error occurs.
1175    pub fn send(self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
1176        let _result = self.send_raw(result);
1177        if _result.is_err() {
1178            self.control_handle.shutdown();
1179        }
1180        self.drop_without_shutdown();
1181        _result
1182    }
1183
1184    /// Similar to "send" but does not shutdown the channel if an error occurs.
1185    pub fn send_no_shutdown_on_err(
1186        self,
1187        mut result: Result<(), &Error>,
1188    ) -> Result<(), fidl::Error> {
1189        let _result = self.send_raw(result);
1190        self.drop_without_shutdown();
1191        _result
1192    }
1193
1194    fn send_raw(&self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
1195        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1196            fidl::encoding::EmptyStruct,
1197            Error,
1198        >>(
1199            fidl::encoding::FlexibleResult::new(result),
1200            self.tx_id,
1201            0x3c73e85476a203df,
1202            fidl::encoding::DynamicFlags::FLEXIBLE,
1203        )
1204    }
1205}
1206
1207#[must_use = "FIDL methods require a response to be sent"]
1208#[derive(Debug)]
1209pub struct ChannelReadChannelStreamingStopResponder {
1210    control_handle: std::mem::ManuallyDrop<ChannelControlHandle>,
1211    tx_id: u32,
1212}
1213
1214/// Set the the channel to be shutdown (see [`ChannelControlHandle::shutdown`])
1215/// if the responder is dropped without sending a response, so that the client
1216/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1217impl std::ops::Drop for ChannelReadChannelStreamingStopResponder {
1218    fn drop(&mut self) {
1219        self.control_handle.shutdown();
1220        // Safety: drops once, never accessed again
1221        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1222    }
1223}
1224
1225impl fidl::endpoints::Responder for ChannelReadChannelStreamingStopResponder {
1226    type ControlHandle = ChannelControlHandle;
1227
1228    fn control_handle(&self) -> &ChannelControlHandle {
1229        &self.control_handle
1230    }
1231
1232    fn drop_without_shutdown(mut self) {
1233        // Safety: drops once, never accessed again due to mem::forget
1234        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1235        // Prevent Drop from running (which would shut down the channel)
1236        std::mem::forget(self);
1237    }
1238}
1239
1240impl ChannelReadChannelStreamingStopResponder {
1241    /// Sends a response to the FIDL transaction.
1242    ///
1243    /// Sets the channel to shutdown if an error occurs.
1244    pub fn send(self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
1245        let _result = self.send_raw(result);
1246        if _result.is_err() {
1247            self.control_handle.shutdown();
1248        }
1249        self.drop_without_shutdown();
1250        _result
1251    }
1252
1253    /// Similar to "send" but does not shutdown the channel if an error occurs.
1254    pub fn send_no_shutdown_on_err(
1255        self,
1256        mut result: Result<(), &Error>,
1257    ) -> Result<(), fidl::Error> {
1258        let _result = self.send_raw(result);
1259        self.drop_without_shutdown();
1260        _result
1261    }
1262
1263    fn send_raw(&self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
1264        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1265            fidl::encoding::EmptyStruct,
1266            Error,
1267        >>(
1268            fidl::encoding::FlexibleResult::new(result),
1269            self.tx_id,
1270            0x56f21d6ed68186e0,
1271            fidl::encoding::DynamicFlags::FLEXIBLE,
1272        )
1273    }
1274}
1275
1276#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1277pub struct EventMarker;
1278
1279impl fidl::endpoints::ProtocolMarker for EventMarker {
1280    type Proxy = EventProxy;
1281    type RequestStream = EventRequestStream;
1282    #[cfg(target_os = "fuchsia")]
1283    type SynchronousProxy = EventSynchronousProxy;
1284
1285    const DEBUG_NAME: &'static str = "(anonymous) Event";
1286}
1287pub type EventCreateEventResult = Result<(), Error>;
1288
1289pub trait EventProxyInterface: Send + Sync {
1290    type CreateEventResponseFut: std::future::Future<Output = Result<EventCreateEventResult, fidl::Error>>
1291        + Send;
1292    fn r#create_event(&self, handle: &NewHandleId) -> Self::CreateEventResponseFut;
1293}
1294#[derive(Debug)]
1295#[cfg(target_os = "fuchsia")]
1296pub struct EventSynchronousProxy {
1297    client: fidl::client::sync::Client,
1298}
1299
1300#[cfg(target_os = "fuchsia")]
1301impl fidl::endpoints::SynchronousProxy for EventSynchronousProxy {
1302    type Proxy = EventProxy;
1303    type Protocol = EventMarker;
1304
1305    fn from_channel(inner: fidl::Channel) -> Self {
1306        Self::new(inner)
1307    }
1308
1309    fn into_channel(self) -> fidl::Channel {
1310        self.client.into_channel()
1311    }
1312
1313    fn as_channel(&self) -> &fidl::Channel {
1314        self.client.as_channel()
1315    }
1316}
1317
1318#[cfg(target_os = "fuchsia")]
1319impl EventSynchronousProxy {
1320    pub fn new(channel: fidl::Channel) -> Self {
1321        Self { client: fidl::client::sync::Client::new(channel) }
1322    }
1323
1324    pub fn into_channel(self) -> fidl::Channel {
1325        self.client.into_channel()
1326    }
1327
1328    /// Waits until an event arrives and returns it. It is safe for other
1329    /// threads to make concurrent requests while waiting for an event.
1330    pub fn wait_for_event(
1331        &self,
1332        deadline: zx::MonotonicInstant,
1333    ) -> Result<EventEvent, fidl::Error> {
1334        EventEvent::decode(self.client.wait_for_event::<EventMarker>(deadline)?)
1335    }
1336
1337    /// Create a new event in this FDomain and return it.
1338    pub fn r#create_event(
1339        &self,
1340        mut handle: &NewHandleId,
1341        ___deadline: zx::MonotonicInstant,
1342    ) -> Result<EventCreateEventResult, fidl::Error> {
1343        let _response = self.client.send_query::<
1344            EventCreateEventRequest,
1345            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
1346            EventMarker,
1347        >(
1348            (handle,),
1349            0x7b05b3f262635987,
1350            fidl::encoding::DynamicFlags::FLEXIBLE,
1351            ___deadline,
1352        )?
1353        .into_result::<EventMarker>("create_event")?;
1354        Ok(_response.map(|x| x))
1355    }
1356}
1357
1358#[cfg(target_os = "fuchsia")]
1359impl From<EventSynchronousProxy> for zx::NullableHandle {
1360    fn from(value: EventSynchronousProxy) -> Self {
1361        value.into_channel().into()
1362    }
1363}
1364
1365#[cfg(target_os = "fuchsia")]
1366impl From<fidl::Channel> for EventSynchronousProxy {
1367    fn from(value: fidl::Channel) -> Self {
1368        Self::new(value)
1369    }
1370}
1371
1372#[cfg(target_os = "fuchsia")]
1373impl fidl::endpoints::FromClient for EventSynchronousProxy {
1374    type Protocol = EventMarker;
1375
1376    fn from_client(value: fidl::endpoints::ClientEnd<EventMarker>) -> Self {
1377        Self::new(value.into_channel())
1378    }
1379}
1380
1381#[derive(Debug, Clone)]
1382pub struct EventProxy {
1383    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1384}
1385
1386impl fidl::endpoints::Proxy for EventProxy {
1387    type Protocol = EventMarker;
1388
1389    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1390        Self::new(inner)
1391    }
1392
1393    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1394        self.client.into_channel().map_err(|client| Self { client })
1395    }
1396
1397    fn as_channel(&self) -> &::fidl::AsyncChannel {
1398        self.client.as_channel()
1399    }
1400}
1401
1402impl EventProxy {
1403    /// Create a new Proxy for fuchsia.fdomain/Event.
1404    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1405        let protocol_name = <EventMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1406        Self { client: fidl::client::Client::new(channel, protocol_name) }
1407    }
1408
1409    /// Get a Stream of events from the remote end of the protocol.
1410    ///
1411    /// # Panics
1412    ///
1413    /// Panics if the event stream was already taken.
1414    pub fn take_event_stream(&self) -> EventEventStream {
1415        EventEventStream { event_receiver: self.client.take_event_receiver() }
1416    }
1417
1418    /// Create a new event in this FDomain and return it.
1419    pub fn r#create_event(
1420        &self,
1421        mut handle: &NewHandleId,
1422    ) -> fidl::client::QueryResponseFut<
1423        EventCreateEventResult,
1424        fidl::encoding::DefaultFuchsiaResourceDialect,
1425    > {
1426        EventProxyInterface::r#create_event(self, handle)
1427    }
1428}
1429
1430impl EventProxyInterface for EventProxy {
1431    type CreateEventResponseFut = fidl::client::QueryResponseFut<
1432        EventCreateEventResult,
1433        fidl::encoding::DefaultFuchsiaResourceDialect,
1434    >;
1435    fn r#create_event(&self, mut handle: &NewHandleId) -> Self::CreateEventResponseFut {
1436        fn _decode(
1437            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1438        ) -> Result<EventCreateEventResult, fidl::Error> {
1439            let _response = fidl::client::decode_transaction_body::<
1440                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
1441                fidl::encoding::DefaultFuchsiaResourceDialect,
1442                0x7b05b3f262635987,
1443            >(_buf?)?
1444            .into_result::<EventMarker>("create_event")?;
1445            Ok(_response.map(|x| x))
1446        }
1447        self.client.send_query_and_decode::<EventCreateEventRequest, EventCreateEventResult>(
1448            (handle,),
1449            0x7b05b3f262635987,
1450            fidl::encoding::DynamicFlags::FLEXIBLE,
1451            _decode,
1452        )
1453    }
1454}
1455
1456pub struct EventEventStream {
1457    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1458}
1459
1460impl std::marker::Unpin for EventEventStream {}
1461
1462impl futures::stream::FusedStream for EventEventStream {
1463    fn is_terminated(&self) -> bool {
1464        self.event_receiver.is_terminated()
1465    }
1466}
1467
1468impl futures::Stream for EventEventStream {
1469    type Item = Result<EventEvent, fidl::Error>;
1470
1471    fn poll_next(
1472        mut self: std::pin::Pin<&mut Self>,
1473        cx: &mut std::task::Context<'_>,
1474    ) -> std::task::Poll<Option<Self::Item>> {
1475        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1476            &mut self.event_receiver,
1477            cx
1478        )?) {
1479            Some(buf) => std::task::Poll::Ready(Some(EventEvent::decode(buf))),
1480            None => std::task::Poll::Ready(None),
1481        }
1482    }
1483}
1484
1485#[derive(Debug)]
1486pub enum EventEvent {
1487    #[non_exhaustive]
1488    _UnknownEvent {
1489        /// Ordinal of the event that was sent.
1490        ordinal: u64,
1491    },
1492}
1493
1494impl EventEvent {
1495    /// Decodes a message buffer as a [`EventEvent`].
1496    fn decode(
1497        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1498    ) -> Result<EventEvent, fidl::Error> {
1499        let (bytes, _handles) = buf.split_mut();
1500        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1501        debug_assert_eq!(tx_header.tx_id, 0);
1502        match tx_header.ordinal {
1503            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1504                Ok(EventEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1505            }
1506            _ => Err(fidl::Error::UnknownOrdinal {
1507                ordinal: tx_header.ordinal,
1508                protocol_name: <EventMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1509            }),
1510        }
1511    }
1512}
1513
1514/// A Stream of incoming requests for fuchsia.fdomain/Event.
1515pub struct EventRequestStream {
1516    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1517    is_terminated: bool,
1518}
1519
1520impl std::marker::Unpin for EventRequestStream {}
1521
1522impl futures::stream::FusedStream for EventRequestStream {
1523    fn is_terminated(&self) -> bool {
1524        self.is_terminated
1525    }
1526}
1527
1528impl fidl::endpoints::RequestStream for EventRequestStream {
1529    type Protocol = EventMarker;
1530    type ControlHandle = EventControlHandle;
1531
1532    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1533        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1534    }
1535
1536    fn control_handle(&self) -> Self::ControlHandle {
1537        EventControlHandle { inner: self.inner.clone() }
1538    }
1539
1540    fn into_inner(
1541        self,
1542    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1543    {
1544        (self.inner, self.is_terminated)
1545    }
1546
1547    fn from_inner(
1548        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1549        is_terminated: bool,
1550    ) -> Self {
1551        Self { inner, is_terminated }
1552    }
1553}
1554
1555impl futures::Stream for EventRequestStream {
1556    type Item = Result<EventRequest, fidl::Error>;
1557
1558    fn poll_next(
1559        mut self: std::pin::Pin<&mut Self>,
1560        cx: &mut std::task::Context<'_>,
1561    ) -> std::task::Poll<Option<Self::Item>> {
1562        let this = &mut *self;
1563        if this.inner.check_shutdown(cx) {
1564            this.is_terminated = true;
1565            return std::task::Poll::Ready(None);
1566        }
1567        if this.is_terminated {
1568            panic!("polled EventRequestStream after completion");
1569        }
1570        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1571            |bytes, handles| {
1572                match this.inner.channel().read_etc(cx, bytes, handles) {
1573                    std::task::Poll::Ready(Ok(())) => {}
1574                    std::task::Poll::Pending => return std::task::Poll::Pending,
1575                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1576                        this.is_terminated = true;
1577                        return std::task::Poll::Ready(None);
1578                    }
1579                    std::task::Poll::Ready(Err(e)) => {
1580                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1581                            e.into(),
1582                        ))));
1583                    }
1584                }
1585
1586                // A message has been received from the channel
1587                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1588
1589                std::task::Poll::Ready(Some(match header.ordinal {
1590                    0x7b05b3f262635987 => {
1591                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1592                        let mut req = fidl::new_empty!(
1593                            EventCreateEventRequest,
1594                            fidl::encoding::DefaultFuchsiaResourceDialect
1595                        );
1596                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<EventCreateEventRequest>(&header, _body_bytes, handles, &mut req)?;
1597                        let control_handle = EventControlHandle { inner: this.inner.clone() };
1598                        Ok(EventRequest::CreateEvent {
1599                            handle: req.handle,
1600
1601                            responder: EventCreateEventResponder {
1602                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1603                                tx_id: header.tx_id,
1604                            },
1605                        })
1606                    }
1607                    _ if header.tx_id == 0
1608                        && header
1609                            .dynamic_flags()
1610                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1611                    {
1612                        Ok(EventRequest::_UnknownMethod {
1613                            ordinal: header.ordinal,
1614                            control_handle: EventControlHandle { inner: this.inner.clone() },
1615                            method_type: fidl::MethodType::OneWay,
1616                        })
1617                    }
1618                    _ if header
1619                        .dynamic_flags()
1620                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1621                    {
1622                        this.inner.send_framework_err(
1623                            fidl::encoding::FrameworkErr::UnknownMethod,
1624                            header.tx_id,
1625                            header.ordinal,
1626                            header.dynamic_flags(),
1627                            (bytes, handles),
1628                        )?;
1629                        Ok(EventRequest::_UnknownMethod {
1630                            ordinal: header.ordinal,
1631                            control_handle: EventControlHandle { inner: this.inner.clone() },
1632                            method_type: fidl::MethodType::TwoWay,
1633                        })
1634                    }
1635                    _ => Err(fidl::Error::UnknownOrdinal {
1636                        ordinal: header.ordinal,
1637                        protocol_name: <EventMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1638                    }),
1639                }))
1640            },
1641        )
1642    }
1643}
1644
1645/// FDomain operations on Events.
1646#[derive(Debug)]
1647pub enum EventRequest {
1648    /// Create a new event in this FDomain and return it.
1649    CreateEvent { handle: NewHandleId, responder: EventCreateEventResponder },
1650    /// An interaction was received which does not match any known method.
1651    #[non_exhaustive]
1652    _UnknownMethod {
1653        /// Ordinal of the method that was called.
1654        ordinal: u64,
1655        control_handle: EventControlHandle,
1656        method_type: fidl::MethodType,
1657    },
1658}
1659
1660impl EventRequest {
1661    #[allow(irrefutable_let_patterns)]
1662    pub fn into_create_event(self) -> Option<(NewHandleId, EventCreateEventResponder)> {
1663        if let EventRequest::CreateEvent { handle, responder } = self {
1664            Some((handle, responder))
1665        } else {
1666            None
1667        }
1668    }
1669
1670    /// Name of the method defined in FIDL
1671    pub fn method_name(&self) -> &'static str {
1672        match *self {
1673            EventRequest::CreateEvent { .. } => "create_event",
1674            EventRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
1675                "unknown one-way method"
1676            }
1677            EventRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
1678                "unknown two-way method"
1679            }
1680        }
1681    }
1682}
1683
1684#[derive(Debug, Clone)]
1685pub struct EventControlHandle {
1686    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1687}
1688
1689impl EventControlHandle {
1690    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1691        self.inner.shutdown_with_epitaph(status.into())
1692    }
1693}
1694
1695impl fidl::endpoints::ControlHandle for EventControlHandle {
1696    fn shutdown(&self) {
1697        self.inner.shutdown()
1698    }
1699
1700    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1701        self.inner.shutdown_with_epitaph(status)
1702    }
1703
1704    fn is_closed(&self) -> bool {
1705        self.inner.channel().is_closed()
1706    }
1707    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1708        self.inner.channel().on_closed()
1709    }
1710
1711    #[cfg(target_os = "fuchsia")]
1712    fn signal_peer(
1713        &self,
1714        clear_mask: zx::Signals,
1715        set_mask: zx::Signals,
1716    ) -> Result<(), zx_status::Status> {
1717        use fidl::Peered;
1718        self.inner.channel().signal_peer(clear_mask, set_mask)
1719    }
1720}
1721
1722impl EventControlHandle {}
1723
1724#[must_use = "FIDL methods require a response to be sent"]
1725#[derive(Debug)]
1726pub struct EventCreateEventResponder {
1727    control_handle: std::mem::ManuallyDrop<EventControlHandle>,
1728    tx_id: u32,
1729}
1730
1731/// Set the the channel to be shutdown (see [`EventControlHandle::shutdown`])
1732/// if the responder is dropped without sending a response, so that the client
1733/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1734impl std::ops::Drop for EventCreateEventResponder {
1735    fn drop(&mut self) {
1736        self.control_handle.shutdown();
1737        // Safety: drops once, never accessed again
1738        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1739    }
1740}
1741
1742impl fidl::endpoints::Responder for EventCreateEventResponder {
1743    type ControlHandle = EventControlHandle;
1744
1745    fn control_handle(&self) -> &EventControlHandle {
1746        &self.control_handle
1747    }
1748
1749    fn drop_without_shutdown(mut self) {
1750        // Safety: drops once, never accessed again due to mem::forget
1751        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1752        // Prevent Drop from running (which would shut down the channel)
1753        std::mem::forget(self);
1754    }
1755}
1756
1757impl EventCreateEventResponder {
1758    /// Sends a response to the FIDL transaction.
1759    ///
1760    /// Sets the channel to shutdown if an error occurs.
1761    pub fn send(self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
1762        let _result = self.send_raw(result);
1763        if _result.is_err() {
1764            self.control_handle.shutdown();
1765        }
1766        self.drop_without_shutdown();
1767        _result
1768    }
1769
1770    /// Similar to "send" but does not shutdown the channel if an error occurs.
1771    pub fn send_no_shutdown_on_err(
1772        self,
1773        mut result: Result<(), &Error>,
1774    ) -> Result<(), fidl::Error> {
1775        let _result = self.send_raw(result);
1776        self.drop_without_shutdown();
1777        _result
1778    }
1779
1780    fn send_raw(&self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
1781        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1782            fidl::encoding::EmptyStruct,
1783            Error,
1784        >>(
1785            fidl::encoding::FlexibleResult::new(result),
1786            self.tx_id,
1787            0x7b05b3f262635987,
1788            fidl::encoding::DynamicFlags::FLEXIBLE,
1789        )
1790    }
1791}
1792
1793#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1794pub struct EventPairMarker;
1795
1796impl fidl::endpoints::ProtocolMarker for EventPairMarker {
1797    type Proxy = EventPairProxy;
1798    type RequestStream = EventPairRequestStream;
1799    #[cfg(target_os = "fuchsia")]
1800    type SynchronousProxy = EventPairSynchronousProxy;
1801
1802    const DEBUG_NAME: &'static str = "(anonymous) EventPair";
1803}
1804pub type EventPairCreateEventPairResult = Result<(), Error>;
1805
1806pub trait EventPairProxyInterface: Send + Sync {
1807    type CreateEventPairResponseFut: std::future::Future<Output = Result<EventPairCreateEventPairResult, fidl::Error>>
1808        + Send;
1809    fn r#create_event_pair(&self, handles: &[NewHandleId; 2]) -> Self::CreateEventPairResponseFut;
1810}
1811#[derive(Debug)]
1812#[cfg(target_os = "fuchsia")]
1813pub struct EventPairSynchronousProxy {
1814    client: fidl::client::sync::Client,
1815}
1816
1817#[cfg(target_os = "fuchsia")]
1818impl fidl::endpoints::SynchronousProxy for EventPairSynchronousProxy {
1819    type Proxy = EventPairProxy;
1820    type Protocol = EventPairMarker;
1821
1822    fn from_channel(inner: fidl::Channel) -> Self {
1823        Self::new(inner)
1824    }
1825
1826    fn into_channel(self) -> fidl::Channel {
1827        self.client.into_channel()
1828    }
1829
1830    fn as_channel(&self) -> &fidl::Channel {
1831        self.client.as_channel()
1832    }
1833}
1834
1835#[cfg(target_os = "fuchsia")]
1836impl EventPairSynchronousProxy {
1837    pub fn new(channel: fidl::Channel) -> Self {
1838        Self { client: fidl::client::sync::Client::new(channel) }
1839    }
1840
1841    pub fn into_channel(self) -> fidl::Channel {
1842        self.client.into_channel()
1843    }
1844
1845    /// Waits until an event arrives and returns it. It is safe for other
1846    /// threads to make concurrent requests while waiting for an event.
1847    pub fn wait_for_event(
1848        &self,
1849        deadline: zx::MonotonicInstant,
1850    ) -> Result<EventPairEvent, fidl::Error> {
1851        EventPairEvent::decode(self.client.wait_for_event::<EventPairMarker>(deadline)?)
1852    }
1853
1854    /// Create a new event pair in this FDomain and return both its ends.
1855    pub fn r#create_event_pair(
1856        &self,
1857        mut handles: &[NewHandleId; 2],
1858        ___deadline: zx::MonotonicInstant,
1859    ) -> Result<EventPairCreateEventPairResult, fidl::Error> {
1860        let _response = self.client.send_query::<
1861            EventPairCreateEventPairRequest,
1862            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
1863            EventPairMarker,
1864        >(
1865            (handles,),
1866            0x7aef61effa65656d,
1867            fidl::encoding::DynamicFlags::FLEXIBLE,
1868            ___deadline,
1869        )?
1870        .into_result::<EventPairMarker>("create_event_pair")?;
1871        Ok(_response.map(|x| x))
1872    }
1873}
1874
1875#[cfg(target_os = "fuchsia")]
1876impl From<EventPairSynchronousProxy> for zx::NullableHandle {
1877    fn from(value: EventPairSynchronousProxy) -> Self {
1878        value.into_channel().into()
1879    }
1880}
1881
1882#[cfg(target_os = "fuchsia")]
1883impl From<fidl::Channel> for EventPairSynchronousProxy {
1884    fn from(value: fidl::Channel) -> Self {
1885        Self::new(value)
1886    }
1887}
1888
1889#[cfg(target_os = "fuchsia")]
1890impl fidl::endpoints::FromClient for EventPairSynchronousProxy {
1891    type Protocol = EventPairMarker;
1892
1893    fn from_client(value: fidl::endpoints::ClientEnd<EventPairMarker>) -> Self {
1894        Self::new(value.into_channel())
1895    }
1896}
1897
1898#[derive(Debug, Clone)]
1899pub struct EventPairProxy {
1900    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1901}
1902
1903impl fidl::endpoints::Proxy for EventPairProxy {
1904    type Protocol = EventPairMarker;
1905
1906    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1907        Self::new(inner)
1908    }
1909
1910    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1911        self.client.into_channel().map_err(|client| Self { client })
1912    }
1913
1914    fn as_channel(&self) -> &::fidl::AsyncChannel {
1915        self.client.as_channel()
1916    }
1917}
1918
1919impl EventPairProxy {
1920    /// Create a new Proxy for fuchsia.fdomain/EventPair.
1921    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1922        let protocol_name = <EventPairMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1923        Self { client: fidl::client::Client::new(channel, protocol_name) }
1924    }
1925
1926    /// Get a Stream of events from the remote end of the protocol.
1927    ///
1928    /// # Panics
1929    ///
1930    /// Panics if the event stream was already taken.
1931    pub fn take_event_stream(&self) -> EventPairEventStream {
1932        EventPairEventStream { event_receiver: self.client.take_event_receiver() }
1933    }
1934
1935    /// Create a new event pair in this FDomain and return both its ends.
1936    pub fn r#create_event_pair(
1937        &self,
1938        mut handles: &[NewHandleId; 2],
1939    ) -> fidl::client::QueryResponseFut<
1940        EventPairCreateEventPairResult,
1941        fidl::encoding::DefaultFuchsiaResourceDialect,
1942    > {
1943        EventPairProxyInterface::r#create_event_pair(self, handles)
1944    }
1945}
1946
1947impl EventPairProxyInterface for EventPairProxy {
1948    type CreateEventPairResponseFut = fidl::client::QueryResponseFut<
1949        EventPairCreateEventPairResult,
1950        fidl::encoding::DefaultFuchsiaResourceDialect,
1951    >;
1952    fn r#create_event_pair(
1953        &self,
1954        mut handles: &[NewHandleId; 2],
1955    ) -> Self::CreateEventPairResponseFut {
1956        fn _decode(
1957            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1958        ) -> Result<EventPairCreateEventPairResult, fidl::Error> {
1959            let _response = fidl::client::decode_transaction_body::<
1960                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
1961                fidl::encoding::DefaultFuchsiaResourceDialect,
1962                0x7aef61effa65656d,
1963            >(_buf?)?
1964            .into_result::<EventPairMarker>("create_event_pair")?;
1965            Ok(_response.map(|x| x))
1966        }
1967        self.client.send_query_and_decode::<
1968            EventPairCreateEventPairRequest,
1969            EventPairCreateEventPairResult,
1970        >(
1971            (handles,),
1972            0x7aef61effa65656d,
1973            fidl::encoding::DynamicFlags::FLEXIBLE,
1974            _decode,
1975        )
1976    }
1977}
1978
1979pub struct EventPairEventStream {
1980    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1981}
1982
1983impl std::marker::Unpin for EventPairEventStream {}
1984
1985impl futures::stream::FusedStream for EventPairEventStream {
1986    fn is_terminated(&self) -> bool {
1987        self.event_receiver.is_terminated()
1988    }
1989}
1990
1991impl futures::Stream for EventPairEventStream {
1992    type Item = Result<EventPairEvent, fidl::Error>;
1993
1994    fn poll_next(
1995        mut self: std::pin::Pin<&mut Self>,
1996        cx: &mut std::task::Context<'_>,
1997    ) -> std::task::Poll<Option<Self::Item>> {
1998        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1999            &mut self.event_receiver,
2000            cx
2001        )?) {
2002            Some(buf) => std::task::Poll::Ready(Some(EventPairEvent::decode(buf))),
2003            None => std::task::Poll::Ready(None),
2004        }
2005    }
2006}
2007
2008#[derive(Debug)]
2009pub enum EventPairEvent {
2010    #[non_exhaustive]
2011    _UnknownEvent {
2012        /// Ordinal of the event that was sent.
2013        ordinal: u64,
2014    },
2015}
2016
2017impl EventPairEvent {
2018    /// Decodes a message buffer as a [`EventPairEvent`].
2019    fn decode(
2020        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2021    ) -> Result<EventPairEvent, fidl::Error> {
2022        let (bytes, _handles) = buf.split_mut();
2023        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2024        debug_assert_eq!(tx_header.tx_id, 0);
2025        match tx_header.ordinal {
2026            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2027                Ok(EventPairEvent::_UnknownEvent { ordinal: tx_header.ordinal })
2028            }
2029            _ => Err(fidl::Error::UnknownOrdinal {
2030                ordinal: tx_header.ordinal,
2031                protocol_name: <EventPairMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2032            }),
2033        }
2034    }
2035}
2036
2037/// A Stream of incoming requests for fuchsia.fdomain/EventPair.
2038pub struct EventPairRequestStream {
2039    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2040    is_terminated: bool,
2041}
2042
2043impl std::marker::Unpin for EventPairRequestStream {}
2044
2045impl futures::stream::FusedStream for EventPairRequestStream {
2046    fn is_terminated(&self) -> bool {
2047        self.is_terminated
2048    }
2049}
2050
2051impl fidl::endpoints::RequestStream for EventPairRequestStream {
2052    type Protocol = EventPairMarker;
2053    type ControlHandle = EventPairControlHandle;
2054
2055    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2056        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2057    }
2058
2059    fn control_handle(&self) -> Self::ControlHandle {
2060        EventPairControlHandle { inner: self.inner.clone() }
2061    }
2062
2063    fn into_inner(
2064        self,
2065    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2066    {
2067        (self.inner, self.is_terminated)
2068    }
2069
2070    fn from_inner(
2071        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2072        is_terminated: bool,
2073    ) -> Self {
2074        Self { inner, is_terminated }
2075    }
2076}
2077
2078impl futures::Stream for EventPairRequestStream {
2079    type Item = Result<EventPairRequest, fidl::Error>;
2080
2081    fn poll_next(
2082        mut self: std::pin::Pin<&mut Self>,
2083        cx: &mut std::task::Context<'_>,
2084    ) -> std::task::Poll<Option<Self::Item>> {
2085        let this = &mut *self;
2086        if this.inner.check_shutdown(cx) {
2087            this.is_terminated = true;
2088            return std::task::Poll::Ready(None);
2089        }
2090        if this.is_terminated {
2091            panic!("polled EventPairRequestStream after completion");
2092        }
2093        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2094            |bytes, handles| {
2095                match this.inner.channel().read_etc(cx, bytes, handles) {
2096                    std::task::Poll::Ready(Ok(())) => {}
2097                    std::task::Poll::Pending => return std::task::Poll::Pending,
2098                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2099                        this.is_terminated = true;
2100                        return std::task::Poll::Ready(None);
2101                    }
2102                    std::task::Poll::Ready(Err(e)) => {
2103                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2104                            e.into(),
2105                        ))));
2106                    }
2107                }
2108
2109                // A message has been received from the channel
2110                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2111
2112                std::task::Poll::Ready(Some(match header.ordinal {
2113                    0x7aef61effa65656d => {
2114                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2115                        let mut req = fidl::new_empty!(
2116                            EventPairCreateEventPairRequest,
2117                            fidl::encoding::DefaultFuchsiaResourceDialect
2118                        );
2119                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<EventPairCreateEventPairRequest>(&header, _body_bytes, handles, &mut req)?;
2120                        let control_handle = EventPairControlHandle { inner: this.inner.clone() };
2121                        Ok(EventPairRequest::CreateEventPair {
2122                            handles: req.handles,
2123
2124                            responder: EventPairCreateEventPairResponder {
2125                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2126                                tx_id: header.tx_id,
2127                            },
2128                        })
2129                    }
2130                    _ if header.tx_id == 0
2131                        && header
2132                            .dynamic_flags()
2133                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2134                    {
2135                        Ok(EventPairRequest::_UnknownMethod {
2136                            ordinal: header.ordinal,
2137                            control_handle: EventPairControlHandle { inner: this.inner.clone() },
2138                            method_type: fidl::MethodType::OneWay,
2139                        })
2140                    }
2141                    _ if header
2142                        .dynamic_flags()
2143                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2144                    {
2145                        this.inner.send_framework_err(
2146                            fidl::encoding::FrameworkErr::UnknownMethod,
2147                            header.tx_id,
2148                            header.ordinal,
2149                            header.dynamic_flags(),
2150                            (bytes, handles),
2151                        )?;
2152                        Ok(EventPairRequest::_UnknownMethod {
2153                            ordinal: header.ordinal,
2154                            control_handle: EventPairControlHandle { inner: this.inner.clone() },
2155                            method_type: fidl::MethodType::TwoWay,
2156                        })
2157                    }
2158                    _ => Err(fidl::Error::UnknownOrdinal {
2159                        ordinal: header.ordinal,
2160                        protocol_name:
2161                            <EventPairMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2162                    }),
2163                }))
2164            },
2165        )
2166    }
2167}
2168
2169/// FDomain operations on EventPairs.
2170#[derive(Debug)]
2171pub enum EventPairRequest {
2172    /// Create a new event pair in this FDomain and return both its ends.
2173    CreateEventPair { handles: [NewHandleId; 2], responder: EventPairCreateEventPairResponder },
2174    /// An interaction was received which does not match any known method.
2175    #[non_exhaustive]
2176    _UnknownMethod {
2177        /// Ordinal of the method that was called.
2178        ordinal: u64,
2179        control_handle: EventPairControlHandle,
2180        method_type: fidl::MethodType,
2181    },
2182}
2183
2184impl EventPairRequest {
2185    #[allow(irrefutable_let_patterns)]
2186    pub fn into_create_event_pair(
2187        self,
2188    ) -> Option<([NewHandleId; 2], EventPairCreateEventPairResponder)> {
2189        if let EventPairRequest::CreateEventPair { handles, responder } = self {
2190            Some((handles, responder))
2191        } else {
2192            None
2193        }
2194    }
2195
2196    /// Name of the method defined in FIDL
2197    pub fn method_name(&self) -> &'static str {
2198        match *self {
2199            EventPairRequest::CreateEventPair { .. } => "create_event_pair",
2200            EventPairRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
2201                "unknown one-way method"
2202            }
2203            EventPairRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
2204                "unknown two-way method"
2205            }
2206        }
2207    }
2208}
2209
2210#[derive(Debug, Clone)]
2211pub struct EventPairControlHandle {
2212    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2213}
2214
2215impl EventPairControlHandle {
2216    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
2217        self.inner.shutdown_with_epitaph(status.into())
2218    }
2219}
2220
2221impl fidl::endpoints::ControlHandle for EventPairControlHandle {
2222    fn shutdown(&self) {
2223        self.inner.shutdown()
2224    }
2225
2226    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
2227        self.inner.shutdown_with_epitaph(status)
2228    }
2229
2230    fn is_closed(&self) -> bool {
2231        self.inner.channel().is_closed()
2232    }
2233    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2234        self.inner.channel().on_closed()
2235    }
2236
2237    #[cfg(target_os = "fuchsia")]
2238    fn signal_peer(
2239        &self,
2240        clear_mask: zx::Signals,
2241        set_mask: zx::Signals,
2242    ) -> Result<(), zx_status::Status> {
2243        use fidl::Peered;
2244        self.inner.channel().signal_peer(clear_mask, set_mask)
2245    }
2246}
2247
2248impl EventPairControlHandle {}
2249
2250#[must_use = "FIDL methods require a response to be sent"]
2251#[derive(Debug)]
2252pub struct EventPairCreateEventPairResponder {
2253    control_handle: std::mem::ManuallyDrop<EventPairControlHandle>,
2254    tx_id: u32,
2255}
2256
2257/// Set the the channel to be shutdown (see [`EventPairControlHandle::shutdown`])
2258/// if the responder is dropped without sending a response, so that the client
2259/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2260impl std::ops::Drop for EventPairCreateEventPairResponder {
2261    fn drop(&mut self) {
2262        self.control_handle.shutdown();
2263        // Safety: drops once, never accessed again
2264        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2265    }
2266}
2267
2268impl fidl::endpoints::Responder for EventPairCreateEventPairResponder {
2269    type ControlHandle = EventPairControlHandle;
2270
2271    fn control_handle(&self) -> &EventPairControlHandle {
2272        &self.control_handle
2273    }
2274
2275    fn drop_without_shutdown(mut self) {
2276        // Safety: drops once, never accessed again due to mem::forget
2277        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2278        // Prevent Drop from running (which would shut down the channel)
2279        std::mem::forget(self);
2280    }
2281}
2282
2283impl EventPairCreateEventPairResponder {
2284    /// Sends a response to the FIDL transaction.
2285    ///
2286    /// Sets the channel to shutdown if an error occurs.
2287    pub fn send(self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
2288        let _result = self.send_raw(result);
2289        if _result.is_err() {
2290            self.control_handle.shutdown();
2291        }
2292        self.drop_without_shutdown();
2293        _result
2294    }
2295
2296    /// Similar to "send" but does not shutdown the channel if an error occurs.
2297    pub fn send_no_shutdown_on_err(
2298        self,
2299        mut result: Result<(), &Error>,
2300    ) -> Result<(), fidl::Error> {
2301        let _result = self.send_raw(result);
2302        self.drop_without_shutdown();
2303        _result
2304    }
2305
2306    fn send_raw(&self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
2307        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2308            fidl::encoding::EmptyStruct,
2309            Error,
2310        >>(
2311            fidl::encoding::FlexibleResult::new(result),
2312            self.tx_id,
2313            0x7aef61effa65656d,
2314            fidl::encoding::DynamicFlags::FLEXIBLE,
2315        )
2316    }
2317}
2318
2319#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2320pub struct FDomainMarker;
2321
2322impl fidl::endpoints::ProtocolMarker for FDomainMarker {
2323    type Proxy = FDomainProxy;
2324    type RequestStream = FDomainRequestStream;
2325    #[cfg(target_os = "fuchsia")]
2326    type SynchronousProxy = FDomainSynchronousProxy;
2327
2328    const DEBUG_NAME: &'static str = "(anonymous) FDomain";
2329}
2330pub type FDomainGetNamespaceResult = Result<(), Error>;
2331pub type FDomainCloseResult = Result<(), Error>;
2332pub type FDomainDuplicateResult = Result<(), Error>;
2333pub type FDomainReplaceResult = Result<(), Error>;
2334pub type FDomainSignalResult = Result<(), Error>;
2335pub type FDomainSignalPeerResult = Result<(), Error>;
2336pub type FDomainWaitForSignalsResult = Result<u32, Error>;
2337pub type FDomainGetKoidResult = Result<u64, Error>;
2338
2339pub trait FDomainProxyInterface: Send + Sync {
2340    type CreateChannelResponseFut: std::future::Future<Output = Result<ChannelCreateChannelResult, fidl::Error>>
2341        + Send;
2342    fn r#create_channel(&self, handles: &[NewHandleId; 2]) -> Self::CreateChannelResponseFut;
2343    type ReadChannelResponseFut: std::future::Future<Output = Result<ChannelReadChannelResult, fidl::Error>>
2344        + Send;
2345    fn r#read_channel(&self, handle: &HandleId) -> Self::ReadChannelResponseFut;
2346    type WriteChannelResponseFut: std::future::Future<Output = Result<ChannelWriteChannelResult, fidl::Error>>
2347        + Send;
2348    fn r#write_channel(
2349        &self,
2350        handle: &HandleId,
2351        data: &[u8],
2352        handles: &Handles,
2353    ) -> Self::WriteChannelResponseFut;
2354    type ReadChannelStreamingStartResponseFut: std::future::Future<Output = Result<ChannelReadChannelStreamingStartResult, fidl::Error>>
2355        + Send;
2356    fn r#read_channel_streaming_start(
2357        &self,
2358        handle: &HandleId,
2359    ) -> Self::ReadChannelStreamingStartResponseFut;
2360    type ReadChannelStreamingStopResponseFut: std::future::Future<Output = Result<ChannelReadChannelStreamingStopResult, fidl::Error>>
2361        + Send;
2362    fn r#read_channel_streaming_stop(
2363        &self,
2364        handle: &HandleId,
2365    ) -> Self::ReadChannelStreamingStopResponseFut;
2366    type CreateEventResponseFut: std::future::Future<Output = Result<EventCreateEventResult, fidl::Error>>
2367        + Send;
2368    fn r#create_event(&self, handle: &NewHandleId) -> Self::CreateEventResponseFut;
2369    type CreateEventPairResponseFut: std::future::Future<Output = Result<EventPairCreateEventPairResult, fidl::Error>>
2370        + Send;
2371    fn r#create_event_pair(&self, handles: &[NewHandleId; 2]) -> Self::CreateEventPairResponseFut;
2372    type CreateSocketResponseFut: std::future::Future<Output = Result<SocketCreateSocketResult, fidl::Error>>
2373        + Send;
2374    fn r#create_socket(
2375        &self,
2376        options: SocketType,
2377        handles: &[NewHandleId; 2],
2378    ) -> Self::CreateSocketResponseFut;
2379    type SetSocketDispositionResponseFut: std::future::Future<Output = Result<SocketSetSocketDispositionResult, fidl::Error>>
2380        + Send;
2381    fn r#set_socket_disposition(
2382        &self,
2383        handle: &HandleId,
2384        disposition: SocketDisposition,
2385        disposition_peer: SocketDisposition,
2386    ) -> Self::SetSocketDispositionResponseFut;
2387    type ReadSocketResponseFut: std::future::Future<Output = Result<SocketReadSocketResult, fidl::Error>>
2388        + Send;
2389    fn r#read_socket(&self, handle: &HandleId, max_bytes: u64) -> Self::ReadSocketResponseFut;
2390    type WriteSocketResponseFut: std::future::Future<Output = Result<SocketWriteSocketResult, fidl::Error>>
2391        + Send;
2392    fn r#write_socket(&self, handle: &HandleId, data: &[u8]) -> Self::WriteSocketResponseFut;
2393    type ReadSocketStreamingStartResponseFut: std::future::Future<Output = Result<SocketReadSocketStreamingStartResult, fidl::Error>>
2394        + Send;
2395    fn r#read_socket_streaming_start(
2396        &self,
2397        handle: &HandleId,
2398    ) -> Self::ReadSocketStreamingStartResponseFut;
2399    type ReadSocketStreamingStopResponseFut: std::future::Future<Output = Result<SocketReadSocketStreamingStopResult, fidl::Error>>
2400        + Send;
2401    fn r#read_socket_streaming_stop(
2402        &self,
2403        handle: &HandleId,
2404    ) -> Self::ReadSocketStreamingStopResponseFut;
2405    type GetNamespaceResponseFut: std::future::Future<Output = Result<FDomainGetNamespaceResult, fidl::Error>>
2406        + Send;
2407    fn r#get_namespace(&self, new_handle: &NewHandleId) -> Self::GetNamespaceResponseFut;
2408    type CloseResponseFut: std::future::Future<Output = Result<FDomainCloseResult, fidl::Error>>
2409        + Send;
2410    fn r#close(&self, handles: &[HandleId]) -> Self::CloseResponseFut;
2411    type DuplicateResponseFut: std::future::Future<Output = Result<FDomainDuplicateResult, fidl::Error>>
2412        + Send;
2413    fn r#duplicate(
2414        &self,
2415        handle: &HandleId,
2416        new_handle: &NewHandleId,
2417        rights: fidl::Rights,
2418    ) -> Self::DuplicateResponseFut;
2419    type ReplaceResponseFut: std::future::Future<Output = Result<FDomainReplaceResult, fidl::Error>>
2420        + Send;
2421    fn r#replace(
2422        &self,
2423        handle: &HandleId,
2424        new_handle: &NewHandleId,
2425        rights: fidl::Rights,
2426    ) -> Self::ReplaceResponseFut;
2427    type SignalResponseFut: std::future::Future<Output = Result<FDomainSignalResult, fidl::Error>>
2428        + Send;
2429    fn r#signal(&self, handle: &HandleId, set: u32, clear: u32) -> Self::SignalResponseFut;
2430    type SignalPeerResponseFut: std::future::Future<Output = Result<FDomainSignalPeerResult, fidl::Error>>
2431        + Send;
2432    fn r#signal_peer(&self, handle: &HandleId, set: u32, clear: u32)
2433    -> Self::SignalPeerResponseFut;
2434    type WaitForSignalsResponseFut: std::future::Future<Output = Result<FDomainWaitForSignalsResult, fidl::Error>>
2435        + Send;
2436    fn r#wait_for_signals(
2437        &self,
2438        handle: &HandleId,
2439        signals: u32,
2440    ) -> Self::WaitForSignalsResponseFut;
2441    type GetKoidResponseFut: std::future::Future<Output = Result<FDomainGetKoidResult, fidl::Error>>
2442        + Send;
2443    fn r#get_koid(&self, handle: &HandleId) -> Self::GetKoidResponseFut;
2444}
2445#[derive(Debug)]
2446#[cfg(target_os = "fuchsia")]
2447pub struct FDomainSynchronousProxy {
2448    client: fidl::client::sync::Client,
2449}
2450
2451#[cfg(target_os = "fuchsia")]
2452impl fidl::endpoints::SynchronousProxy for FDomainSynchronousProxy {
2453    type Proxy = FDomainProxy;
2454    type Protocol = FDomainMarker;
2455
2456    fn from_channel(inner: fidl::Channel) -> Self {
2457        Self::new(inner)
2458    }
2459
2460    fn into_channel(self) -> fidl::Channel {
2461        self.client.into_channel()
2462    }
2463
2464    fn as_channel(&self) -> &fidl::Channel {
2465        self.client.as_channel()
2466    }
2467}
2468
2469#[cfg(target_os = "fuchsia")]
2470impl FDomainSynchronousProxy {
2471    pub fn new(channel: fidl::Channel) -> Self {
2472        Self { client: fidl::client::sync::Client::new(channel) }
2473    }
2474
2475    pub fn into_channel(self) -> fidl::Channel {
2476        self.client.into_channel()
2477    }
2478
2479    /// Waits until an event arrives and returns it. It is safe for other
2480    /// threads to make concurrent requests while waiting for an event.
2481    pub fn wait_for_event(
2482        &self,
2483        deadline: zx::MonotonicInstant,
2484    ) -> Result<FDomainEvent, fidl::Error> {
2485        FDomainEvent::decode(self.client.wait_for_event::<FDomainMarker>(deadline)?)
2486    }
2487
2488    /// Create a new channel in this FDomain and return both its ends.
2489    pub fn r#create_channel(
2490        &self,
2491        mut handles: &[NewHandleId; 2],
2492        ___deadline: zx::MonotonicInstant,
2493    ) -> Result<ChannelCreateChannelResult, fidl::Error> {
2494        let _response = self.client.send_query::<
2495            ChannelCreateChannelRequest,
2496            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
2497            FDomainMarker,
2498        >(
2499            (handles,),
2500            0x182d38bfe88673b5,
2501            fidl::encoding::DynamicFlags::FLEXIBLE,
2502            ___deadline,
2503        )?
2504        .into_result::<FDomainMarker>("create_channel")?;
2505        Ok(_response.map(|x| x))
2506    }
2507
2508    /// Read a message from a channel. This method will fail if the channel is currently being read
2509    /// using the streaming read functions.
2510    ///
2511    /// Note that this method is not like zx_channel_read in that it will not
2512    /// return `SHOULD_WAIT` but will instead delay returning until there is data
2513    /// to return.
2514    pub fn r#read_channel(
2515        &self,
2516        mut handle: &HandleId,
2517        ___deadline: zx::MonotonicInstant,
2518    ) -> Result<ChannelReadChannelResult, fidl::Error> {
2519        let _response = self.client.send_query::<
2520            ChannelReadChannelRequest,
2521            fidl::encoding::FlexibleResultType<ChannelMessage, Error>,
2522            FDomainMarker,
2523        >(
2524            (handle,),
2525            0x6ef47bf27bf7d050,
2526            fidl::encoding::DynamicFlags::FLEXIBLE,
2527            ___deadline,
2528        )?
2529        .into_result::<FDomainMarker>("read_channel")?;
2530        Ok(_response.map(|x| (x.data, x.handles)))
2531    }
2532
2533    /// Write to a channel. Handles are always consumed.
2534    pub fn r#write_channel(
2535        &self,
2536        mut handle: &HandleId,
2537        mut data: &[u8],
2538        mut handles: &Handles,
2539        ___deadline: zx::MonotonicInstant,
2540    ) -> Result<ChannelWriteChannelResult, fidl::Error> {
2541        let _response = self.client.send_query::<
2542            ChannelWriteChannelRequest,
2543            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, WriteChannelError>,
2544            FDomainMarker,
2545        >(
2546            (handle, data, handles,),
2547            0x75a2559b945d5eb5,
2548            fidl::encoding::DynamicFlags::FLEXIBLE,
2549            ___deadline,
2550        )?
2551        .into_result::<FDomainMarker>("write_channel")?;
2552        Ok(_response.map(|x| x))
2553    }
2554
2555    /// Starts reading from the given channel. Data is returned via the `ChannelStreamingData` event.
2556    /// That event will occur repeatedly until `ReadChannelStreamingStop` is called for the same handle
2557    /// or the event indicates the handle is closed.
2558    pub fn r#read_channel_streaming_start(
2559        &self,
2560        mut handle: &HandleId,
2561        ___deadline: zx::MonotonicInstant,
2562    ) -> Result<ChannelReadChannelStreamingStartResult, fidl::Error> {
2563        let _response = self.client.send_query::<
2564            ChannelReadChannelStreamingStartRequest,
2565            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
2566            FDomainMarker,
2567        >(
2568            (handle,),
2569            0x3c73e85476a203df,
2570            fidl::encoding::DynamicFlags::FLEXIBLE,
2571            ___deadline,
2572        )?
2573        .into_result::<FDomainMarker>("read_channel_streaming_start")?;
2574        Ok(_response.map(|x| x))
2575    }
2576
2577    /// Stop asynchronous reading from the given channel.
2578    pub fn r#read_channel_streaming_stop(
2579        &self,
2580        mut handle: &HandleId,
2581        ___deadline: zx::MonotonicInstant,
2582    ) -> Result<ChannelReadChannelStreamingStopResult, fidl::Error> {
2583        let _response = self.client.send_query::<
2584            ChannelReadChannelStreamingStopRequest,
2585            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
2586            FDomainMarker,
2587        >(
2588            (handle,),
2589            0x56f21d6ed68186e0,
2590            fidl::encoding::DynamicFlags::FLEXIBLE,
2591            ___deadline,
2592        )?
2593        .into_result::<FDomainMarker>("read_channel_streaming_stop")?;
2594        Ok(_response.map(|x| x))
2595    }
2596
2597    /// Create a new event in this FDomain and return it.
2598    pub fn r#create_event(
2599        &self,
2600        mut handle: &NewHandleId,
2601        ___deadline: zx::MonotonicInstant,
2602    ) -> Result<EventCreateEventResult, fidl::Error> {
2603        let _response = self.client.send_query::<
2604            EventCreateEventRequest,
2605            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
2606            FDomainMarker,
2607        >(
2608            (handle,),
2609            0x7b05b3f262635987,
2610            fidl::encoding::DynamicFlags::FLEXIBLE,
2611            ___deadline,
2612        )?
2613        .into_result::<FDomainMarker>("create_event")?;
2614        Ok(_response.map(|x| x))
2615    }
2616
2617    /// Create a new event pair in this FDomain and return both its ends.
2618    pub fn r#create_event_pair(
2619        &self,
2620        mut handles: &[NewHandleId; 2],
2621        ___deadline: zx::MonotonicInstant,
2622    ) -> Result<EventPairCreateEventPairResult, fidl::Error> {
2623        let _response = self.client.send_query::<
2624            EventPairCreateEventPairRequest,
2625            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
2626            FDomainMarker,
2627        >(
2628            (handles,),
2629            0x7aef61effa65656d,
2630            fidl::encoding::DynamicFlags::FLEXIBLE,
2631            ___deadline,
2632        )?
2633        .into_result::<FDomainMarker>("create_event_pair")?;
2634        Ok(_response.map(|x| x))
2635    }
2636
2637    /// Create a new socket in this FDomain and return both its ends.
2638    pub fn r#create_socket(
2639        &self,
2640        mut options: SocketType,
2641        mut handles: &[NewHandleId; 2],
2642        ___deadline: zx::MonotonicInstant,
2643    ) -> Result<SocketCreateSocketResult, fidl::Error> {
2644        let _response = self.client.send_query::<
2645            SocketCreateSocketRequest,
2646            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
2647            FDomainMarker,
2648        >(
2649            (options, handles,),
2650            0x200bf0ea21932de0,
2651            fidl::encoding::DynamicFlags::FLEXIBLE,
2652            ___deadline,
2653        )?
2654        .into_result::<FDomainMarker>("create_socket")?;
2655        Ok(_response.map(|x| x))
2656    }
2657
2658    /// Set the disposition of a given socket.
2659    pub fn r#set_socket_disposition(
2660        &self,
2661        mut handle: &HandleId,
2662        mut disposition: SocketDisposition,
2663        mut disposition_peer: SocketDisposition,
2664        ___deadline: zx::MonotonicInstant,
2665    ) -> Result<SocketSetSocketDispositionResult, fidl::Error> {
2666        let _response = self.client.send_query::<
2667            SocketSetSocketDispositionRequest,
2668            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
2669            FDomainMarker,
2670        >(
2671            (handle, disposition, disposition_peer,),
2672            0x60d3c7ccb17f9bdf,
2673            fidl::encoding::DynamicFlags::FLEXIBLE,
2674            ___deadline,
2675        )?
2676        .into_result::<FDomainMarker>("set_socket_disposition")?;
2677        Ok(_response.map(|x| x))
2678    }
2679
2680    /// Read data from a socket. This method will fail if the socket is currently being read
2681    /// asynchronously.
2682    pub fn r#read_socket(
2683        &self,
2684        mut handle: &HandleId,
2685        mut max_bytes: u64,
2686        ___deadline: zx::MonotonicInstant,
2687    ) -> Result<SocketReadSocketResult, fidl::Error> {
2688        let _response = self.client.send_query::<
2689            SocketReadSocketRequest,
2690            fidl::encoding::FlexibleResultType<SocketData, Error>,
2691            FDomainMarker,
2692        >(
2693            (handle, max_bytes,),
2694            0x1da8aabec249c02e,
2695            fidl::encoding::DynamicFlags::FLEXIBLE,
2696            ___deadline,
2697        )?
2698        .into_result::<FDomainMarker>("read_socket")?;
2699        Ok(_response.map(|x| (x.data, x.is_datagram)))
2700    }
2701
2702    /// Write to a socket. This will attempt to write all the data passed, and
2703    /// will block and retry whenever it is safe (e.g. it should never return
2704    /// SHOULD_WAIT). The `WriteSocketError` contains a `wrote` parameter to
2705    /// indicate if some bytes were written successfully before the failure
2706    /// occurred.
2707    pub fn r#write_socket(
2708        &self,
2709        mut handle: &HandleId,
2710        mut data: &[u8],
2711        ___deadline: zx::MonotonicInstant,
2712    ) -> Result<SocketWriteSocketResult, fidl::Error> {
2713        let _response = self.client.send_query::<
2714            SocketWriteSocketRequest,
2715            fidl::encoding::FlexibleResultType<SocketWriteSocketResponse, WriteSocketError>,
2716            FDomainMarker,
2717        >(
2718            (handle, data,),
2719            0x5b541623cbbbf683,
2720            fidl::encoding::DynamicFlags::FLEXIBLE,
2721            ___deadline,
2722        )?
2723        .into_result::<FDomainMarker>("write_socket")?;
2724        Ok(_response.map(|x| x.wrote))
2725    }
2726
2727    /// Starts reading from the given socket. Data is returned via the `SocketStreamingData` event. That
2728    /// event will occur repeatedly until `ReadSocketStreamingStop` is called for the same handle or the
2729    /// event indicates the handle is closed.
2730    pub fn r#read_socket_streaming_start(
2731        &self,
2732        mut handle: &HandleId,
2733        ___deadline: zx::MonotonicInstant,
2734    ) -> Result<SocketReadSocketStreamingStartResult, fidl::Error> {
2735        let _response = self.client.send_query::<
2736            SocketReadSocketStreamingStartRequest,
2737            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
2738            FDomainMarker,
2739        >(
2740            (handle,),
2741            0x2a592748d5f33445,
2742            fidl::encoding::DynamicFlags::FLEXIBLE,
2743            ___deadline,
2744        )?
2745        .into_result::<FDomainMarker>("read_socket_streaming_start")?;
2746        Ok(_response.map(|x| x))
2747    }
2748
2749    /// Stop asynchronous reading from the given socket.
2750    pub fn r#read_socket_streaming_stop(
2751        &self,
2752        mut handle: &HandleId,
2753        ___deadline: zx::MonotonicInstant,
2754    ) -> Result<SocketReadSocketStreamingStopResult, fidl::Error> {
2755        let _response = self.client.send_query::<
2756            SocketReadSocketStreamingStopRequest,
2757            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
2758            FDomainMarker,
2759        >(
2760            (handle,),
2761            0x53e5cade5f4d22e7,
2762            fidl::encoding::DynamicFlags::FLEXIBLE,
2763            ___deadline,
2764        )?
2765        .into_result::<FDomainMarker>("read_socket_streaming_stop")?;
2766        Ok(_response.map(|x| x))
2767    }
2768
2769    /// Adds a new channel handle to this namespace which points to a
2770    /// fuchsia.io.Directory. Can be used to "bootstrap" the FDomain.
2771    pub fn r#get_namespace(
2772        &self,
2773        mut new_handle: &NewHandleId,
2774        ___deadline: zx::MonotonicInstant,
2775    ) -> Result<FDomainGetNamespaceResult, fidl::Error> {
2776        let _response = self.client.send_query::<
2777            FDomainGetNamespaceRequest,
2778            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
2779            FDomainMarker,
2780        >(
2781            (new_handle,),
2782            0x74f2e74d9f53e11e,
2783            fidl::encoding::DynamicFlags::FLEXIBLE,
2784            ___deadline,
2785        )?
2786        .into_result::<FDomainMarker>("get_namespace")?;
2787        Ok(_response.map(|x| x))
2788    }
2789
2790    /// Close one or more handles.
2791    pub fn r#close(
2792        &self,
2793        mut handles: &[HandleId],
2794        ___deadline: zx::MonotonicInstant,
2795    ) -> Result<FDomainCloseResult, fidl::Error> {
2796        let _response = self.client.send_query::<
2797            FDomainCloseRequest,
2798            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
2799            FDomainMarker,
2800        >(
2801            (handles,),
2802            0x5ef8c24362964257,
2803            fidl::encoding::DynamicFlags::FLEXIBLE,
2804            ___deadline,
2805        )?
2806        .into_result::<FDomainMarker>("close")?;
2807        Ok(_response.map(|x| x))
2808    }
2809
2810    /// Duplicate a handle.
2811    pub fn r#duplicate(
2812        &self,
2813        mut handle: &HandleId,
2814        mut new_handle: &NewHandleId,
2815        mut rights: fidl::Rights,
2816        ___deadline: zx::MonotonicInstant,
2817    ) -> Result<FDomainDuplicateResult, fidl::Error> {
2818        let _response = self.client.send_query::<
2819            FDomainDuplicateRequest,
2820            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
2821            FDomainMarker,
2822        >(
2823            (handle, new_handle, rights,),
2824            0x7a85b94bd1777ab9,
2825            fidl::encoding::DynamicFlags::FLEXIBLE,
2826            ___deadline,
2827        )?
2828        .into_result::<FDomainMarker>("duplicate")?;
2829        Ok(_response.map(|x| x))
2830    }
2831
2832    /// Close a handle and replace it with a new one with possibly different
2833    /// rights.
2834    pub fn r#replace(
2835        &self,
2836        mut handle: &HandleId,
2837        mut new_handle: &NewHandleId,
2838        mut rights: fidl::Rights,
2839        ___deadline: zx::MonotonicInstant,
2840    ) -> Result<FDomainReplaceResult, fidl::Error> {
2841        let _response = self.client.send_query::<
2842            FDomainReplaceRequest,
2843            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
2844            FDomainMarker,
2845        >(
2846            (handle, new_handle, rights,),
2847            0x32fa64625a5bd3be,
2848            fidl::encoding::DynamicFlags::FLEXIBLE,
2849            ___deadline,
2850        )?
2851        .into_result::<FDomainMarker>("replace")?;
2852        Ok(_response.map(|x| x))
2853    }
2854
2855    /// Set or clear signals on a handle.
2856    pub fn r#signal(
2857        &self,
2858        mut handle: &HandleId,
2859        mut set: u32,
2860        mut clear: u32,
2861        ___deadline: zx::MonotonicInstant,
2862    ) -> Result<FDomainSignalResult, fidl::Error> {
2863        let _response = self.client.send_query::<
2864            FDomainSignalRequest,
2865            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
2866            FDomainMarker,
2867        >(
2868            (handle, set, clear,),
2869            0xe8352fb978996d9,
2870            fidl::encoding::DynamicFlags::FLEXIBLE,
2871            ___deadline,
2872        )?
2873        .into_result::<FDomainMarker>("signal")?;
2874        Ok(_response.map(|x| x))
2875    }
2876
2877    /// Set or clear signals on a handle's peer.
2878    pub fn r#signal_peer(
2879        &self,
2880        mut handle: &HandleId,
2881        mut set: u32,
2882        mut clear: u32,
2883        ___deadline: zx::MonotonicInstant,
2884    ) -> Result<FDomainSignalPeerResult, fidl::Error> {
2885        let _response = self.client.send_query::<
2886            FDomainSignalPeerRequest,
2887            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
2888            FDomainMarker,
2889        >(
2890            (handle, set, clear,),
2891            0x7e84ec8ca7eabaf8,
2892            fidl::encoding::DynamicFlags::FLEXIBLE,
2893            ___deadline,
2894        )?
2895        .into_result::<FDomainMarker>("signal_peer")?;
2896        Ok(_response.map(|x| x))
2897    }
2898
2899    /// Wait for signals from the given handle. Reply will be returned when one
2900    /// of the given signals is asserted.
2901    pub fn r#wait_for_signals(
2902        &self,
2903        mut handle: &HandleId,
2904        mut signals: u32,
2905        ___deadline: zx::MonotonicInstant,
2906    ) -> Result<FDomainWaitForSignalsResult, fidl::Error> {
2907        let _response = self.client.send_query::<
2908            FDomainWaitForSignalsRequest,
2909            fidl::encoding::FlexibleResultType<FDomainWaitForSignalsResponse, Error>,
2910            FDomainMarker,
2911        >(
2912            (handle, signals,),
2913            0x8f72d9b4b85c1eb,
2914            fidl::encoding::DynamicFlags::FLEXIBLE,
2915            ___deadline,
2916        )?
2917        .into_result::<FDomainMarker>("wait_for_signals")?;
2918        Ok(_response.map(|x| x.signals))
2919    }
2920
2921    /// Return the kernel object ID (koid) of the handle.
2922    pub fn r#get_koid(
2923        &self,
2924        mut handle: &HandleId,
2925        ___deadline: zx::MonotonicInstant,
2926    ) -> Result<FDomainGetKoidResult, fidl::Error> {
2927        let _response = self.client.send_query::<
2928            FDomainGetKoidRequest,
2929            fidl::encoding::FlexibleResultType<FDomainGetKoidResponse, Error>,
2930            FDomainMarker,
2931        >(
2932            (handle,),
2933            0x437db979a63402c3,
2934            fidl::encoding::DynamicFlags::FLEXIBLE,
2935            ___deadline,
2936        )?
2937        .into_result::<FDomainMarker>("get_koid")?;
2938        Ok(_response.map(|x| x.koid))
2939    }
2940}
2941
2942#[cfg(target_os = "fuchsia")]
2943impl From<FDomainSynchronousProxy> for zx::NullableHandle {
2944    fn from(value: FDomainSynchronousProxy) -> Self {
2945        value.into_channel().into()
2946    }
2947}
2948
2949#[cfg(target_os = "fuchsia")]
2950impl From<fidl::Channel> for FDomainSynchronousProxy {
2951    fn from(value: fidl::Channel) -> Self {
2952        Self::new(value)
2953    }
2954}
2955
2956#[cfg(target_os = "fuchsia")]
2957impl fidl::endpoints::FromClient for FDomainSynchronousProxy {
2958    type Protocol = FDomainMarker;
2959
2960    fn from_client(value: fidl::endpoints::ClientEnd<FDomainMarker>) -> Self {
2961        Self::new(value.into_channel())
2962    }
2963}
2964
2965#[derive(Debug, Clone)]
2966pub struct FDomainProxy {
2967    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2968}
2969
2970impl fidl::endpoints::Proxy for FDomainProxy {
2971    type Protocol = FDomainMarker;
2972
2973    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2974        Self::new(inner)
2975    }
2976
2977    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2978        self.client.into_channel().map_err(|client| Self { client })
2979    }
2980
2981    fn as_channel(&self) -> &::fidl::AsyncChannel {
2982        self.client.as_channel()
2983    }
2984}
2985
2986impl FDomainProxy {
2987    /// Create a new Proxy for fuchsia.fdomain/FDomain.
2988    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2989        let protocol_name = <FDomainMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2990        Self { client: fidl::client::Client::new(channel, protocol_name) }
2991    }
2992
2993    /// Get a Stream of events from the remote end of the protocol.
2994    ///
2995    /// # Panics
2996    ///
2997    /// Panics if the event stream was already taken.
2998    pub fn take_event_stream(&self) -> FDomainEventStream {
2999        FDomainEventStream { event_receiver: self.client.take_event_receiver() }
3000    }
3001
3002    /// Create a new channel in this FDomain and return both its ends.
3003    pub fn r#create_channel(
3004        &self,
3005        mut handles: &[NewHandleId; 2],
3006    ) -> fidl::client::QueryResponseFut<
3007        ChannelCreateChannelResult,
3008        fidl::encoding::DefaultFuchsiaResourceDialect,
3009    > {
3010        FDomainProxyInterface::r#create_channel(self, handles)
3011    }
3012
3013    /// Read a message from a channel. This method will fail if the channel is currently being read
3014    /// using the streaming read functions.
3015    ///
3016    /// Note that this method is not like zx_channel_read in that it will not
3017    /// return `SHOULD_WAIT` but will instead delay returning until there is data
3018    /// to return.
3019    pub fn r#read_channel(
3020        &self,
3021        mut handle: &HandleId,
3022    ) -> fidl::client::QueryResponseFut<
3023        ChannelReadChannelResult,
3024        fidl::encoding::DefaultFuchsiaResourceDialect,
3025    > {
3026        FDomainProxyInterface::r#read_channel(self, handle)
3027    }
3028
3029    /// Write to a channel. Handles are always consumed.
3030    pub fn r#write_channel(
3031        &self,
3032        mut handle: &HandleId,
3033        mut data: &[u8],
3034        mut handles: &Handles,
3035    ) -> fidl::client::QueryResponseFut<
3036        ChannelWriteChannelResult,
3037        fidl::encoding::DefaultFuchsiaResourceDialect,
3038    > {
3039        FDomainProxyInterface::r#write_channel(self, handle, data, handles)
3040    }
3041
3042    /// Starts reading from the given channel. Data is returned via the `ChannelStreamingData` event.
3043    /// That event will occur repeatedly until `ReadChannelStreamingStop` is called for the same handle
3044    /// or the event indicates the handle is closed.
3045    pub fn r#read_channel_streaming_start(
3046        &self,
3047        mut handle: &HandleId,
3048    ) -> fidl::client::QueryResponseFut<
3049        ChannelReadChannelStreamingStartResult,
3050        fidl::encoding::DefaultFuchsiaResourceDialect,
3051    > {
3052        FDomainProxyInterface::r#read_channel_streaming_start(self, handle)
3053    }
3054
3055    /// Stop asynchronous reading from the given channel.
3056    pub fn r#read_channel_streaming_stop(
3057        &self,
3058        mut handle: &HandleId,
3059    ) -> fidl::client::QueryResponseFut<
3060        ChannelReadChannelStreamingStopResult,
3061        fidl::encoding::DefaultFuchsiaResourceDialect,
3062    > {
3063        FDomainProxyInterface::r#read_channel_streaming_stop(self, handle)
3064    }
3065
3066    /// Create a new event in this FDomain and return it.
3067    pub fn r#create_event(
3068        &self,
3069        mut handle: &NewHandleId,
3070    ) -> fidl::client::QueryResponseFut<
3071        EventCreateEventResult,
3072        fidl::encoding::DefaultFuchsiaResourceDialect,
3073    > {
3074        FDomainProxyInterface::r#create_event(self, handle)
3075    }
3076
3077    /// Create a new event pair in this FDomain and return both its ends.
3078    pub fn r#create_event_pair(
3079        &self,
3080        mut handles: &[NewHandleId; 2],
3081    ) -> fidl::client::QueryResponseFut<
3082        EventPairCreateEventPairResult,
3083        fidl::encoding::DefaultFuchsiaResourceDialect,
3084    > {
3085        FDomainProxyInterface::r#create_event_pair(self, handles)
3086    }
3087
3088    /// Create a new socket in this FDomain and return both its ends.
3089    pub fn r#create_socket(
3090        &self,
3091        mut options: SocketType,
3092        mut handles: &[NewHandleId; 2],
3093    ) -> fidl::client::QueryResponseFut<
3094        SocketCreateSocketResult,
3095        fidl::encoding::DefaultFuchsiaResourceDialect,
3096    > {
3097        FDomainProxyInterface::r#create_socket(self, options, handles)
3098    }
3099
3100    /// Set the disposition of a given socket.
3101    pub fn r#set_socket_disposition(
3102        &self,
3103        mut handle: &HandleId,
3104        mut disposition: SocketDisposition,
3105        mut disposition_peer: SocketDisposition,
3106    ) -> fidl::client::QueryResponseFut<
3107        SocketSetSocketDispositionResult,
3108        fidl::encoding::DefaultFuchsiaResourceDialect,
3109    > {
3110        FDomainProxyInterface::r#set_socket_disposition(self, handle, disposition, disposition_peer)
3111    }
3112
3113    /// Read data from a socket. This method will fail if the socket is currently being read
3114    /// asynchronously.
3115    pub fn r#read_socket(
3116        &self,
3117        mut handle: &HandleId,
3118        mut max_bytes: u64,
3119    ) -> fidl::client::QueryResponseFut<
3120        SocketReadSocketResult,
3121        fidl::encoding::DefaultFuchsiaResourceDialect,
3122    > {
3123        FDomainProxyInterface::r#read_socket(self, handle, max_bytes)
3124    }
3125
3126    /// Write to a socket. This will attempt to write all the data passed, and
3127    /// will block and retry whenever it is safe (e.g. it should never return
3128    /// SHOULD_WAIT). The `WriteSocketError` contains a `wrote` parameter to
3129    /// indicate if some bytes were written successfully before the failure
3130    /// occurred.
3131    pub fn r#write_socket(
3132        &self,
3133        mut handle: &HandleId,
3134        mut data: &[u8],
3135    ) -> fidl::client::QueryResponseFut<
3136        SocketWriteSocketResult,
3137        fidl::encoding::DefaultFuchsiaResourceDialect,
3138    > {
3139        FDomainProxyInterface::r#write_socket(self, handle, data)
3140    }
3141
3142    /// Starts reading from the given socket. Data is returned via the `SocketStreamingData` event. That
3143    /// event will occur repeatedly until `ReadSocketStreamingStop` is called for the same handle or the
3144    /// event indicates the handle is closed.
3145    pub fn r#read_socket_streaming_start(
3146        &self,
3147        mut handle: &HandleId,
3148    ) -> fidl::client::QueryResponseFut<
3149        SocketReadSocketStreamingStartResult,
3150        fidl::encoding::DefaultFuchsiaResourceDialect,
3151    > {
3152        FDomainProxyInterface::r#read_socket_streaming_start(self, handle)
3153    }
3154
3155    /// Stop asynchronous reading from the given socket.
3156    pub fn r#read_socket_streaming_stop(
3157        &self,
3158        mut handle: &HandleId,
3159    ) -> fidl::client::QueryResponseFut<
3160        SocketReadSocketStreamingStopResult,
3161        fidl::encoding::DefaultFuchsiaResourceDialect,
3162    > {
3163        FDomainProxyInterface::r#read_socket_streaming_stop(self, handle)
3164    }
3165
3166    /// Adds a new channel handle to this namespace which points to a
3167    /// fuchsia.io.Directory. Can be used to "bootstrap" the FDomain.
3168    pub fn r#get_namespace(
3169        &self,
3170        mut new_handle: &NewHandleId,
3171    ) -> fidl::client::QueryResponseFut<
3172        FDomainGetNamespaceResult,
3173        fidl::encoding::DefaultFuchsiaResourceDialect,
3174    > {
3175        FDomainProxyInterface::r#get_namespace(self, new_handle)
3176    }
3177
3178    /// Close one or more handles.
3179    pub fn r#close(
3180        &self,
3181        mut handles: &[HandleId],
3182    ) -> fidl::client::QueryResponseFut<
3183        FDomainCloseResult,
3184        fidl::encoding::DefaultFuchsiaResourceDialect,
3185    > {
3186        FDomainProxyInterface::r#close(self, handles)
3187    }
3188
3189    /// Duplicate a handle.
3190    pub fn r#duplicate(
3191        &self,
3192        mut handle: &HandleId,
3193        mut new_handle: &NewHandleId,
3194        mut rights: fidl::Rights,
3195    ) -> fidl::client::QueryResponseFut<
3196        FDomainDuplicateResult,
3197        fidl::encoding::DefaultFuchsiaResourceDialect,
3198    > {
3199        FDomainProxyInterface::r#duplicate(self, handle, new_handle, rights)
3200    }
3201
3202    /// Close a handle and replace it with a new one with possibly different
3203    /// rights.
3204    pub fn r#replace(
3205        &self,
3206        mut handle: &HandleId,
3207        mut new_handle: &NewHandleId,
3208        mut rights: fidl::Rights,
3209    ) -> fidl::client::QueryResponseFut<
3210        FDomainReplaceResult,
3211        fidl::encoding::DefaultFuchsiaResourceDialect,
3212    > {
3213        FDomainProxyInterface::r#replace(self, handle, new_handle, rights)
3214    }
3215
3216    /// Set or clear signals on a handle.
3217    pub fn r#signal(
3218        &self,
3219        mut handle: &HandleId,
3220        mut set: u32,
3221        mut clear: u32,
3222    ) -> fidl::client::QueryResponseFut<
3223        FDomainSignalResult,
3224        fidl::encoding::DefaultFuchsiaResourceDialect,
3225    > {
3226        FDomainProxyInterface::r#signal(self, handle, set, clear)
3227    }
3228
3229    /// Set or clear signals on a handle's peer.
3230    pub fn r#signal_peer(
3231        &self,
3232        mut handle: &HandleId,
3233        mut set: u32,
3234        mut clear: u32,
3235    ) -> fidl::client::QueryResponseFut<
3236        FDomainSignalPeerResult,
3237        fidl::encoding::DefaultFuchsiaResourceDialect,
3238    > {
3239        FDomainProxyInterface::r#signal_peer(self, handle, set, clear)
3240    }
3241
3242    /// Wait for signals from the given handle. Reply will be returned when one
3243    /// of the given signals is asserted.
3244    pub fn r#wait_for_signals(
3245        &self,
3246        mut handle: &HandleId,
3247        mut signals: u32,
3248    ) -> fidl::client::QueryResponseFut<
3249        FDomainWaitForSignalsResult,
3250        fidl::encoding::DefaultFuchsiaResourceDialect,
3251    > {
3252        FDomainProxyInterface::r#wait_for_signals(self, handle, signals)
3253    }
3254
3255    /// Return the kernel object ID (koid) of the handle.
3256    pub fn r#get_koid(
3257        &self,
3258        mut handle: &HandleId,
3259    ) -> fidl::client::QueryResponseFut<
3260        FDomainGetKoidResult,
3261        fidl::encoding::DefaultFuchsiaResourceDialect,
3262    > {
3263        FDomainProxyInterface::r#get_koid(self, handle)
3264    }
3265}
3266
3267impl FDomainProxyInterface for FDomainProxy {
3268    type CreateChannelResponseFut = fidl::client::QueryResponseFut<
3269        ChannelCreateChannelResult,
3270        fidl::encoding::DefaultFuchsiaResourceDialect,
3271    >;
3272    fn r#create_channel(&self, mut handles: &[NewHandleId; 2]) -> Self::CreateChannelResponseFut {
3273        fn _decode(
3274            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3275        ) -> Result<ChannelCreateChannelResult, fidl::Error> {
3276            let _response = fidl::client::decode_transaction_body::<
3277                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
3278                fidl::encoding::DefaultFuchsiaResourceDialect,
3279                0x182d38bfe88673b5,
3280            >(_buf?)?
3281            .into_result::<FDomainMarker>("create_channel")?;
3282            Ok(_response.map(|x| x))
3283        }
3284        self.client
3285            .send_query_and_decode::<ChannelCreateChannelRequest, ChannelCreateChannelResult>(
3286                (handles,),
3287                0x182d38bfe88673b5,
3288                fidl::encoding::DynamicFlags::FLEXIBLE,
3289                _decode,
3290            )
3291    }
3292
3293    type ReadChannelResponseFut = fidl::client::QueryResponseFut<
3294        ChannelReadChannelResult,
3295        fidl::encoding::DefaultFuchsiaResourceDialect,
3296    >;
3297    fn r#read_channel(&self, mut handle: &HandleId) -> Self::ReadChannelResponseFut {
3298        fn _decode(
3299            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3300        ) -> Result<ChannelReadChannelResult, fidl::Error> {
3301            let _response = fidl::client::decode_transaction_body::<
3302                fidl::encoding::FlexibleResultType<ChannelMessage, Error>,
3303                fidl::encoding::DefaultFuchsiaResourceDialect,
3304                0x6ef47bf27bf7d050,
3305            >(_buf?)?
3306            .into_result::<FDomainMarker>("read_channel")?;
3307            Ok(_response.map(|x| (x.data, x.handles)))
3308        }
3309        self.client.send_query_and_decode::<ChannelReadChannelRequest, ChannelReadChannelResult>(
3310            (handle,),
3311            0x6ef47bf27bf7d050,
3312            fidl::encoding::DynamicFlags::FLEXIBLE,
3313            _decode,
3314        )
3315    }
3316
3317    type WriteChannelResponseFut = fidl::client::QueryResponseFut<
3318        ChannelWriteChannelResult,
3319        fidl::encoding::DefaultFuchsiaResourceDialect,
3320    >;
3321    fn r#write_channel(
3322        &self,
3323        mut handle: &HandleId,
3324        mut data: &[u8],
3325        mut handles: &Handles,
3326    ) -> Self::WriteChannelResponseFut {
3327        fn _decode(
3328            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3329        ) -> Result<ChannelWriteChannelResult, fidl::Error> {
3330            let _response = fidl::client::decode_transaction_body::<
3331                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, WriteChannelError>,
3332                fidl::encoding::DefaultFuchsiaResourceDialect,
3333                0x75a2559b945d5eb5,
3334            >(_buf?)?
3335            .into_result::<FDomainMarker>("write_channel")?;
3336            Ok(_response.map(|x| x))
3337        }
3338        self.client.send_query_and_decode::<ChannelWriteChannelRequest, ChannelWriteChannelResult>(
3339            (handle, data, handles),
3340            0x75a2559b945d5eb5,
3341            fidl::encoding::DynamicFlags::FLEXIBLE,
3342            _decode,
3343        )
3344    }
3345
3346    type ReadChannelStreamingStartResponseFut = fidl::client::QueryResponseFut<
3347        ChannelReadChannelStreamingStartResult,
3348        fidl::encoding::DefaultFuchsiaResourceDialect,
3349    >;
3350    fn r#read_channel_streaming_start(
3351        &self,
3352        mut handle: &HandleId,
3353    ) -> Self::ReadChannelStreamingStartResponseFut {
3354        fn _decode(
3355            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3356        ) -> Result<ChannelReadChannelStreamingStartResult, fidl::Error> {
3357            let _response = fidl::client::decode_transaction_body::<
3358                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
3359                fidl::encoding::DefaultFuchsiaResourceDialect,
3360                0x3c73e85476a203df,
3361            >(_buf?)?
3362            .into_result::<FDomainMarker>("read_channel_streaming_start")?;
3363            Ok(_response.map(|x| x))
3364        }
3365        self.client.send_query_and_decode::<
3366            ChannelReadChannelStreamingStartRequest,
3367            ChannelReadChannelStreamingStartResult,
3368        >(
3369            (handle,),
3370            0x3c73e85476a203df,
3371            fidl::encoding::DynamicFlags::FLEXIBLE,
3372            _decode,
3373        )
3374    }
3375
3376    type ReadChannelStreamingStopResponseFut = fidl::client::QueryResponseFut<
3377        ChannelReadChannelStreamingStopResult,
3378        fidl::encoding::DefaultFuchsiaResourceDialect,
3379    >;
3380    fn r#read_channel_streaming_stop(
3381        &self,
3382        mut handle: &HandleId,
3383    ) -> Self::ReadChannelStreamingStopResponseFut {
3384        fn _decode(
3385            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3386        ) -> Result<ChannelReadChannelStreamingStopResult, fidl::Error> {
3387            let _response = fidl::client::decode_transaction_body::<
3388                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
3389                fidl::encoding::DefaultFuchsiaResourceDialect,
3390                0x56f21d6ed68186e0,
3391            >(_buf?)?
3392            .into_result::<FDomainMarker>("read_channel_streaming_stop")?;
3393            Ok(_response.map(|x| x))
3394        }
3395        self.client.send_query_and_decode::<
3396            ChannelReadChannelStreamingStopRequest,
3397            ChannelReadChannelStreamingStopResult,
3398        >(
3399            (handle,),
3400            0x56f21d6ed68186e0,
3401            fidl::encoding::DynamicFlags::FLEXIBLE,
3402            _decode,
3403        )
3404    }
3405
3406    type CreateEventResponseFut = fidl::client::QueryResponseFut<
3407        EventCreateEventResult,
3408        fidl::encoding::DefaultFuchsiaResourceDialect,
3409    >;
3410    fn r#create_event(&self, mut handle: &NewHandleId) -> Self::CreateEventResponseFut {
3411        fn _decode(
3412            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3413        ) -> Result<EventCreateEventResult, fidl::Error> {
3414            let _response = fidl::client::decode_transaction_body::<
3415                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
3416                fidl::encoding::DefaultFuchsiaResourceDialect,
3417                0x7b05b3f262635987,
3418            >(_buf?)?
3419            .into_result::<FDomainMarker>("create_event")?;
3420            Ok(_response.map(|x| x))
3421        }
3422        self.client.send_query_and_decode::<EventCreateEventRequest, EventCreateEventResult>(
3423            (handle,),
3424            0x7b05b3f262635987,
3425            fidl::encoding::DynamicFlags::FLEXIBLE,
3426            _decode,
3427        )
3428    }
3429
3430    type CreateEventPairResponseFut = fidl::client::QueryResponseFut<
3431        EventPairCreateEventPairResult,
3432        fidl::encoding::DefaultFuchsiaResourceDialect,
3433    >;
3434    fn r#create_event_pair(
3435        &self,
3436        mut handles: &[NewHandleId; 2],
3437    ) -> Self::CreateEventPairResponseFut {
3438        fn _decode(
3439            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3440        ) -> Result<EventPairCreateEventPairResult, fidl::Error> {
3441            let _response = fidl::client::decode_transaction_body::<
3442                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
3443                fidl::encoding::DefaultFuchsiaResourceDialect,
3444                0x7aef61effa65656d,
3445            >(_buf?)?
3446            .into_result::<FDomainMarker>("create_event_pair")?;
3447            Ok(_response.map(|x| x))
3448        }
3449        self.client.send_query_and_decode::<
3450            EventPairCreateEventPairRequest,
3451            EventPairCreateEventPairResult,
3452        >(
3453            (handles,),
3454            0x7aef61effa65656d,
3455            fidl::encoding::DynamicFlags::FLEXIBLE,
3456            _decode,
3457        )
3458    }
3459
3460    type CreateSocketResponseFut = fidl::client::QueryResponseFut<
3461        SocketCreateSocketResult,
3462        fidl::encoding::DefaultFuchsiaResourceDialect,
3463    >;
3464    fn r#create_socket(
3465        &self,
3466        mut options: SocketType,
3467        mut handles: &[NewHandleId; 2],
3468    ) -> Self::CreateSocketResponseFut {
3469        fn _decode(
3470            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3471        ) -> Result<SocketCreateSocketResult, fidl::Error> {
3472            let _response = fidl::client::decode_transaction_body::<
3473                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
3474                fidl::encoding::DefaultFuchsiaResourceDialect,
3475                0x200bf0ea21932de0,
3476            >(_buf?)?
3477            .into_result::<FDomainMarker>("create_socket")?;
3478            Ok(_response.map(|x| x))
3479        }
3480        self.client.send_query_and_decode::<SocketCreateSocketRequest, SocketCreateSocketResult>(
3481            (options, handles),
3482            0x200bf0ea21932de0,
3483            fidl::encoding::DynamicFlags::FLEXIBLE,
3484            _decode,
3485        )
3486    }
3487
3488    type SetSocketDispositionResponseFut = fidl::client::QueryResponseFut<
3489        SocketSetSocketDispositionResult,
3490        fidl::encoding::DefaultFuchsiaResourceDialect,
3491    >;
3492    fn r#set_socket_disposition(
3493        &self,
3494        mut handle: &HandleId,
3495        mut disposition: SocketDisposition,
3496        mut disposition_peer: SocketDisposition,
3497    ) -> Self::SetSocketDispositionResponseFut {
3498        fn _decode(
3499            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3500        ) -> Result<SocketSetSocketDispositionResult, fidl::Error> {
3501            let _response = fidl::client::decode_transaction_body::<
3502                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
3503                fidl::encoding::DefaultFuchsiaResourceDialect,
3504                0x60d3c7ccb17f9bdf,
3505            >(_buf?)?
3506            .into_result::<FDomainMarker>("set_socket_disposition")?;
3507            Ok(_response.map(|x| x))
3508        }
3509        self.client.send_query_and_decode::<
3510            SocketSetSocketDispositionRequest,
3511            SocketSetSocketDispositionResult,
3512        >(
3513            (handle, disposition, disposition_peer,),
3514            0x60d3c7ccb17f9bdf,
3515            fidl::encoding::DynamicFlags::FLEXIBLE,
3516            _decode,
3517        )
3518    }
3519
3520    type ReadSocketResponseFut = fidl::client::QueryResponseFut<
3521        SocketReadSocketResult,
3522        fidl::encoding::DefaultFuchsiaResourceDialect,
3523    >;
3524    fn r#read_socket(
3525        &self,
3526        mut handle: &HandleId,
3527        mut max_bytes: u64,
3528    ) -> Self::ReadSocketResponseFut {
3529        fn _decode(
3530            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3531        ) -> Result<SocketReadSocketResult, fidl::Error> {
3532            let _response = fidl::client::decode_transaction_body::<
3533                fidl::encoding::FlexibleResultType<SocketData, Error>,
3534                fidl::encoding::DefaultFuchsiaResourceDialect,
3535                0x1da8aabec249c02e,
3536            >(_buf?)?
3537            .into_result::<FDomainMarker>("read_socket")?;
3538            Ok(_response.map(|x| (x.data, x.is_datagram)))
3539        }
3540        self.client.send_query_and_decode::<SocketReadSocketRequest, SocketReadSocketResult>(
3541            (handle, max_bytes),
3542            0x1da8aabec249c02e,
3543            fidl::encoding::DynamicFlags::FLEXIBLE,
3544            _decode,
3545        )
3546    }
3547
3548    type WriteSocketResponseFut = fidl::client::QueryResponseFut<
3549        SocketWriteSocketResult,
3550        fidl::encoding::DefaultFuchsiaResourceDialect,
3551    >;
3552    fn r#write_socket(
3553        &self,
3554        mut handle: &HandleId,
3555        mut data: &[u8],
3556    ) -> Self::WriteSocketResponseFut {
3557        fn _decode(
3558            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3559        ) -> Result<SocketWriteSocketResult, fidl::Error> {
3560            let _response = fidl::client::decode_transaction_body::<
3561                fidl::encoding::FlexibleResultType<SocketWriteSocketResponse, WriteSocketError>,
3562                fidl::encoding::DefaultFuchsiaResourceDialect,
3563                0x5b541623cbbbf683,
3564            >(_buf?)?
3565            .into_result::<FDomainMarker>("write_socket")?;
3566            Ok(_response.map(|x| x.wrote))
3567        }
3568        self.client.send_query_and_decode::<SocketWriteSocketRequest, SocketWriteSocketResult>(
3569            (handle, data),
3570            0x5b541623cbbbf683,
3571            fidl::encoding::DynamicFlags::FLEXIBLE,
3572            _decode,
3573        )
3574    }
3575
3576    type ReadSocketStreamingStartResponseFut = fidl::client::QueryResponseFut<
3577        SocketReadSocketStreamingStartResult,
3578        fidl::encoding::DefaultFuchsiaResourceDialect,
3579    >;
3580    fn r#read_socket_streaming_start(
3581        &self,
3582        mut handle: &HandleId,
3583    ) -> Self::ReadSocketStreamingStartResponseFut {
3584        fn _decode(
3585            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3586        ) -> Result<SocketReadSocketStreamingStartResult, fidl::Error> {
3587            let _response = fidl::client::decode_transaction_body::<
3588                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
3589                fidl::encoding::DefaultFuchsiaResourceDialect,
3590                0x2a592748d5f33445,
3591            >(_buf?)?
3592            .into_result::<FDomainMarker>("read_socket_streaming_start")?;
3593            Ok(_response.map(|x| x))
3594        }
3595        self.client.send_query_and_decode::<
3596            SocketReadSocketStreamingStartRequest,
3597            SocketReadSocketStreamingStartResult,
3598        >(
3599            (handle,),
3600            0x2a592748d5f33445,
3601            fidl::encoding::DynamicFlags::FLEXIBLE,
3602            _decode,
3603        )
3604    }
3605
3606    type ReadSocketStreamingStopResponseFut = fidl::client::QueryResponseFut<
3607        SocketReadSocketStreamingStopResult,
3608        fidl::encoding::DefaultFuchsiaResourceDialect,
3609    >;
3610    fn r#read_socket_streaming_stop(
3611        &self,
3612        mut handle: &HandleId,
3613    ) -> Self::ReadSocketStreamingStopResponseFut {
3614        fn _decode(
3615            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3616        ) -> Result<SocketReadSocketStreamingStopResult, fidl::Error> {
3617            let _response = fidl::client::decode_transaction_body::<
3618                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
3619                fidl::encoding::DefaultFuchsiaResourceDialect,
3620                0x53e5cade5f4d22e7,
3621            >(_buf?)?
3622            .into_result::<FDomainMarker>("read_socket_streaming_stop")?;
3623            Ok(_response.map(|x| x))
3624        }
3625        self.client.send_query_and_decode::<
3626            SocketReadSocketStreamingStopRequest,
3627            SocketReadSocketStreamingStopResult,
3628        >(
3629            (handle,),
3630            0x53e5cade5f4d22e7,
3631            fidl::encoding::DynamicFlags::FLEXIBLE,
3632            _decode,
3633        )
3634    }
3635
3636    type GetNamespaceResponseFut = fidl::client::QueryResponseFut<
3637        FDomainGetNamespaceResult,
3638        fidl::encoding::DefaultFuchsiaResourceDialect,
3639    >;
3640    fn r#get_namespace(&self, mut new_handle: &NewHandleId) -> Self::GetNamespaceResponseFut {
3641        fn _decode(
3642            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3643        ) -> Result<FDomainGetNamespaceResult, fidl::Error> {
3644            let _response = fidl::client::decode_transaction_body::<
3645                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
3646                fidl::encoding::DefaultFuchsiaResourceDialect,
3647                0x74f2e74d9f53e11e,
3648            >(_buf?)?
3649            .into_result::<FDomainMarker>("get_namespace")?;
3650            Ok(_response.map(|x| x))
3651        }
3652        self.client.send_query_and_decode::<FDomainGetNamespaceRequest, FDomainGetNamespaceResult>(
3653            (new_handle,),
3654            0x74f2e74d9f53e11e,
3655            fidl::encoding::DynamicFlags::FLEXIBLE,
3656            _decode,
3657        )
3658    }
3659
3660    type CloseResponseFut = fidl::client::QueryResponseFut<
3661        FDomainCloseResult,
3662        fidl::encoding::DefaultFuchsiaResourceDialect,
3663    >;
3664    fn r#close(&self, mut handles: &[HandleId]) -> Self::CloseResponseFut {
3665        fn _decode(
3666            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3667        ) -> Result<FDomainCloseResult, fidl::Error> {
3668            let _response = fidl::client::decode_transaction_body::<
3669                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
3670                fidl::encoding::DefaultFuchsiaResourceDialect,
3671                0x5ef8c24362964257,
3672            >(_buf?)?
3673            .into_result::<FDomainMarker>("close")?;
3674            Ok(_response.map(|x| x))
3675        }
3676        self.client.send_query_and_decode::<FDomainCloseRequest, FDomainCloseResult>(
3677            (handles,),
3678            0x5ef8c24362964257,
3679            fidl::encoding::DynamicFlags::FLEXIBLE,
3680            _decode,
3681        )
3682    }
3683
3684    type DuplicateResponseFut = fidl::client::QueryResponseFut<
3685        FDomainDuplicateResult,
3686        fidl::encoding::DefaultFuchsiaResourceDialect,
3687    >;
3688    fn r#duplicate(
3689        &self,
3690        mut handle: &HandleId,
3691        mut new_handle: &NewHandleId,
3692        mut rights: fidl::Rights,
3693    ) -> Self::DuplicateResponseFut {
3694        fn _decode(
3695            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3696        ) -> Result<FDomainDuplicateResult, fidl::Error> {
3697            let _response = fidl::client::decode_transaction_body::<
3698                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
3699                fidl::encoding::DefaultFuchsiaResourceDialect,
3700                0x7a85b94bd1777ab9,
3701            >(_buf?)?
3702            .into_result::<FDomainMarker>("duplicate")?;
3703            Ok(_response.map(|x| x))
3704        }
3705        self.client.send_query_and_decode::<FDomainDuplicateRequest, FDomainDuplicateResult>(
3706            (handle, new_handle, rights),
3707            0x7a85b94bd1777ab9,
3708            fidl::encoding::DynamicFlags::FLEXIBLE,
3709            _decode,
3710        )
3711    }
3712
3713    type ReplaceResponseFut = fidl::client::QueryResponseFut<
3714        FDomainReplaceResult,
3715        fidl::encoding::DefaultFuchsiaResourceDialect,
3716    >;
3717    fn r#replace(
3718        &self,
3719        mut handle: &HandleId,
3720        mut new_handle: &NewHandleId,
3721        mut rights: fidl::Rights,
3722    ) -> Self::ReplaceResponseFut {
3723        fn _decode(
3724            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3725        ) -> Result<FDomainReplaceResult, fidl::Error> {
3726            let _response = fidl::client::decode_transaction_body::<
3727                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
3728                fidl::encoding::DefaultFuchsiaResourceDialect,
3729                0x32fa64625a5bd3be,
3730            >(_buf?)?
3731            .into_result::<FDomainMarker>("replace")?;
3732            Ok(_response.map(|x| x))
3733        }
3734        self.client.send_query_and_decode::<FDomainReplaceRequest, FDomainReplaceResult>(
3735            (handle, new_handle, rights),
3736            0x32fa64625a5bd3be,
3737            fidl::encoding::DynamicFlags::FLEXIBLE,
3738            _decode,
3739        )
3740    }
3741
3742    type SignalResponseFut = fidl::client::QueryResponseFut<
3743        FDomainSignalResult,
3744        fidl::encoding::DefaultFuchsiaResourceDialect,
3745    >;
3746    fn r#signal(
3747        &self,
3748        mut handle: &HandleId,
3749        mut set: u32,
3750        mut clear: u32,
3751    ) -> Self::SignalResponseFut {
3752        fn _decode(
3753            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3754        ) -> Result<FDomainSignalResult, fidl::Error> {
3755            let _response = fidl::client::decode_transaction_body::<
3756                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
3757                fidl::encoding::DefaultFuchsiaResourceDialect,
3758                0xe8352fb978996d9,
3759            >(_buf?)?
3760            .into_result::<FDomainMarker>("signal")?;
3761            Ok(_response.map(|x| x))
3762        }
3763        self.client.send_query_and_decode::<FDomainSignalRequest, FDomainSignalResult>(
3764            (handle, set, clear),
3765            0xe8352fb978996d9,
3766            fidl::encoding::DynamicFlags::FLEXIBLE,
3767            _decode,
3768        )
3769    }
3770
3771    type SignalPeerResponseFut = fidl::client::QueryResponseFut<
3772        FDomainSignalPeerResult,
3773        fidl::encoding::DefaultFuchsiaResourceDialect,
3774    >;
3775    fn r#signal_peer(
3776        &self,
3777        mut handle: &HandleId,
3778        mut set: u32,
3779        mut clear: u32,
3780    ) -> Self::SignalPeerResponseFut {
3781        fn _decode(
3782            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3783        ) -> Result<FDomainSignalPeerResult, fidl::Error> {
3784            let _response = fidl::client::decode_transaction_body::<
3785                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
3786                fidl::encoding::DefaultFuchsiaResourceDialect,
3787                0x7e84ec8ca7eabaf8,
3788            >(_buf?)?
3789            .into_result::<FDomainMarker>("signal_peer")?;
3790            Ok(_response.map(|x| x))
3791        }
3792        self.client.send_query_and_decode::<FDomainSignalPeerRequest, FDomainSignalPeerResult>(
3793            (handle, set, clear),
3794            0x7e84ec8ca7eabaf8,
3795            fidl::encoding::DynamicFlags::FLEXIBLE,
3796            _decode,
3797        )
3798    }
3799
3800    type WaitForSignalsResponseFut = fidl::client::QueryResponseFut<
3801        FDomainWaitForSignalsResult,
3802        fidl::encoding::DefaultFuchsiaResourceDialect,
3803    >;
3804    fn r#wait_for_signals(
3805        &self,
3806        mut handle: &HandleId,
3807        mut signals: u32,
3808    ) -> Self::WaitForSignalsResponseFut {
3809        fn _decode(
3810            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3811        ) -> Result<FDomainWaitForSignalsResult, fidl::Error> {
3812            let _response = fidl::client::decode_transaction_body::<
3813                fidl::encoding::FlexibleResultType<FDomainWaitForSignalsResponse, Error>,
3814                fidl::encoding::DefaultFuchsiaResourceDialect,
3815                0x8f72d9b4b85c1eb,
3816            >(_buf?)?
3817            .into_result::<FDomainMarker>("wait_for_signals")?;
3818            Ok(_response.map(|x| x.signals))
3819        }
3820        self.client
3821            .send_query_and_decode::<FDomainWaitForSignalsRequest, FDomainWaitForSignalsResult>(
3822                (handle, signals),
3823                0x8f72d9b4b85c1eb,
3824                fidl::encoding::DynamicFlags::FLEXIBLE,
3825                _decode,
3826            )
3827    }
3828
3829    type GetKoidResponseFut = fidl::client::QueryResponseFut<
3830        FDomainGetKoidResult,
3831        fidl::encoding::DefaultFuchsiaResourceDialect,
3832    >;
3833    fn r#get_koid(&self, mut handle: &HandleId) -> Self::GetKoidResponseFut {
3834        fn _decode(
3835            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3836        ) -> Result<FDomainGetKoidResult, fidl::Error> {
3837            let _response = fidl::client::decode_transaction_body::<
3838                fidl::encoding::FlexibleResultType<FDomainGetKoidResponse, Error>,
3839                fidl::encoding::DefaultFuchsiaResourceDialect,
3840                0x437db979a63402c3,
3841            >(_buf?)?
3842            .into_result::<FDomainMarker>("get_koid")?;
3843            Ok(_response.map(|x| x.koid))
3844        }
3845        self.client.send_query_and_decode::<FDomainGetKoidRequest, FDomainGetKoidResult>(
3846            (handle,),
3847            0x437db979a63402c3,
3848            fidl::encoding::DynamicFlags::FLEXIBLE,
3849            _decode,
3850        )
3851    }
3852}
3853
3854pub struct FDomainEventStream {
3855    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3856}
3857
3858impl std::marker::Unpin for FDomainEventStream {}
3859
3860impl futures::stream::FusedStream for FDomainEventStream {
3861    fn is_terminated(&self) -> bool {
3862        self.event_receiver.is_terminated()
3863    }
3864}
3865
3866impl futures::Stream for FDomainEventStream {
3867    type Item = Result<FDomainEvent, fidl::Error>;
3868
3869    fn poll_next(
3870        mut self: std::pin::Pin<&mut Self>,
3871        cx: &mut std::task::Context<'_>,
3872    ) -> std::task::Poll<Option<Self::Item>> {
3873        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3874            &mut self.event_receiver,
3875            cx
3876        )?) {
3877            Some(buf) => std::task::Poll::Ready(Some(FDomainEvent::decode(buf))),
3878            None => std::task::Poll::Ready(None),
3879        }
3880    }
3881}
3882
3883#[derive(Debug)]
3884pub enum FDomainEvent {
3885    OnChannelStreamingData {
3886        handle: HandleId,
3887        channel_sent: ChannelSent,
3888    },
3889    OnSocketStreamingData {
3890        handle: HandleId,
3891        socket_message: SocketMessage,
3892    },
3893    #[non_exhaustive]
3894    _UnknownEvent {
3895        /// Ordinal of the event that was sent.
3896        ordinal: u64,
3897    },
3898}
3899
3900impl FDomainEvent {
3901    #[allow(irrefutable_let_patterns)]
3902    pub fn into_on_channel_streaming_data(self) -> Option<(HandleId, ChannelSent)> {
3903        if let FDomainEvent::OnChannelStreamingData { handle, channel_sent } = self {
3904            Some((handle, channel_sent))
3905        } else {
3906            None
3907        }
3908    }
3909    #[allow(irrefutable_let_patterns)]
3910    pub fn into_on_socket_streaming_data(self) -> Option<(HandleId, SocketMessage)> {
3911        if let FDomainEvent::OnSocketStreamingData { handle, socket_message } = self {
3912            Some((handle, socket_message))
3913        } else {
3914            None
3915        }
3916    }
3917
3918    /// Decodes a message buffer as a [`FDomainEvent`].
3919    fn decode(
3920        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3921    ) -> Result<FDomainEvent, fidl::Error> {
3922        let (bytes, _handles) = buf.split_mut();
3923        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3924        debug_assert_eq!(tx_header.tx_id, 0);
3925        match tx_header.ordinal {
3926            0x7d4431805202dfe1 => {
3927                let mut out = fidl::new_empty!(
3928                    ChannelOnChannelStreamingDataRequest,
3929                    fidl::encoding::DefaultFuchsiaResourceDialect
3930                );
3931                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChannelOnChannelStreamingDataRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
3932                Ok((FDomainEvent::OnChannelStreamingData {
3933                    handle: out.handle,
3934                    channel_sent: out.channel_sent,
3935                }))
3936            }
3937            0x998b5e66b3c80a2 => {
3938                let mut out = fidl::new_empty!(
3939                    SocketOnSocketStreamingDataRequest,
3940                    fidl::encoding::DefaultFuchsiaResourceDialect
3941                );
3942                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SocketOnSocketStreamingDataRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
3943                Ok((FDomainEvent::OnSocketStreamingData {
3944                    handle: out.handle,
3945                    socket_message: out.socket_message,
3946                }))
3947            }
3948            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
3949                Ok(FDomainEvent::_UnknownEvent { ordinal: tx_header.ordinal })
3950            }
3951            _ => Err(fidl::Error::UnknownOrdinal {
3952                ordinal: tx_header.ordinal,
3953                protocol_name: <FDomainMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3954            }),
3955        }
3956    }
3957}
3958
3959/// A Stream of incoming requests for fuchsia.fdomain/FDomain.
3960pub struct FDomainRequestStream {
3961    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3962    is_terminated: bool,
3963}
3964
3965impl std::marker::Unpin for FDomainRequestStream {}
3966
3967impl futures::stream::FusedStream for FDomainRequestStream {
3968    fn is_terminated(&self) -> bool {
3969        self.is_terminated
3970    }
3971}
3972
3973impl fidl::endpoints::RequestStream for FDomainRequestStream {
3974    type Protocol = FDomainMarker;
3975    type ControlHandle = FDomainControlHandle;
3976
3977    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3978        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3979    }
3980
3981    fn control_handle(&self) -> Self::ControlHandle {
3982        FDomainControlHandle { inner: self.inner.clone() }
3983    }
3984
3985    fn into_inner(
3986        self,
3987    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3988    {
3989        (self.inner, self.is_terminated)
3990    }
3991
3992    fn from_inner(
3993        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3994        is_terminated: bool,
3995    ) -> Self {
3996        Self { inner, is_terminated }
3997    }
3998}
3999
4000impl futures::Stream for FDomainRequestStream {
4001    type Item = Result<FDomainRequest, fidl::Error>;
4002
4003    fn poll_next(
4004        mut self: std::pin::Pin<&mut Self>,
4005        cx: &mut std::task::Context<'_>,
4006    ) -> std::task::Poll<Option<Self::Item>> {
4007        let this = &mut *self;
4008        if this.inner.check_shutdown(cx) {
4009            this.is_terminated = true;
4010            return std::task::Poll::Ready(None);
4011        }
4012        if this.is_terminated {
4013            panic!("polled FDomainRequestStream after completion");
4014        }
4015        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4016            |bytes, handles| {
4017                match this.inner.channel().read_etc(cx, bytes, handles) {
4018                    std::task::Poll::Ready(Ok(())) => {}
4019                    std::task::Poll::Pending => return std::task::Poll::Pending,
4020                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4021                        this.is_terminated = true;
4022                        return std::task::Poll::Ready(None);
4023                    }
4024                    std::task::Poll::Ready(Err(e)) => {
4025                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4026                            e.into(),
4027                        ))));
4028                    }
4029                }
4030
4031                // A message has been received from the channel
4032                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4033
4034                std::task::Poll::Ready(Some(match header.ordinal {
4035                    0x182d38bfe88673b5 => {
4036                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4037                        let mut req = fidl::new_empty!(
4038                            ChannelCreateChannelRequest,
4039                            fidl::encoding::DefaultFuchsiaResourceDialect
4040                        );
4041                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChannelCreateChannelRequest>(&header, _body_bytes, handles, &mut req)?;
4042                        let control_handle = FDomainControlHandle { inner: this.inner.clone() };
4043                        Ok(FDomainRequest::CreateChannel {
4044                            handles: req.handles,
4045
4046                            responder: FDomainCreateChannelResponder {
4047                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4048                                tx_id: header.tx_id,
4049                            },
4050                        })
4051                    }
4052                    0x6ef47bf27bf7d050 => {
4053                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4054                        let mut req = fidl::new_empty!(
4055                            ChannelReadChannelRequest,
4056                            fidl::encoding::DefaultFuchsiaResourceDialect
4057                        );
4058                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChannelReadChannelRequest>(&header, _body_bytes, handles, &mut req)?;
4059                        let control_handle = FDomainControlHandle { inner: this.inner.clone() };
4060                        Ok(FDomainRequest::ReadChannel {
4061                            handle: req.handle,
4062
4063                            responder: FDomainReadChannelResponder {
4064                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4065                                tx_id: header.tx_id,
4066                            },
4067                        })
4068                    }
4069                    0x75a2559b945d5eb5 => {
4070                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4071                        let mut req = fidl::new_empty!(
4072                            ChannelWriteChannelRequest,
4073                            fidl::encoding::DefaultFuchsiaResourceDialect
4074                        );
4075                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChannelWriteChannelRequest>(&header, _body_bytes, handles, &mut req)?;
4076                        let control_handle = FDomainControlHandle { inner: this.inner.clone() };
4077                        Ok(FDomainRequest::WriteChannel {
4078                            handle: req.handle,
4079                            data: req.data,
4080                            handles: req.handles,
4081
4082                            responder: FDomainWriteChannelResponder {
4083                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4084                                tx_id: header.tx_id,
4085                            },
4086                        })
4087                    }
4088                    0x3c73e85476a203df => {
4089                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4090                        let mut req = fidl::new_empty!(
4091                            ChannelReadChannelStreamingStartRequest,
4092                            fidl::encoding::DefaultFuchsiaResourceDialect
4093                        );
4094                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChannelReadChannelStreamingStartRequest>(&header, _body_bytes, handles, &mut req)?;
4095                        let control_handle = FDomainControlHandle { inner: this.inner.clone() };
4096                        Ok(FDomainRequest::ReadChannelStreamingStart {
4097                            handle: req.handle,
4098
4099                            responder: FDomainReadChannelStreamingStartResponder {
4100                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4101                                tx_id: header.tx_id,
4102                            },
4103                        })
4104                    }
4105                    0x56f21d6ed68186e0 => {
4106                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4107                        let mut req = fidl::new_empty!(
4108                            ChannelReadChannelStreamingStopRequest,
4109                            fidl::encoding::DefaultFuchsiaResourceDialect
4110                        );
4111                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChannelReadChannelStreamingStopRequest>(&header, _body_bytes, handles, &mut req)?;
4112                        let control_handle = FDomainControlHandle { inner: this.inner.clone() };
4113                        Ok(FDomainRequest::ReadChannelStreamingStop {
4114                            handle: req.handle,
4115
4116                            responder: FDomainReadChannelStreamingStopResponder {
4117                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4118                                tx_id: header.tx_id,
4119                            },
4120                        })
4121                    }
4122                    0x7b05b3f262635987 => {
4123                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4124                        let mut req = fidl::new_empty!(
4125                            EventCreateEventRequest,
4126                            fidl::encoding::DefaultFuchsiaResourceDialect
4127                        );
4128                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<EventCreateEventRequest>(&header, _body_bytes, handles, &mut req)?;
4129                        let control_handle = FDomainControlHandle { inner: this.inner.clone() };
4130                        Ok(FDomainRequest::CreateEvent {
4131                            handle: req.handle,
4132
4133                            responder: FDomainCreateEventResponder {
4134                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4135                                tx_id: header.tx_id,
4136                            },
4137                        })
4138                    }
4139                    0x7aef61effa65656d => {
4140                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4141                        let mut req = fidl::new_empty!(
4142                            EventPairCreateEventPairRequest,
4143                            fidl::encoding::DefaultFuchsiaResourceDialect
4144                        );
4145                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<EventPairCreateEventPairRequest>(&header, _body_bytes, handles, &mut req)?;
4146                        let control_handle = FDomainControlHandle { inner: this.inner.clone() };
4147                        Ok(FDomainRequest::CreateEventPair {
4148                            handles: req.handles,
4149
4150                            responder: FDomainCreateEventPairResponder {
4151                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4152                                tx_id: header.tx_id,
4153                            },
4154                        })
4155                    }
4156                    0x200bf0ea21932de0 => {
4157                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4158                        let mut req = fidl::new_empty!(
4159                            SocketCreateSocketRequest,
4160                            fidl::encoding::DefaultFuchsiaResourceDialect
4161                        );
4162                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SocketCreateSocketRequest>(&header, _body_bytes, handles, &mut req)?;
4163                        let control_handle = FDomainControlHandle { inner: this.inner.clone() };
4164                        Ok(FDomainRequest::CreateSocket {
4165                            options: req.options,
4166                            handles: req.handles,
4167
4168                            responder: FDomainCreateSocketResponder {
4169                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4170                                tx_id: header.tx_id,
4171                            },
4172                        })
4173                    }
4174                    0x60d3c7ccb17f9bdf => {
4175                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4176                        let mut req = fidl::new_empty!(
4177                            SocketSetSocketDispositionRequest,
4178                            fidl::encoding::DefaultFuchsiaResourceDialect
4179                        );
4180                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SocketSetSocketDispositionRequest>(&header, _body_bytes, handles, &mut req)?;
4181                        let control_handle = FDomainControlHandle { inner: this.inner.clone() };
4182                        Ok(FDomainRequest::SetSocketDisposition {
4183                            handle: req.handle,
4184                            disposition: req.disposition,
4185                            disposition_peer: req.disposition_peer,
4186
4187                            responder: FDomainSetSocketDispositionResponder {
4188                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4189                                tx_id: header.tx_id,
4190                            },
4191                        })
4192                    }
4193                    0x1da8aabec249c02e => {
4194                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4195                        let mut req = fidl::new_empty!(
4196                            SocketReadSocketRequest,
4197                            fidl::encoding::DefaultFuchsiaResourceDialect
4198                        );
4199                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SocketReadSocketRequest>(&header, _body_bytes, handles, &mut req)?;
4200                        let control_handle = FDomainControlHandle { inner: this.inner.clone() };
4201                        Ok(FDomainRequest::ReadSocket {
4202                            handle: req.handle,
4203                            max_bytes: req.max_bytes,
4204
4205                            responder: FDomainReadSocketResponder {
4206                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4207                                tx_id: header.tx_id,
4208                            },
4209                        })
4210                    }
4211                    0x5b541623cbbbf683 => {
4212                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4213                        let mut req = fidl::new_empty!(
4214                            SocketWriteSocketRequest,
4215                            fidl::encoding::DefaultFuchsiaResourceDialect
4216                        );
4217                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SocketWriteSocketRequest>(&header, _body_bytes, handles, &mut req)?;
4218                        let control_handle = FDomainControlHandle { inner: this.inner.clone() };
4219                        Ok(FDomainRequest::WriteSocket {
4220                            handle: req.handle,
4221                            data: req.data,
4222
4223                            responder: FDomainWriteSocketResponder {
4224                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4225                                tx_id: header.tx_id,
4226                            },
4227                        })
4228                    }
4229                    0x2a592748d5f33445 => {
4230                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4231                        let mut req = fidl::new_empty!(
4232                            SocketReadSocketStreamingStartRequest,
4233                            fidl::encoding::DefaultFuchsiaResourceDialect
4234                        );
4235                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SocketReadSocketStreamingStartRequest>(&header, _body_bytes, handles, &mut req)?;
4236                        let control_handle = FDomainControlHandle { inner: this.inner.clone() };
4237                        Ok(FDomainRequest::ReadSocketStreamingStart {
4238                            handle: req.handle,
4239
4240                            responder: FDomainReadSocketStreamingStartResponder {
4241                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4242                                tx_id: header.tx_id,
4243                            },
4244                        })
4245                    }
4246                    0x53e5cade5f4d22e7 => {
4247                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4248                        let mut req = fidl::new_empty!(
4249                            SocketReadSocketStreamingStopRequest,
4250                            fidl::encoding::DefaultFuchsiaResourceDialect
4251                        );
4252                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SocketReadSocketStreamingStopRequest>(&header, _body_bytes, handles, &mut req)?;
4253                        let control_handle = FDomainControlHandle { inner: this.inner.clone() };
4254                        Ok(FDomainRequest::ReadSocketStreamingStop {
4255                            handle: req.handle,
4256
4257                            responder: FDomainReadSocketStreamingStopResponder {
4258                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4259                                tx_id: header.tx_id,
4260                            },
4261                        })
4262                    }
4263                    0x74f2e74d9f53e11e => {
4264                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4265                        let mut req = fidl::new_empty!(
4266                            FDomainGetNamespaceRequest,
4267                            fidl::encoding::DefaultFuchsiaResourceDialect
4268                        );
4269                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FDomainGetNamespaceRequest>(&header, _body_bytes, handles, &mut req)?;
4270                        let control_handle = FDomainControlHandle { inner: this.inner.clone() };
4271                        Ok(FDomainRequest::GetNamespace {
4272                            new_handle: req.new_handle,
4273
4274                            responder: FDomainGetNamespaceResponder {
4275                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4276                                tx_id: header.tx_id,
4277                            },
4278                        })
4279                    }
4280                    0x5ef8c24362964257 => {
4281                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4282                        let mut req = fidl::new_empty!(
4283                            FDomainCloseRequest,
4284                            fidl::encoding::DefaultFuchsiaResourceDialect
4285                        );
4286                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FDomainCloseRequest>(&header, _body_bytes, handles, &mut req)?;
4287                        let control_handle = FDomainControlHandle { inner: this.inner.clone() };
4288                        Ok(FDomainRequest::Close {
4289                            handles: req.handles,
4290
4291                            responder: FDomainCloseResponder {
4292                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4293                                tx_id: header.tx_id,
4294                            },
4295                        })
4296                    }
4297                    0x7a85b94bd1777ab9 => {
4298                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4299                        let mut req = fidl::new_empty!(
4300                            FDomainDuplicateRequest,
4301                            fidl::encoding::DefaultFuchsiaResourceDialect
4302                        );
4303                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FDomainDuplicateRequest>(&header, _body_bytes, handles, &mut req)?;
4304                        let control_handle = FDomainControlHandle { inner: this.inner.clone() };
4305                        Ok(FDomainRequest::Duplicate {
4306                            handle: req.handle,
4307                            new_handle: req.new_handle,
4308                            rights: req.rights,
4309
4310                            responder: FDomainDuplicateResponder {
4311                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4312                                tx_id: header.tx_id,
4313                            },
4314                        })
4315                    }
4316                    0x32fa64625a5bd3be => {
4317                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4318                        let mut req = fidl::new_empty!(
4319                            FDomainReplaceRequest,
4320                            fidl::encoding::DefaultFuchsiaResourceDialect
4321                        );
4322                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FDomainReplaceRequest>(&header, _body_bytes, handles, &mut req)?;
4323                        let control_handle = FDomainControlHandle { inner: this.inner.clone() };
4324                        Ok(FDomainRequest::Replace {
4325                            handle: req.handle,
4326                            new_handle: req.new_handle,
4327                            rights: req.rights,
4328
4329                            responder: FDomainReplaceResponder {
4330                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4331                                tx_id: header.tx_id,
4332                            },
4333                        })
4334                    }
4335                    0xe8352fb978996d9 => {
4336                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4337                        let mut req = fidl::new_empty!(
4338                            FDomainSignalRequest,
4339                            fidl::encoding::DefaultFuchsiaResourceDialect
4340                        );
4341                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FDomainSignalRequest>(&header, _body_bytes, handles, &mut req)?;
4342                        let control_handle = FDomainControlHandle { inner: this.inner.clone() };
4343                        Ok(FDomainRequest::Signal {
4344                            handle: req.handle,
4345                            set: req.set,
4346                            clear: req.clear,
4347
4348                            responder: FDomainSignalResponder {
4349                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4350                                tx_id: header.tx_id,
4351                            },
4352                        })
4353                    }
4354                    0x7e84ec8ca7eabaf8 => {
4355                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4356                        let mut req = fidl::new_empty!(
4357                            FDomainSignalPeerRequest,
4358                            fidl::encoding::DefaultFuchsiaResourceDialect
4359                        );
4360                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FDomainSignalPeerRequest>(&header, _body_bytes, handles, &mut req)?;
4361                        let control_handle = FDomainControlHandle { inner: this.inner.clone() };
4362                        Ok(FDomainRequest::SignalPeer {
4363                            handle: req.handle,
4364                            set: req.set,
4365                            clear: req.clear,
4366
4367                            responder: FDomainSignalPeerResponder {
4368                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4369                                tx_id: header.tx_id,
4370                            },
4371                        })
4372                    }
4373                    0x8f72d9b4b85c1eb => {
4374                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4375                        let mut req = fidl::new_empty!(
4376                            FDomainWaitForSignalsRequest,
4377                            fidl::encoding::DefaultFuchsiaResourceDialect
4378                        );
4379                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FDomainWaitForSignalsRequest>(&header, _body_bytes, handles, &mut req)?;
4380                        let control_handle = FDomainControlHandle { inner: this.inner.clone() };
4381                        Ok(FDomainRequest::WaitForSignals {
4382                            handle: req.handle,
4383                            signals: req.signals,
4384
4385                            responder: FDomainWaitForSignalsResponder {
4386                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4387                                tx_id: header.tx_id,
4388                            },
4389                        })
4390                    }
4391                    0x437db979a63402c3 => {
4392                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4393                        let mut req = fidl::new_empty!(
4394                            FDomainGetKoidRequest,
4395                            fidl::encoding::DefaultFuchsiaResourceDialect
4396                        );
4397                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FDomainGetKoidRequest>(&header, _body_bytes, handles, &mut req)?;
4398                        let control_handle = FDomainControlHandle { inner: this.inner.clone() };
4399                        Ok(FDomainRequest::GetKoid {
4400                            handle: req.handle,
4401
4402                            responder: FDomainGetKoidResponder {
4403                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4404                                tx_id: header.tx_id,
4405                            },
4406                        })
4407                    }
4408                    _ if header.tx_id == 0
4409                        && header
4410                            .dynamic_flags()
4411                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
4412                    {
4413                        Ok(FDomainRequest::_UnknownMethod {
4414                            ordinal: header.ordinal,
4415                            control_handle: FDomainControlHandle { inner: this.inner.clone() },
4416                            method_type: fidl::MethodType::OneWay,
4417                        })
4418                    }
4419                    _ if header
4420                        .dynamic_flags()
4421                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
4422                    {
4423                        this.inner.send_framework_err(
4424                            fidl::encoding::FrameworkErr::UnknownMethod,
4425                            header.tx_id,
4426                            header.ordinal,
4427                            header.dynamic_flags(),
4428                            (bytes, handles),
4429                        )?;
4430                        Ok(FDomainRequest::_UnknownMethod {
4431                            ordinal: header.ordinal,
4432                            control_handle: FDomainControlHandle { inner: this.inner.clone() },
4433                            method_type: fidl::MethodType::TwoWay,
4434                        })
4435                    }
4436                    _ => Err(fidl::Error::UnknownOrdinal {
4437                        ordinal: header.ordinal,
4438                        protocol_name:
4439                            <FDomainMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4440                    }),
4441                }))
4442            },
4443        )
4444    }
4445}
4446
4447/// The FDomain control protocol.
4448///
4449/// This protocol is designed to be used over a network or other non-channel
4450/// transport.
4451#[derive(Debug)]
4452pub enum FDomainRequest {
4453    /// Create a new channel in this FDomain and return both its ends.
4454    CreateChannel { handles: [NewHandleId; 2], responder: FDomainCreateChannelResponder },
4455    /// Read a message from a channel. This method will fail if the channel is currently being read
4456    /// using the streaming read functions.
4457    ///
4458    /// Note that this method is not like zx_channel_read in that it will not
4459    /// return `SHOULD_WAIT` but will instead delay returning until there is data
4460    /// to return.
4461    ReadChannel { handle: HandleId, responder: FDomainReadChannelResponder },
4462    /// Write to a channel. Handles are always consumed.
4463    WriteChannel {
4464        handle: HandleId,
4465        data: Vec<u8>,
4466        handles: Handles,
4467        responder: FDomainWriteChannelResponder,
4468    },
4469    /// Starts reading from the given channel. Data is returned via the `ChannelStreamingData` event.
4470    /// That event will occur repeatedly until `ReadChannelStreamingStop` is called for the same handle
4471    /// or the event indicates the handle is closed.
4472    ReadChannelStreamingStart {
4473        handle: HandleId,
4474        responder: FDomainReadChannelStreamingStartResponder,
4475    },
4476    /// Stop asynchronous reading from the given channel.
4477    ReadChannelStreamingStop {
4478        handle: HandleId,
4479        responder: FDomainReadChannelStreamingStopResponder,
4480    },
4481    /// Create a new event in this FDomain and return it.
4482    CreateEvent { handle: NewHandleId, responder: FDomainCreateEventResponder },
4483    /// Create a new event pair in this FDomain and return both its ends.
4484    CreateEventPair { handles: [NewHandleId; 2], responder: FDomainCreateEventPairResponder },
4485    /// Create a new socket in this FDomain and return both its ends.
4486    CreateSocket {
4487        options: SocketType,
4488        handles: [NewHandleId; 2],
4489        responder: FDomainCreateSocketResponder,
4490    },
4491    /// Set the disposition of a given socket.
4492    SetSocketDisposition {
4493        handle: HandleId,
4494        disposition: SocketDisposition,
4495        disposition_peer: SocketDisposition,
4496        responder: FDomainSetSocketDispositionResponder,
4497    },
4498    /// Read data from a socket. This method will fail if the socket is currently being read
4499    /// asynchronously.
4500    ReadSocket { handle: HandleId, max_bytes: u64, responder: FDomainReadSocketResponder },
4501    /// Write to a socket. This will attempt to write all the data passed, and
4502    /// will block and retry whenever it is safe (e.g. it should never return
4503    /// SHOULD_WAIT). The `WriteSocketError` contains a `wrote` parameter to
4504    /// indicate if some bytes were written successfully before the failure
4505    /// occurred.
4506    WriteSocket { handle: HandleId, data: Vec<u8>, responder: FDomainWriteSocketResponder },
4507    /// Starts reading from the given socket. Data is returned via the `SocketStreamingData` event. That
4508    /// event will occur repeatedly until `ReadSocketStreamingStop` is called for the same handle or the
4509    /// event indicates the handle is closed.
4510    ReadSocketStreamingStart {
4511        handle: HandleId,
4512        responder: FDomainReadSocketStreamingStartResponder,
4513    },
4514    /// Stop asynchronous reading from the given socket.
4515    ReadSocketStreamingStop { handle: HandleId, responder: FDomainReadSocketStreamingStopResponder },
4516    /// Adds a new channel handle to this namespace which points to a
4517    /// fuchsia.io.Directory. Can be used to "bootstrap" the FDomain.
4518    GetNamespace { new_handle: NewHandleId, responder: FDomainGetNamespaceResponder },
4519    /// Close one or more handles.
4520    Close { handles: Vec<HandleId>, responder: FDomainCloseResponder },
4521    /// Duplicate a handle.
4522    Duplicate {
4523        handle: HandleId,
4524        new_handle: NewHandleId,
4525        rights: fidl::Rights,
4526        responder: FDomainDuplicateResponder,
4527    },
4528    /// Close a handle and replace it with a new one with possibly different
4529    /// rights.
4530    Replace {
4531        handle: HandleId,
4532        new_handle: NewHandleId,
4533        rights: fidl::Rights,
4534        responder: FDomainReplaceResponder,
4535    },
4536    /// Set or clear signals on a handle.
4537    Signal { handle: HandleId, set: u32, clear: u32, responder: FDomainSignalResponder },
4538    /// Set or clear signals on a handle's peer.
4539    SignalPeer { handle: HandleId, set: u32, clear: u32, responder: FDomainSignalPeerResponder },
4540    /// Wait for signals from the given handle. Reply will be returned when one
4541    /// of the given signals is asserted.
4542    WaitForSignals { handle: HandleId, signals: u32, responder: FDomainWaitForSignalsResponder },
4543    /// Return the kernel object ID (koid) of the handle.
4544    GetKoid { handle: HandleId, responder: FDomainGetKoidResponder },
4545    /// An interaction was received which does not match any known method.
4546    #[non_exhaustive]
4547    _UnknownMethod {
4548        /// Ordinal of the method that was called.
4549        ordinal: u64,
4550        control_handle: FDomainControlHandle,
4551        method_type: fidl::MethodType,
4552    },
4553}
4554
4555impl FDomainRequest {
4556    #[allow(irrefutable_let_patterns)]
4557    pub fn into_create_channel(self) -> Option<([NewHandleId; 2], FDomainCreateChannelResponder)> {
4558        if let FDomainRequest::CreateChannel { handles, responder } = self {
4559            Some((handles, responder))
4560        } else {
4561            None
4562        }
4563    }
4564
4565    #[allow(irrefutable_let_patterns)]
4566    pub fn into_read_channel(self) -> Option<(HandleId, FDomainReadChannelResponder)> {
4567        if let FDomainRequest::ReadChannel { handle, responder } = self {
4568            Some((handle, responder))
4569        } else {
4570            None
4571        }
4572    }
4573
4574    #[allow(irrefutable_let_patterns)]
4575    pub fn into_write_channel(
4576        self,
4577    ) -> Option<(HandleId, Vec<u8>, Handles, FDomainWriteChannelResponder)> {
4578        if let FDomainRequest::WriteChannel { handle, data, handles, responder } = self {
4579            Some((handle, data, handles, responder))
4580        } else {
4581            None
4582        }
4583    }
4584
4585    #[allow(irrefutable_let_patterns)]
4586    pub fn into_read_channel_streaming_start(
4587        self,
4588    ) -> Option<(HandleId, FDomainReadChannelStreamingStartResponder)> {
4589        if let FDomainRequest::ReadChannelStreamingStart { handle, responder } = self {
4590            Some((handle, responder))
4591        } else {
4592            None
4593        }
4594    }
4595
4596    #[allow(irrefutable_let_patterns)]
4597    pub fn into_read_channel_streaming_stop(
4598        self,
4599    ) -> Option<(HandleId, FDomainReadChannelStreamingStopResponder)> {
4600        if let FDomainRequest::ReadChannelStreamingStop { handle, responder } = self {
4601            Some((handle, responder))
4602        } else {
4603            None
4604        }
4605    }
4606
4607    #[allow(irrefutable_let_patterns)]
4608    pub fn into_create_event(self) -> Option<(NewHandleId, FDomainCreateEventResponder)> {
4609        if let FDomainRequest::CreateEvent { handle, responder } = self {
4610            Some((handle, responder))
4611        } else {
4612            None
4613        }
4614    }
4615
4616    #[allow(irrefutable_let_patterns)]
4617    pub fn into_create_event_pair(
4618        self,
4619    ) -> Option<([NewHandleId; 2], FDomainCreateEventPairResponder)> {
4620        if let FDomainRequest::CreateEventPair { handles, responder } = self {
4621            Some((handles, responder))
4622        } else {
4623            None
4624        }
4625    }
4626
4627    #[allow(irrefutable_let_patterns)]
4628    pub fn into_create_socket(
4629        self,
4630    ) -> Option<(SocketType, [NewHandleId; 2], FDomainCreateSocketResponder)> {
4631        if let FDomainRequest::CreateSocket { options, handles, responder } = self {
4632            Some((options, handles, responder))
4633        } else {
4634            None
4635        }
4636    }
4637
4638    #[allow(irrefutable_let_patterns)]
4639    pub fn into_set_socket_disposition(
4640        self,
4641    ) -> Option<(
4642        HandleId,
4643        SocketDisposition,
4644        SocketDisposition,
4645        FDomainSetSocketDispositionResponder,
4646    )> {
4647        if let FDomainRequest::SetSocketDisposition {
4648            handle,
4649            disposition,
4650            disposition_peer,
4651            responder,
4652        } = self
4653        {
4654            Some((handle, disposition, disposition_peer, responder))
4655        } else {
4656            None
4657        }
4658    }
4659
4660    #[allow(irrefutable_let_patterns)]
4661    pub fn into_read_socket(self) -> Option<(HandleId, u64, FDomainReadSocketResponder)> {
4662        if let FDomainRequest::ReadSocket { handle, max_bytes, responder } = self {
4663            Some((handle, max_bytes, responder))
4664        } else {
4665            None
4666        }
4667    }
4668
4669    #[allow(irrefutable_let_patterns)]
4670    pub fn into_write_socket(self) -> Option<(HandleId, Vec<u8>, FDomainWriteSocketResponder)> {
4671        if let FDomainRequest::WriteSocket { handle, data, responder } = self {
4672            Some((handle, data, responder))
4673        } else {
4674            None
4675        }
4676    }
4677
4678    #[allow(irrefutable_let_patterns)]
4679    pub fn into_read_socket_streaming_start(
4680        self,
4681    ) -> Option<(HandleId, FDomainReadSocketStreamingStartResponder)> {
4682        if let FDomainRequest::ReadSocketStreamingStart { handle, responder } = self {
4683            Some((handle, responder))
4684        } else {
4685            None
4686        }
4687    }
4688
4689    #[allow(irrefutable_let_patterns)]
4690    pub fn into_read_socket_streaming_stop(
4691        self,
4692    ) -> Option<(HandleId, FDomainReadSocketStreamingStopResponder)> {
4693        if let FDomainRequest::ReadSocketStreamingStop { handle, responder } = self {
4694            Some((handle, responder))
4695        } else {
4696            None
4697        }
4698    }
4699
4700    #[allow(irrefutable_let_patterns)]
4701    pub fn into_get_namespace(self) -> Option<(NewHandleId, FDomainGetNamespaceResponder)> {
4702        if let FDomainRequest::GetNamespace { new_handle, responder } = self {
4703            Some((new_handle, responder))
4704        } else {
4705            None
4706        }
4707    }
4708
4709    #[allow(irrefutable_let_patterns)]
4710    pub fn into_close(self) -> Option<(Vec<HandleId>, FDomainCloseResponder)> {
4711        if let FDomainRequest::Close { handles, responder } = self {
4712            Some((handles, responder))
4713        } else {
4714            None
4715        }
4716    }
4717
4718    #[allow(irrefutable_let_patterns)]
4719    pub fn into_duplicate(
4720        self,
4721    ) -> Option<(HandleId, NewHandleId, fidl::Rights, FDomainDuplicateResponder)> {
4722        if let FDomainRequest::Duplicate { handle, new_handle, rights, responder } = self {
4723            Some((handle, new_handle, rights, responder))
4724        } else {
4725            None
4726        }
4727    }
4728
4729    #[allow(irrefutable_let_patterns)]
4730    pub fn into_replace(
4731        self,
4732    ) -> Option<(HandleId, NewHandleId, fidl::Rights, FDomainReplaceResponder)> {
4733        if let FDomainRequest::Replace { handle, new_handle, rights, responder } = self {
4734            Some((handle, new_handle, rights, responder))
4735        } else {
4736            None
4737        }
4738    }
4739
4740    #[allow(irrefutable_let_patterns)]
4741    pub fn into_signal(self) -> Option<(HandleId, u32, u32, FDomainSignalResponder)> {
4742        if let FDomainRequest::Signal { handle, set, clear, responder } = self {
4743            Some((handle, set, clear, responder))
4744        } else {
4745            None
4746        }
4747    }
4748
4749    #[allow(irrefutable_let_patterns)]
4750    pub fn into_signal_peer(self) -> Option<(HandleId, u32, u32, FDomainSignalPeerResponder)> {
4751        if let FDomainRequest::SignalPeer { handle, set, clear, responder } = self {
4752            Some((handle, set, clear, responder))
4753        } else {
4754            None
4755        }
4756    }
4757
4758    #[allow(irrefutable_let_patterns)]
4759    pub fn into_wait_for_signals(self) -> Option<(HandleId, u32, FDomainWaitForSignalsResponder)> {
4760        if let FDomainRequest::WaitForSignals { handle, signals, responder } = self {
4761            Some((handle, signals, responder))
4762        } else {
4763            None
4764        }
4765    }
4766
4767    #[allow(irrefutable_let_patterns)]
4768    pub fn into_get_koid(self) -> Option<(HandleId, FDomainGetKoidResponder)> {
4769        if let FDomainRequest::GetKoid { handle, responder } = self {
4770            Some((handle, responder))
4771        } else {
4772            None
4773        }
4774    }
4775
4776    /// Name of the method defined in FIDL
4777    pub fn method_name(&self) -> &'static str {
4778        match *self {
4779            FDomainRequest::CreateChannel { .. } => "create_channel",
4780            FDomainRequest::ReadChannel { .. } => "read_channel",
4781            FDomainRequest::WriteChannel { .. } => "write_channel",
4782            FDomainRequest::ReadChannelStreamingStart { .. } => "read_channel_streaming_start",
4783            FDomainRequest::ReadChannelStreamingStop { .. } => "read_channel_streaming_stop",
4784            FDomainRequest::CreateEvent { .. } => "create_event",
4785            FDomainRequest::CreateEventPair { .. } => "create_event_pair",
4786            FDomainRequest::CreateSocket { .. } => "create_socket",
4787            FDomainRequest::SetSocketDisposition { .. } => "set_socket_disposition",
4788            FDomainRequest::ReadSocket { .. } => "read_socket",
4789            FDomainRequest::WriteSocket { .. } => "write_socket",
4790            FDomainRequest::ReadSocketStreamingStart { .. } => "read_socket_streaming_start",
4791            FDomainRequest::ReadSocketStreamingStop { .. } => "read_socket_streaming_stop",
4792            FDomainRequest::GetNamespace { .. } => "get_namespace",
4793            FDomainRequest::Close { .. } => "close",
4794            FDomainRequest::Duplicate { .. } => "duplicate",
4795            FDomainRequest::Replace { .. } => "replace",
4796            FDomainRequest::Signal { .. } => "signal",
4797            FDomainRequest::SignalPeer { .. } => "signal_peer",
4798            FDomainRequest::WaitForSignals { .. } => "wait_for_signals",
4799            FDomainRequest::GetKoid { .. } => "get_koid",
4800            FDomainRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
4801                "unknown one-way method"
4802            }
4803            FDomainRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
4804                "unknown two-way method"
4805            }
4806        }
4807    }
4808}
4809
4810#[derive(Debug, Clone)]
4811pub struct FDomainControlHandle {
4812    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4813}
4814
4815impl FDomainControlHandle {
4816    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
4817        self.inner.shutdown_with_epitaph(status.into())
4818    }
4819}
4820
4821impl fidl::endpoints::ControlHandle for FDomainControlHandle {
4822    fn shutdown(&self) {
4823        self.inner.shutdown()
4824    }
4825
4826    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
4827        self.inner.shutdown_with_epitaph(status)
4828    }
4829
4830    fn is_closed(&self) -> bool {
4831        self.inner.channel().is_closed()
4832    }
4833    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4834        self.inner.channel().on_closed()
4835    }
4836
4837    #[cfg(target_os = "fuchsia")]
4838    fn signal_peer(
4839        &self,
4840        clear_mask: zx::Signals,
4841        set_mask: zx::Signals,
4842    ) -> Result<(), zx_status::Status> {
4843        use fidl::Peered;
4844        self.inner.channel().signal_peer(clear_mask, set_mask)
4845    }
4846}
4847
4848impl FDomainControlHandle {
4849    pub fn send_on_channel_streaming_data(
4850        &self,
4851        mut handle: &HandleId,
4852        mut channel_sent: &ChannelSent,
4853    ) -> Result<(), fidl::Error> {
4854        self.inner.send::<ChannelOnChannelStreamingDataRequest>(
4855            (handle, channel_sent),
4856            0,
4857            0x7d4431805202dfe1,
4858            fidl::encoding::DynamicFlags::FLEXIBLE,
4859        )
4860    }
4861
4862    pub fn send_on_socket_streaming_data(
4863        &self,
4864        mut handle: &HandleId,
4865        mut socket_message: &SocketMessage,
4866    ) -> Result<(), fidl::Error> {
4867        self.inner.send::<SocketOnSocketStreamingDataRequest>(
4868            (handle, socket_message),
4869            0,
4870            0x998b5e66b3c80a2,
4871            fidl::encoding::DynamicFlags::FLEXIBLE,
4872        )
4873    }
4874}
4875
4876#[must_use = "FIDL methods require a response to be sent"]
4877#[derive(Debug)]
4878pub struct FDomainCreateChannelResponder {
4879    control_handle: std::mem::ManuallyDrop<FDomainControlHandle>,
4880    tx_id: u32,
4881}
4882
4883/// Set the the channel to be shutdown (see [`FDomainControlHandle::shutdown`])
4884/// if the responder is dropped without sending a response, so that the client
4885/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4886impl std::ops::Drop for FDomainCreateChannelResponder {
4887    fn drop(&mut self) {
4888        self.control_handle.shutdown();
4889        // Safety: drops once, never accessed again
4890        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4891    }
4892}
4893
4894impl fidl::endpoints::Responder for FDomainCreateChannelResponder {
4895    type ControlHandle = FDomainControlHandle;
4896
4897    fn control_handle(&self) -> &FDomainControlHandle {
4898        &self.control_handle
4899    }
4900
4901    fn drop_without_shutdown(mut self) {
4902        // Safety: drops once, never accessed again due to mem::forget
4903        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4904        // Prevent Drop from running (which would shut down the channel)
4905        std::mem::forget(self);
4906    }
4907}
4908
4909impl FDomainCreateChannelResponder {
4910    /// Sends a response to the FIDL transaction.
4911    ///
4912    /// Sets the channel to shutdown if an error occurs.
4913    pub fn send(self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
4914        let _result = self.send_raw(result);
4915        if _result.is_err() {
4916            self.control_handle.shutdown();
4917        }
4918        self.drop_without_shutdown();
4919        _result
4920    }
4921
4922    /// Similar to "send" but does not shutdown the channel if an error occurs.
4923    pub fn send_no_shutdown_on_err(
4924        self,
4925        mut result: Result<(), &Error>,
4926    ) -> Result<(), fidl::Error> {
4927        let _result = self.send_raw(result);
4928        self.drop_without_shutdown();
4929        _result
4930    }
4931
4932    fn send_raw(&self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
4933        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
4934            fidl::encoding::EmptyStruct,
4935            Error,
4936        >>(
4937            fidl::encoding::FlexibleResult::new(result),
4938            self.tx_id,
4939            0x182d38bfe88673b5,
4940            fidl::encoding::DynamicFlags::FLEXIBLE,
4941        )
4942    }
4943}
4944
4945#[must_use = "FIDL methods require a response to be sent"]
4946#[derive(Debug)]
4947pub struct FDomainReadChannelResponder {
4948    control_handle: std::mem::ManuallyDrop<FDomainControlHandle>,
4949    tx_id: u32,
4950}
4951
4952/// Set the the channel to be shutdown (see [`FDomainControlHandle::shutdown`])
4953/// if the responder is dropped without sending a response, so that the client
4954/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4955impl std::ops::Drop for FDomainReadChannelResponder {
4956    fn drop(&mut self) {
4957        self.control_handle.shutdown();
4958        // Safety: drops once, never accessed again
4959        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4960    }
4961}
4962
4963impl fidl::endpoints::Responder for FDomainReadChannelResponder {
4964    type ControlHandle = FDomainControlHandle;
4965
4966    fn control_handle(&self) -> &FDomainControlHandle {
4967        &self.control_handle
4968    }
4969
4970    fn drop_without_shutdown(mut self) {
4971        // Safety: drops once, never accessed again due to mem::forget
4972        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4973        // Prevent Drop from running (which would shut down the channel)
4974        std::mem::forget(self);
4975    }
4976}
4977
4978impl FDomainReadChannelResponder {
4979    /// Sends a response to the FIDL transaction.
4980    ///
4981    /// Sets the channel to shutdown if an error occurs.
4982    pub fn send(
4983        self,
4984        mut result: Result<(&[u8], &[HandleInfo]), &Error>,
4985    ) -> Result<(), fidl::Error> {
4986        let _result = self.send_raw(result);
4987        if _result.is_err() {
4988            self.control_handle.shutdown();
4989        }
4990        self.drop_without_shutdown();
4991        _result
4992    }
4993
4994    /// Similar to "send" but does not shutdown the channel if an error occurs.
4995    pub fn send_no_shutdown_on_err(
4996        self,
4997        mut result: Result<(&[u8], &[HandleInfo]), &Error>,
4998    ) -> Result<(), fidl::Error> {
4999        let _result = self.send_raw(result);
5000        self.drop_without_shutdown();
5001        _result
5002    }
5003
5004    fn send_raw(
5005        &self,
5006        mut result: Result<(&[u8], &[HandleInfo]), &Error>,
5007    ) -> Result<(), fidl::Error> {
5008        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<ChannelMessage, Error>>(
5009            fidl::encoding::FlexibleResult::new(result),
5010            self.tx_id,
5011            0x6ef47bf27bf7d050,
5012            fidl::encoding::DynamicFlags::FLEXIBLE,
5013        )
5014    }
5015}
5016
5017#[must_use = "FIDL methods require a response to be sent"]
5018#[derive(Debug)]
5019pub struct FDomainWriteChannelResponder {
5020    control_handle: std::mem::ManuallyDrop<FDomainControlHandle>,
5021    tx_id: u32,
5022}
5023
5024/// Set the the channel to be shutdown (see [`FDomainControlHandle::shutdown`])
5025/// if the responder is dropped without sending a response, so that the client
5026/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5027impl std::ops::Drop for FDomainWriteChannelResponder {
5028    fn drop(&mut self) {
5029        self.control_handle.shutdown();
5030        // Safety: drops once, never accessed again
5031        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5032    }
5033}
5034
5035impl fidl::endpoints::Responder for FDomainWriteChannelResponder {
5036    type ControlHandle = FDomainControlHandle;
5037
5038    fn control_handle(&self) -> &FDomainControlHandle {
5039        &self.control_handle
5040    }
5041
5042    fn drop_without_shutdown(mut self) {
5043        // Safety: drops once, never accessed again due to mem::forget
5044        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5045        // Prevent Drop from running (which would shut down the channel)
5046        std::mem::forget(self);
5047    }
5048}
5049
5050impl FDomainWriteChannelResponder {
5051    /// Sends a response to the FIDL transaction.
5052    ///
5053    /// Sets the channel to shutdown if an error occurs.
5054    pub fn send(self, mut result: Result<(), &WriteChannelError>) -> Result<(), fidl::Error> {
5055        let _result = self.send_raw(result);
5056        if _result.is_err() {
5057            self.control_handle.shutdown();
5058        }
5059        self.drop_without_shutdown();
5060        _result
5061    }
5062
5063    /// Similar to "send" but does not shutdown the channel if an error occurs.
5064    pub fn send_no_shutdown_on_err(
5065        self,
5066        mut result: Result<(), &WriteChannelError>,
5067    ) -> Result<(), fidl::Error> {
5068        let _result = self.send_raw(result);
5069        self.drop_without_shutdown();
5070        _result
5071    }
5072
5073    fn send_raw(&self, mut result: Result<(), &WriteChannelError>) -> Result<(), fidl::Error> {
5074        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
5075            fidl::encoding::EmptyStruct,
5076            WriteChannelError,
5077        >>(
5078            fidl::encoding::FlexibleResult::new(result),
5079            self.tx_id,
5080            0x75a2559b945d5eb5,
5081            fidl::encoding::DynamicFlags::FLEXIBLE,
5082        )
5083    }
5084}
5085
5086#[must_use = "FIDL methods require a response to be sent"]
5087#[derive(Debug)]
5088pub struct FDomainReadChannelStreamingStartResponder {
5089    control_handle: std::mem::ManuallyDrop<FDomainControlHandle>,
5090    tx_id: u32,
5091}
5092
5093/// Set the the channel to be shutdown (see [`FDomainControlHandle::shutdown`])
5094/// if the responder is dropped without sending a response, so that the client
5095/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5096impl std::ops::Drop for FDomainReadChannelStreamingStartResponder {
5097    fn drop(&mut self) {
5098        self.control_handle.shutdown();
5099        // Safety: drops once, never accessed again
5100        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5101    }
5102}
5103
5104impl fidl::endpoints::Responder for FDomainReadChannelStreamingStartResponder {
5105    type ControlHandle = FDomainControlHandle;
5106
5107    fn control_handle(&self) -> &FDomainControlHandle {
5108        &self.control_handle
5109    }
5110
5111    fn drop_without_shutdown(mut self) {
5112        // Safety: drops once, never accessed again due to mem::forget
5113        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5114        // Prevent Drop from running (which would shut down the channel)
5115        std::mem::forget(self);
5116    }
5117}
5118
5119impl FDomainReadChannelStreamingStartResponder {
5120    /// Sends a response to the FIDL transaction.
5121    ///
5122    /// Sets the channel to shutdown if an error occurs.
5123    pub fn send(self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
5124        let _result = self.send_raw(result);
5125        if _result.is_err() {
5126            self.control_handle.shutdown();
5127        }
5128        self.drop_without_shutdown();
5129        _result
5130    }
5131
5132    /// Similar to "send" but does not shutdown the channel if an error occurs.
5133    pub fn send_no_shutdown_on_err(
5134        self,
5135        mut result: Result<(), &Error>,
5136    ) -> Result<(), fidl::Error> {
5137        let _result = self.send_raw(result);
5138        self.drop_without_shutdown();
5139        _result
5140    }
5141
5142    fn send_raw(&self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
5143        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
5144            fidl::encoding::EmptyStruct,
5145            Error,
5146        >>(
5147            fidl::encoding::FlexibleResult::new(result),
5148            self.tx_id,
5149            0x3c73e85476a203df,
5150            fidl::encoding::DynamicFlags::FLEXIBLE,
5151        )
5152    }
5153}
5154
5155#[must_use = "FIDL methods require a response to be sent"]
5156#[derive(Debug)]
5157pub struct FDomainReadChannelStreamingStopResponder {
5158    control_handle: std::mem::ManuallyDrop<FDomainControlHandle>,
5159    tx_id: u32,
5160}
5161
5162/// Set the the channel to be shutdown (see [`FDomainControlHandle::shutdown`])
5163/// if the responder is dropped without sending a response, so that the client
5164/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5165impl std::ops::Drop for FDomainReadChannelStreamingStopResponder {
5166    fn drop(&mut self) {
5167        self.control_handle.shutdown();
5168        // Safety: drops once, never accessed again
5169        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5170    }
5171}
5172
5173impl fidl::endpoints::Responder for FDomainReadChannelStreamingStopResponder {
5174    type ControlHandle = FDomainControlHandle;
5175
5176    fn control_handle(&self) -> &FDomainControlHandle {
5177        &self.control_handle
5178    }
5179
5180    fn drop_without_shutdown(mut self) {
5181        // Safety: drops once, never accessed again due to mem::forget
5182        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5183        // Prevent Drop from running (which would shut down the channel)
5184        std::mem::forget(self);
5185    }
5186}
5187
5188impl FDomainReadChannelStreamingStopResponder {
5189    /// Sends a response to the FIDL transaction.
5190    ///
5191    /// Sets the channel to shutdown if an error occurs.
5192    pub fn send(self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
5193        let _result = self.send_raw(result);
5194        if _result.is_err() {
5195            self.control_handle.shutdown();
5196        }
5197        self.drop_without_shutdown();
5198        _result
5199    }
5200
5201    /// Similar to "send" but does not shutdown the channel if an error occurs.
5202    pub fn send_no_shutdown_on_err(
5203        self,
5204        mut result: Result<(), &Error>,
5205    ) -> Result<(), fidl::Error> {
5206        let _result = self.send_raw(result);
5207        self.drop_without_shutdown();
5208        _result
5209    }
5210
5211    fn send_raw(&self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
5212        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
5213            fidl::encoding::EmptyStruct,
5214            Error,
5215        >>(
5216            fidl::encoding::FlexibleResult::new(result),
5217            self.tx_id,
5218            0x56f21d6ed68186e0,
5219            fidl::encoding::DynamicFlags::FLEXIBLE,
5220        )
5221    }
5222}
5223
5224#[must_use = "FIDL methods require a response to be sent"]
5225#[derive(Debug)]
5226pub struct FDomainCreateEventResponder {
5227    control_handle: std::mem::ManuallyDrop<FDomainControlHandle>,
5228    tx_id: u32,
5229}
5230
5231/// Set the the channel to be shutdown (see [`FDomainControlHandle::shutdown`])
5232/// if the responder is dropped without sending a response, so that the client
5233/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5234impl std::ops::Drop for FDomainCreateEventResponder {
5235    fn drop(&mut self) {
5236        self.control_handle.shutdown();
5237        // Safety: drops once, never accessed again
5238        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5239    }
5240}
5241
5242impl fidl::endpoints::Responder for FDomainCreateEventResponder {
5243    type ControlHandle = FDomainControlHandle;
5244
5245    fn control_handle(&self) -> &FDomainControlHandle {
5246        &self.control_handle
5247    }
5248
5249    fn drop_without_shutdown(mut self) {
5250        // Safety: drops once, never accessed again due to mem::forget
5251        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5252        // Prevent Drop from running (which would shut down the channel)
5253        std::mem::forget(self);
5254    }
5255}
5256
5257impl FDomainCreateEventResponder {
5258    /// Sends a response to the FIDL transaction.
5259    ///
5260    /// Sets the channel to shutdown if an error occurs.
5261    pub fn send(self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
5262        let _result = self.send_raw(result);
5263        if _result.is_err() {
5264            self.control_handle.shutdown();
5265        }
5266        self.drop_without_shutdown();
5267        _result
5268    }
5269
5270    /// Similar to "send" but does not shutdown the channel if an error occurs.
5271    pub fn send_no_shutdown_on_err(
5272        self,
5273        mut result: Result<(), &Error>,
5274    ) -> Result<(), fidl::Error> {
5275        let _result = self.send_raw(result);
5276        self.drop_without_shutdown();
5277        _result
5278    }
5279
5280    fn send_raw(&self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
5281        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
5282            fidl::encoding::EmptyStruct,
5283            Error,
5284        >>(
5285            fidl::encoding::FlexibleResult::new(result),
5286            self.tx_id,
5287            0x7b05b3f262635987,
5288            fidl::encoding::DynamicFlags::FLEXIBLE,
5289        )
5290    }
5291}
5292
5293#[must_use = "FIDL methods require a response to be sent"]
5294#[derive(Debug)]
5295pub struct FDomainCreateEventPairResponder {
5296    control_handle: std::mem::ManuallyDrop<FDomainControlHandle>,
5297    tx_id: u32,
5298}
5299
5300/// Set the the channel to be shutdown (see [`FDomainControlHandle::shutdown`])
5301/// if the responder is dropped without sending a response, so that the client
5302/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5303impl std::ops::Drop for FDomainCreateEventPairResponder {
5304    fn drop(&mut self) {
5305        self.control_handle.shutdown();
5306        // Safety: drops once, never accessed again
5307        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5308    }
5309}
5310
5311impl fidl::endpoints::Responder for FDomainCreateEventPairResponder {
5312    type ControlHandle = FDomainControlHandle;
5313
5314    fn control_handle(&self) -> &FDomainControlHandle {
5315        &self.control_handle
5316    }
5317
5318    fn drop_without_shutdown(mut self) {
5319        // Safety: drops once, never accessed again due to mem::forget
5320        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5321        // Prevent Drop from running (which would shut down the channel)
5322        std::mem::forget(self);
5323    }
5324}
5325
5326impl FDomainCreateEventPairResponder {
5327    /// Sends a response to the FIDL transaction.
5328    ///
5329    /// Sets the channel to shutdown if an error occurs.
5330    pub fn send(self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
5331        let _result = self.send_raw(result);
5332        if _result.is_err() {
5333            self.control_handle.shutdown();
5334        }
5335        self.drop_without_shutdown();
5336        _result
5337    }
5338
5339    /// Similar to "send" but does not shutdown the channel if an error occurs.
5340    pub fn send_no_shutdown_on_err(
5341        self,
5342        mut result: Result<(), &Error>,
5343    ) -> Result<(), fidl::Error> {
5344        let _result = self.send_raw(result);
5345        self.drop_without_shutdown();
5346        _result
5347    }
5348
5349    fn send_raw(&self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
5350        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
5351            fidl::encoding::EmptyStruct,
5352            Error,
5353        >>(
5354            fidl::encoding::FlexibleResult::new(result),
5355            self.tx_id,
5356            0x7aef61effa65656d,
5357            fidl::encoding::DynamicFlags::FLEXIBLE,
5358        )
5359    }
5360}
5361
5362#[must_use = "FIDL methods require a response to be sent"]
5363#[derive(Debug)]
5364pub struct FDomainCreateSocketResponder {
5365    control_handle: std::mem::ManuallyDrop<FDomainControlHandle>,
5366    tx_id: u32,
5367}
5368
5369/// Set the the channel to be shutdown (see [`FDomainControlHandle::shutdown`])
5370/// if the responder is dropped without sending a response, so that the client
5371/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5372impl std::ops::Drop for FDomainCreateSocketResponder {
5373    fn drop(&mut self) {
5374        self.control_handle.shutdown();
5375        // Safety: drops once, never accessed again
5376        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5377    }
5378}
5379
5380impl fidl::endpoints::Responder for FDomainCreateSocketResponder {
5381    type ControlHandle = FDomainControlHandle;
5382
5383    fn control_handle(&self) -> &FDomainControlHandle {
5384        &self.control_handle
5385    }
5386
5387    fn drop_without_shutdown(mut self) {
5388        // Safety: drops once, never accessed again due to mem::forget
5389        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5390        // Prevent Drop from running (which would shut down the channel)
5391        std::mem::forget(self);
5392    }
5393}
5394
5395impl FDomainCreateSocketResponder {
5396    /// Sends a response to the FIDL transaction.
5397    ///
5398    /// Sets the channel to shutdown if an error occurs.
5399    pub fn send(self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
5400        let _result = self.send_raw(result);
5401        if _result.is_err() {
5402            self.control_handle.shutdown();
5403        }
5404        self.drop_without_shutdown();
5405        _result
5406    }
5407
5408    /// Similar to "send" but does not shutdown the channel if an error occurs.
5409    pub fn send_no_shutdown_on_err(
5410        self,
5411        mut result: Result<(), &Error>,
5412    ) -> Result<(), fidl::Error> {
5413        let _result = self.send_raw(result);
5414        self.drop_without_shutdown();
5415        _result
5416    }
5417
5418    fn send_raw(&self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
5419        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
5420            fidl::encoding::EmptyStruct,
5421            Error,
5422        >>(
5423            fidl::encoding::FlexibleResult::new(result),
5424            self.tx_id,
5425            0x200bf0ea21932de0,
5426            fidl::encoding::DynamicFlags::FLEXIBLE,
5427        )
5428    }
5429}
5430
5431#[must_use = "FIDL methods require a response to be sent"]
5432#[derive(Debug)]
5433pub struct FDomainSetSocketDispositionResponder {
5434    control_handle: std::mem::ManuallyDrop<FDomainControlHandle>,
5435    tx_id: u32,
5436}
5437
5438/// Set the the channel to be shutdown (see [`FDomainControlHandle::shutdown`])
5439/// if the responder is dropped without sending a response, so that the client
5440/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5441impl std::ops::Drop for FDomainSetSocketDispositionResponder {
5442    fn drop(&mut self) {
5443        self.control_handle.shutdown();
5444        // Safety: drops once, never accessed again
5445        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5446    }
5447}
5448
5449impl fidl::endpoints::Responder for FDomainSetSocketDispositionResponder {
5450    type ControlHandle = FDomainControlHandle;
5451
5452    fn control_handle(&self) -> &FDomainControlHandle {
5453        &self.control_handle
5454    }
5455
5456    fn drop_without_shutdown(mut self) {
5457        // Safety: drops once, never accessed again due to mem::forget
5458        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5459        // Prevent Drop from running (which would shut down the channel)
5460        std::mem::forget(self);
5461    }
5462}
5463
5464impl FDomainSetSocketDispositionResponder {
5465    /// Sends a response to the FIDL transaction.
5466    ///
5467    /// Sets the channel to shutdown if an error occurs.
5468    pub fn send(self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
5469        let _result = self.send_raw(result);
5470        if _result.is_err() {
5471            self.control_handle.shutdown();
5472        }
5473        self.drop_without_shutdown();
5474        _result
5475    }
5476
5477    /// Similar to "send" but does not shutdown the channel if an error occurs.
5478    pub fn send_no_shutdown_on_err(
5479        self,
5480        mut result: Result<(), &Error>,
5481    ) -> Result<(), fidl::Error> {
5482        let _result = self.send_raw(result);
5483        self.drop_without_shutdown();
5484        _result
5485    }
5486
5487    fn send_raw(&self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
5488        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
5489            fidl::encoding::EmptyStruct,
5490            Error,
5491        >>(
5492            fidl::encoding::FlexibleResult::new(result),
5493            self.tx_id,
5494            0x60d3c7ccb17f9bdf,
5495            fidl::encoding::DynamicFlags::FLEXIBLE,
5496        )
5497    }
5498}
5499
5500#[must_use = "FIDL methods require a response to be sent"]
5501#[derive(Debug)]
5502pub struct FDomainReadSocketResponder {
5503    control_handle: std::mem::ManuallyDrop<FDomainControlHandle>,
5504    tx_id: u32,
5505}
5506
5507/// Set the the channel to be shutdown (see [`FDomainControlHandle::shutdown`])
5508/// if the responder is dropped without sending a response, so that the client
5509/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5510impl std::ops::Drop for FDomainReadSocketResponder {
5511    fn drop(&mut self) {
5512        self.control_handle.shutdown();
5513        // Safety: drops once, never accessed again
5514        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5515    }
5516}
5517
5518impl fidl::endpoints::Responder for FDomainReadSocketResponder {
5519    type ControlHandle = FDomainControlHandle;
5520
5521    fn control_handle(&self) -> &FDomainControlHandle {
5522        &self.control_handle
5523    }
5524
5525    fn drop_without_shutdown(mut self) {
5526        // Safety: drops once, never accessed again due to mem::forget
5527        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5528        // Prevent Drop from running (which would shut down the channel)
5529        std::mem::forget(self);
5530    }
5531}
5532
5533impl FDomainReadSocketResponder {
5534    /// Sends a response to the FIDL transaction.
5535    ///
5536    /// Sets the channel to shutdown if an error occurs.
5537    pub fn send(self, mut result: Result<(&[u8], bool), &Error>) -> Result<(), fidl::Error> {
5538        let _result = self.send_raw(result);
5539        if _result.is_err() {
5540            self.control_handle.shutdown();
5541        }
5542        self.drop_without_shutdown();
5543        _result
5544    }
5545
5546    /// Similar to "send" but does not shutdown the channel if an error occurs.
5547    pub fn send_no_shutdown_on_err(
5548        self,
5549        mut result: Result<(&[u8], bool), &Error>,
5550    ) -> Result<(), fidl::Error> {
5551        let _result = self.send_raw(result);
5552        self.drop_without_shutdown();
5553        _result
5554    }
5555
5556    fn send_raw(&self, mut result: Result<(&[u8], bool), &Error>) -> Result<(), fidl::Error> {
5557        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<SocketData, Error>>(
5558            fidl::encoding::FlexibleResult::new(result),
5559            self.tx_id,
5560            0x1da8aabec249c02e,
5561            fidl::encoding::DynamicFlags::FLEXIBLE,
5562        )
5563    }
5564}
5565
5566#[must_use = "FIDL methods require a response to be sent"]
5567#[derive(Debug)]
5568pub struct FDomainWriteSocketResponder {
5569    control_handle: std::mem::ManuallyDrop<FDomainControlHandle>,
5570    tx_id: u32,
5571}
5572
5573/// Set the the channel to be shutdown (see [`FDomainControlHandle::shutdown`])
5574/// if the responder is dropped without sending a response, so that the client
5575/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5576impl std::ops::Drop for FDomainWriteSocketResponder {
5577    fn drop(&mut self) {
5578        self.control_handle.shutdown();
5579        // Safety: drops once, never accessed again
5580        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5581    }
5582}
5583
5584impl fidl::endpoints::Responder for FDomainWriteSocketResponder {
5585    type ControlHandle = FDomainControlHandle;
5586
5587    fn control_handle(&self) -> &FDomainControlHandle {
5588        &self.control_handle
5589    }
5590
5591    fn drop_without_shutdown(mut self) {
5592        // Safety: drops once, never accessed again due to mem::forget
5593        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5594        // Prevent Drop from running (which would shut down the channel)
5595        std::mem::forget(self);
5596    }
5597}
5598
5599impl FDomainWriteSocketResponder {
5600    /// Sends a response to the FIDL transaction.
5601    ///
5602    /// Sets the channel to shutdown if an error occurs.
5603    pub fn send(self, mut result: Result<u64, &WriteSocketError>) -> Result<(), fidl::Error> {
5604        let _result = self.send_raw(result);
5605        if _result.is_err() {
5606            self.control_handle.shutdown();
5607        }
5608        self.drop_without_shutdown();
5609        _result
5610    }
5611
5612    /// Similar to "send" but does not shutdown the channel if an error occurs.
5613    pub fn send_no_shutdown_on_err(
5614        self,
5615        mut result: Result<u64, &WriteSocketError>,
5616    ) -> Result<(), fidl::Error> {
5617        let _result = self.send_raw(result);
5618        self.drop_without_shutdown();
5619        _result
5620    }
5621
5622    fn send_raw(&self, mut result: Result<u64, &WriteSocketError>) -> Result<(), fidl::Error> {
5623        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
5624            SocketWriteSocketResponse,
5625            WriteSocketError,
5626        >>(
5627            fidl::encoding::FlexibleResult::new(result.map(|wrote| (wrote,))),
5628            self.tx_id,
5629            0x5b541623cbbbf683,
5630            fidl::encoding::DynamicFlags::FLEXIBLE,
5631        )
5632    }
5633}
5634
5635#[must_use = "FIDL methods require a response to be sent"]
5636#[derive(Debug)]
5637pub struct FDomainReadSocketStreamingStartResponder {
5638    control_handle: std::mem::ManuallyDrop<FDomainControlHandle>,
5639    tx_id: u32,
5640}
5641
5642/// Set the the channel to be shutdown (see [`FDomainControlHandle::shutdown`])
5643/// if the responder is dropped without sending a response, so that the client
5644/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5645impl std::ops::Drop for FDomainReadSocketStreamingStartResponder {
5646    fn drop(&mut self) {
5647        self.control_handle.shutdown();
5648        // Safety: drops once, never accessed again
5649        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5650    }
5651}
5652
5653impl fidl::endpoints::Responder for FDomainReadSocketStreamingStartResponder {
5654    type ControlHandle = FDomainControlHandle;
5655
5656    fn control_handle(&self) -> &FDomainControlHandle {
5657        &self.control_handle
5658    }
5659
5660    fn drop_without_shutdown(mut self) {
5661        // Safety: drops once, never accessed again due to mem::forget
5662        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5663        // Prevent Drop from running (which would shut down the channel)
5664        std::mem::forget(self);
5665    }
5666}
5667
5668impl FDomainReadSocketStreamingStartResponder {
5669    /// Sends a response to the FIDL transaction.
5670    ///
5671    /// Sets the channel to shutdown if an error occurs.
5672    pub fn send(self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
5673        let _result = self.send_raw(result);
5674        if _result.is_err() {
5675            self.control_handle.shutdown();
5676        }
5677        self.drop_without_shutdown();
5678        _result
5679    }
5680
5681    /// Similar to "send" but does not shutdown the channel if an error occurs.
5682    pub fn send_no_shutdown_on_err(
5683        self,
5684        mut result: Result<(), &Error>,
5685    ) -> Result<(), fidl::Error> {
5686        let _result = self.send_raw(result);
5687        self.drop_without_shutdown();
5688        _result
5689    }
5690
5691    fn send_raw(&self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
5692        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
5693            fidl::encoding::EmptyStruct,
5694            Error,
5695        >>(
5696            fidl::encoding::FlexibleResult::new(result),
5697            self.tx_id,
5698            0x2a592748d5f33445,
5699            fidl::encoding::DynamicFlags::FLEXIBLE,
5700        )
5701    }
5702}
5703
5704#[must_use = "FIDL methods require a response to be sent"]
5705#[derive(Debug)]
5706pub struct FDomainReadSocketStreamingStopResponder {
5707    control_handle: std::mem::ManuallyDrop<FDomainControlHandle>,
5708    tx_id: u32,
5709}
5710
5711/// Set the the channel to be shutdown (see [`FDomainControlHandle::shutdown`])
5712/// if the responder is dropped without sending a response, so that the client
5713/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5714impl std::ops::Drop for FDomainReadSocketStreamingStopResponder {
5715    fn drop(&mut self) {
5716        self.control_handle.shutdown();
5717        // Safety: drops once, never accessed again
5718        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5719    }
5720}
5721
5722impl fidl::endpoints::Responder for FDomainReadSocketStreamingStopResponder {
5723    type ControlHandle = FDomainControlHandle;
5724
5725    fn control_handle(&self) -> &FDomainControlHandle {
5726        &self.control_handle
5727    }
5728
5729    fn drop_without_shutdown(mut self) {
5730        // Safety: drops once, never accessed again due to mem::forget
5731        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5732        // Prevent Drop from running (which would shut down the channel)
5733        std::mem::forget(self);
5734    }
5735}
5736
5737impl FDomainReadSocketStreamingStopResponder {
5738    /// Sends a response to the FIDL transaction.
5739    ///
5740    /// Sets the channel to shutdown if an error occurs.
5741    pub fn send(self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
5742        let _result = self.send_raw(result);
5743        if _result.is_err() {
5744            self.control_handle.shutdown();
5745        }
5746        self.drop_without_shutdown();
5747        _result
5748    }
5749
5750    /// Similar to "send" but does not shutdown the channel if an error occurs.
5751    pub fn send_no_shutdown_on_err(
5752        self,
5753        mut result: Result<(), &Error>,
5754    ) -> Result<(), fidl::Error> {
5755        let _result = self.send_raw(result);
5756        self.drop_without_shutdown();
5757        _result
5758    }
5759
5760    fn send_raw(&self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
5761        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
5762            fidl::encoding::EmptyStruct,
5763            Error,
5764        >>(
5765            fidl::encoding::FlexibleResult::new(result),
5766            self.tx_id,
5767            0x53e5cade5f4d22e7,
5768            fidl::encoding::DynamicFlags::FLEXIBLE,
5769        )
5770    }
5771}
5772
5773#[must_use = "FIDL methods require a response to be sent"]
5774#[derive(Debug)]
5775pub struct FDomainGetNamespaceResponder {
5776    control_handle: std::mem::ManuallyDrop<FDomainControlHandle>,
5777    tx_id: u32,
5778}
5779
5780/// Set the the channel to be shutdown (see [`FDomainControlHandle::shutdown`])
5781/// if the responder is dropped without sending a response, so that the client
5782/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5783impl std::ops::Drop for FDomainGetNamespaceResponder {
5784    fn drop(&mut self) {
5785        self.control_handle.shutdown();
5786        // Safety: drops once, never accessed again
5787        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5788    }
5789}
5790
5791impl fidl::endpoints::Responder for FDomainGetNamespaceResponder {
5792    type ControlHandle = FDomainControlHandle;
5793
5794    fn control_handle(&self) -> &FDomainControlHandle {
5795        &self.control_handle
5796    }
5797
5798    fn drop_without_shutdown(mut self) {
5799        // Safety: drops once, never accessed again due to mem::forget
5800        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5801        // Prevent Drop from running (which would shut down the channel)
5802        std::mem::forget(self);
5803    }
5804}
5805
5806impl FDomainGetNamespaceResponder {
5807    /// Sends a response to the FIDL transaction.
5808    ///
5809    /// Sets the channel to shutdown if an error occurs.
5810    pub fn send(self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
5811        let _result = self.send_raw(result);
5812        if _result.is_err() {
5813            self.control_handle.shutdown();
5814        }
5815        self.drop_without_shutdown();
5816        _result
5817    }
5818
5819    /// Similar to "send" but does not shutdown the channel if an error occurs.
5820    pub fn send_no_shutdown_on_err(
5821        self,
5822        mut result: Result<(), &Error>,
5823    ) -> Result<(), fidl::Error> {
5824        let _result = self.send_raw(result);
5825        self.drop_without_shutdown();
5826        _result
5827    }
5828
5829    fn send_raw(&self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
5830        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
5831            fidl::encoding::EmptyStruct,
5832            Error,
5833        >>(
5834            fidl::encoding::FlexibleResult::new(result),
5835            self.tx_id,
5836            0x74f2e74d9f53e11e,
5837            fidl::encoding::DynamicFlags::FLEXIBLE,
5838        )
5839    }
5840}
5841
5842#[must_use = "FIDL methods require a response to be sent"]
5843#[derive(Debug)]
5844pub struct FDomainCloseResponder {
5845    control_handle: std::mem::ManuallyDrop<FDomainControlHandle>,
5846    tx_id: u32,
5847}
5848
5849/// Set the the channel to be shutdown (see [`FDomainControlHandle::shutdown`])
5850/// if the responder is dropped without sending a response, so that the client
5851/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5852impl std::ops::Drop for FDomainCloseResponder {
5853    fn drop(&mut self) {
5854        self.control_handle.shutdown();
5855        // Safety: drops once, never accessed again
5856        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5857    }
5858}
5859
5860impl fidl::endpoints::Responder for FDomainCloseResponder {
5861    type ControlHandle = FDomainControlHandle;
5862
5863    fn control_handle(&self) -> &FDomainControlHandle {
5864        &self.control_handle
5865    }
5866
5867    fn drop_without_shutdown(mut self) {
5868        // Safety: drops once, never accessed again due to mem::forget
5869        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5870        // Prevent Drop from running (which would shut down the channel)
5871        std::mem::forget(self);
5872    }
5873}
5874
5875impl FDomainCloseResponder {
5876    /// Sends a response to the FIDL transaction.
5877    ///
5878    /// Sets the channel to shutdown if an error occurs.
5879    pub fn send(self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
5880        let _result = self.send_raw(result);
5881        if _result.is_err() {
5882            self.control_handle.shutdown();
5883        }
5884        self.drop_without_shutdown();
5885        _result
5886    }
5887
5888    /// Similar to "send" but does not shutdown the channel if an error occurs.
5889    pub fn send_no_shutdown_on_err(
5890        self,
5891        mut result: Result<(), &Error>,
5892    ) -> Result<(), fidl::Error> {
5893        let _result = self.send_raw(result);
5894        self.drop_without_shutdown();
5895        _result
5896    }
5897
5898    fn send_raw(&self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
5899        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
5900            fidl::encoding::EmptyStruct,
5901            Error,
5902        >>(
5903            fidl::encoding::FlexibleResult::new(result),
5904            self.tx_id,
5905            0x5ef8c24362964257,
5906            fidl::encoding::DynamicFlags::FLEXIBLE,
5907        )
5908    }
5909}
5910
5911#[must_use = "FIDL methods require a response to be sent"]
5912#[derive(Debug)]
5913pub struct FDomainDuplicateResponder {
5914    control_handle: std::mem::ManuallyDrop<FDomainControlHandle>,
5915    tx_id: u32,
5916}
5917
5918/// Set the the channel to be shutdown (see [`FDomainControlHandle::shutdown`])
5919/// if the responder is dropped without sending a response, so that the client
5920/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5921impl std::ops::Drop for FDomainDuplicateResponder {
5922    fn drop(&mut self) {
5923        self.control_handle.shutdown();
5924        // Safety: drops once, never accessed again
5925        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5926    }
5927}
5928
5929impl fidl::endpoints::Responder for FDomainDuplicateResponder {
5930    type ControlHandle = FDomainControlHandle;
5931
5932    fn control_handle(&self) -> &FDomainControlHandle {
5933        &self.control_handle
5934    }
5935
5936    fn drop_without_shutdown(mut self) {
5937        // Safety: drops once, never accessed again due to mem::forget
5938        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5939        // Prevent Drop from running (which would shut down the channel)
5940        std::mem::forget(self);
5941    }
5942}
5943
5944impl FDomainDuplicateResponder {
5945    /// Sends a response to the FIDL transaction.
5946    ///
5947    /// Sets the channel to shutdown if an error occurs.
5948    pub fn send(self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
5949        let _result = self.send_raw(result);
5950        if _result.is_err() {
5951            self.control_handle.shutdown();
5952        }
5953        self.drop_without_shutdown();
5954        _result
5955    }
5956
5957    /// Similar to "send" but does not shutdown the channel if an error occurs.
5958    pub fn send_no_shutdown_on_err(
5959        self,
5960        mut result: Result<(), &Error>,
5961    ) -> Result<(), fidl::Error> {
5962        let _result = self.send_raw(result);
5963        self.drop_without_shutdown();
5964        _result
5965    }
5966
5967    fn send_raw(&self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
5968        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
5969            fidl::encoding::EmptyStruct,
5970            Error,
5971        >>(
5972            fidl::encoding::FlexibleResult::new(result),
5973            self.tx_id,
5974            0x7a85b94bd1777ab9,
5975            fidl::encoding::DynamicFlags::FLEXIBLE,
5976        )
5977    }
5978}
5979
5980#[must_use = "FIDL methods require a response to be sent"]
5981#[derive(Debug)]
5982pub struct FDomainReplaceResponder {
5983    control_handle: std::mem::ManuallyDrop<FDomainControlHandle>,
5984    tx_id: u32,
5985}
5986
5987/// Set the the channel to be shutdown (see [`FDomainControlHandle::shutdown`])
5988/// if the responder is dropped without sending a response, so that the client
5989/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5990impl std::ops::Drop for FDomainReplaceResponder {
5991    fn drop(&mut self) {
5992        self.control_handle.shutdown();
5993        // Safety: drops once, never accessed again
5994        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5995    }
5996}
5997
5998impl fidl::endpoints::Responder for FDomainReplaceResponder {
5999    type ControlHandle = FDomainControlHandle;
6000
6001    fn control_handle(&self) -> &FDomainControlHandle {
6002        &self.control_handle
6003    }
6004
6005    fn drop_without_shutdown(mut self) {
6006        // Safety: drops once, never accessed again due to mem::forget
6007        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6008        // Prevent Drop from running (which would shut down the channel)
6009        std::mem::forget(self);
6010    }
6011}
6012
6013impl FDomainReplaceResponder {
6014    /// Sends a response to the FIDL transaction.
6015    ///
6016    /// Sets the channel to shutdown if an error occurs.
6017    pub fn send(self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
6018        let _result = self.send_raw(result);
6019        if _result.is_err() {
6020            self.control_handle.shutdown();
6021        }
6022        self.drop_without_shutdown();
6023        _result
6024    }
6025
6026    /// Similar to "send" but does not shutdown the channel if an error occurs.
6027    pub fn send_no_shutdown_on_err(
6028        self,
6029        mut result: Result<(), &Error>,
6030    ) -> Result<(), fidl::Error> {
6031        let _result = self.send_raw(result);
6032        self.drop_without_shutdown();
6033        _result
6034    }
6035
6036    fn send_raw(&self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
6037        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
6038            fidl::encoding::EmptyStruct,
6039            Error,
6040        >>(
6041            fidl::encoding::FlexibleResult::new(result),
6042            self.tx_id,
6043            0x32fa64625a5bd3be,
6044            fidl::encoding::DynamicFlags::FLEXIBLE,
6045        )
6046    }
6047}
6048
6049#[must_use = "FIDL methods require a response to be sent"]
6050#[derive(Debug)]
6051pub struct FDomainSignalResponder {
6052    control_handle: std::mem::ManuallyDrop<FDomainControlHandle>,
6053    tx_id: u32,
6054}
6055
6056/// Set the the channel to be shutdown (see [`FDomainControlHandle::shutdown`])
6057/// if the responder is dropped without sending a response, so that the client
6058/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6059impl std::ops::Drop for FDomainSignalResponder {
6060    fn drop(&mut self) {
6061        self.control_handle.shutdown();
6062        // Safety: drops once, never accessed again
6063        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6064    }
6065}
6066
6067impl fidl::endpoints::Responder for FDomainSignalResponder {
6068    type ControlHandle = FDomainControlHandle;
6069
6070    fn control_handle(&self) -> &FDomainControlHandle {
6071        &self.control_handle
6072    }
6073
6074    fn drop_without_shutdown(mut self) {
6075        // Safety: drops once, never accessed again due to mem::forget
6076        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6077        // Prevent Drop from running (which would shut down the channel)
6078        std::mem::forget(self);
6079    }
6080}
6081
6082impl FDomainSignalResponder {
6083    /// Sends a response to the FIDL transaction.
6084    ///
6085    /// Sets the channel to shutdown if an error occurs.
6086    pub fn send(self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
6087        let _result = self.send_raw(result);
6088        if _result.is_err() {
6089            self.control_handle.shutdown();
6090        }
6091        self.drop_without_shutdown();
6092        _result
6093    }
6094
6095    /// Similar to "send" but does not shutdown the channel if an error occurs.
6096    pub fn send_no_shutdown_on_err(
6097        self,
6098        mut result: Result<(), &Error>,
6099    ) -> Result<(), fidl::Error> {
6100        let _result = self.send_raw(result);
6101        self.drop_without_shutdown();
6102        _result
6103    }
6104
6105    fn send_raw(&self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
6106        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
6107            fidl::encoding::EmptyStruct,
6108            Error,
6109        >>(
6110            fidl::encoding::FlexibleResult::new(result),
6111            self.tx_id,
6112            0xe8352fb978996d9,
6113            fidl::encoding::DynamicFlags::FLEXIBLE,
6114        )
6115    }
6116}
6117
6118#[must_use = "FIDL methods require a response to be sent"]
6119#[derive(Debug)]
6120pub struct FDomainSignalPeerResponder {
6121    control_handle: std::mem::ManuallyDrop<FDomainControlHandle>,
6122    tx_id: u32,
6123}
6124
6125/// Set the the channel to be shutdown (see [`FDomainControlHandle::shutdown`])
6126/// if the responder is dropped without sending a response, so that the client
6127/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6128impl std::ops::Drop for FDomainSignalPeerResponder {
6129    fn drop(&mut self) {
6130        self.control_handle.shutdown();
6131        // Safety: drops once, never accessed again
6132        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6133    }
6134}
6135
6136impl fidl::endpoints::Responder for FDomainSignalPeerResponder {
6137    type ControlHandle = FDomainControlHandle;
6138
6139    fn control_handle(&self) -> &FDomainControlHandle {
6140        &self.control_handle
6141    }
6142
6143    fn drop_without_shutdown(mut self) {
6144        // Safety: drops once, never accessed again due to mem::forget
6145        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6146        // Prevent Drop from running (which would shut down the channel)
6147        std::mem::forget(self);
6148    }
6149}
6150
6151impl FDomainSignalPeerResponder {
6152    /// Sends a response to the FIDL transaction.
6153    ///
6154    /// Sets the channel to shutdown if an error occurs.
6155    pub fn send(self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
6156        let _result = self.send_raw(result);
6157        if _result.is_err() {
6158            self.control_handle.shutdown();
6159        }
6160        self.drop_without_shutdown();
6161        _result
6162    }
6163
6164    /// Similar to "send" but does not shutdown the channel if an error occurs.
6165    pub fn send_no_shutdown_on_err(
6166        self,
6167        mut result: Result<(), &Error>,
6168    ) -> Result<(), fidl::Error> {
6169        let _result = self.send_raw(result);
6170        self.drop_without_shutdown();
6171        _result
6172    }
6173
6174    fn send_raw(&self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
6175        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
6176            fidl::encoding::EmptyStruct,
6177            Error,
6178        >>(
6179            fidl::encoding::FlexibleResult::new(result),
6180            self.tx_id,
6181            0x7e84ec8ca7eabaf8,
6182            fidl::encoding::DynamicFlags::FLEXIBLE,
6183        )
6184    }
6185}
6186
6187#[must_use = "FIDL methods require a response to be sent"]
6188#[derive(Debug)]
6189pub struct FDomainWaitForSignalsResponder {
6190    control_handle: std::mem::ManuallyDrop<FDomainControlHandle>,
6191    tx_id: u32,
6192}
6193
6194/// Set the the channel to be shutdown (see [`FDomainControlHandle::shutdown`])
6195/// if the responder is dropped without sending a response, so that the client
6196/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6197impl std::ops::Drop for FDomainWaitForSignalsResponder {
6198    fn drop(&mut self) {
6199        self.control_handle.shutdown();
6200        // Safety: drops once, never accessed again
6201        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6202    }
6203}
6204
6205impl fidl::endpoints::Responder for FDomainWaitForSignalsResponder {
6206    type ControlHandle = FDomainControlHandle;
6207
6208    fn control_handle(&self) -> &FDomainControlHandle {
6209        &self.control_handle
6210    }
6211
6212    fn drop_without_shutdown(mut self) {
6213        // Safety: drops once, never accessed again due to mem::forget
6214        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6215        // Prevent Drop from running (which would shut down the channel)
6216        std::mem::forget(self);
6217    }
6218}
6219
6220impl FDomainWaitForSignalsResponder {
6221    /// Sends a response to the FIDL transaction.
6222    ///
6223    /// Sets the channel to shutdown if an error occurs.
6224    pub fn send(self, mut result: Result<u32, &Error>) -> Result<(), fidl::Error> {
6225        let _result = self.send_raw(result);
6226        if _result.is_err() {
6227            self.control_handle.shutdown();
6228        }
6229        self.drop_without_shutdown();
6230        _result
6231    }
6232
6233    /// Similar to "send" but does not shutdown the channel if an error occurs.
6234    pub fn send_no_shutdown_on_err(
6235        self,
6236        mut result: Result<u32, &Error>,
6237    ) -> Result<(), fidl::Error> {
6238        let _result = self.send_raw(result);
6239        self.drop_without_shutdown();
6240        _result
6241    }
6242
6243    fn send_raw(&self, mut result: Result<u32, &Error>) -> Result<(), fidl::Error> {
6244        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
6245            FDomainWaitForSignalsResponse,
6246            Error,
6247        >>(
6248            fidl::encoding::FlexibleResult::new(result.map(|signals| (signals,))),
6249            self.tx_id,
6250            0x8f72d9b4b85c1eb,
6251            fidl::encoding::DynamicFlags::FLEXIBLE,
6252        )
6253    }
6254}
6255
6256#[must_use = "FIDL methods require a response to be sent"]
6257#[derive(Debug)]
6258pub struct FDomainGetKoidResponder {
6259    control_handle: std::mem::ManuallyDrop<FDomainControlHandle>,
6260    tx_id: u32,
6261}
6262
6263/// Set the the channel to be shutdown (see [`FDomainControlHandle::shutdown`])
6264/// if the responder is dropped without sending a response, so that the client
6265/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6266impl std::ops::Drop for FDomainGetKoidResponder {
6267    fn drop(&mut self) {
6268        self.control_handle.shutdown();
6269        // Safety: drops once, never accessed again
6270        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6271    }
6272}
6273
6274impl fidl::endpoints::Responder for FDomainGetKoidResponder {
6275    type ControlHandle = FDomainControlHandle;
6276
6277    fn control_handle(&self) -> &FDomainControlHandle {
6278        &self.control_handle
6279    }
6280
6281    fn drop_without_shutdown(mut self) {
6282        // Safety: drops once, never accessed again due to mem::forget
6283        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6284        // Prevent Drop from running (which would shut down the channel)
6285        std::mem::forget(self);
6286    }
6287}
6288
6289impl FDomainGetKoidResponder {
6290    /// Sends a response to the FIDL transaction.
6291    ///
6292    /// Sets the channel to shutdown if an error occurs.
6293    pub fn send(self, mut result: Result<u64, &Error>) -> Result<(), fidl::Error> {
6294        let _result = self.send_raw(result);
6295        if _result.is_err() {
6296            self.control_handle.shutdown();
6297        }
6298        self.drop_without_shutdown();
6299        _result
6300    }
6301
6302    /// Similar to "send" but does not shutdown the channel if an error occurs.
6303    pub fn send_no_shutdown_on_err(
6304        self,
6305        mut result: Result<u64, &Error>,
6306    ) -> Result<(), fidl::Error> {
6307        let _result = self.send_raw(result);
6308        self.drop_without_shutdown();
6309        _result
6310    }
6311
6312    fn send_raw(&self, mut result: Result<u64, &Error>) -> Result<(), fidl::Error> {
6313        self.control_handle
6314            .inner
6315            .send::<fidl::encoding::FlexibleResultType<FDomainGetKoidResponse, Error>>(
6316                fidl::encoding::FlexibleResult::new(result.map(|koid| (koid,))),
6317                self.tx_id,
6318                0x437db979a63402c3,
6319                fidl::encoding::DynamicFlags::FLEXIBLE,
6320            )
6321    }
6322}
6323
6324#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6325pub struct SocketMarker;
6326
6327impl fidl::endpoints::ProtocolMarker for SocketMarker {
6328    type Proxy = SocketProxy;
6329    type RequestStream = SocketRequestStream;
6330    #[cfg(target_os = "fuchsia")]
6331    type SynchronousProxy = SocketSynchronousProxy;
6332
6333    const DEBUG_NAME: &'static str = "(anonymous) Socket";
6334}
6335pub type SocketCreateSocketResult = Result<(), Error>;
6336pub type SocketSetSocketDispositionResult = Result<(), Error>;
6337pub type SocketReadSocketResult = Result<(Vec<u8>, bool), Error>;
6338pub type SocketWriteSocketResult = Result<u64, WriteSocketError>;
6339pub type SocketReadSocketStreamingStartResult = Result<(), Error>;
6340pub type SocketReadSocketStreamingStopResult = Result<(), Error>;
6341
6342pub trait SocketProxyInterface: Send + Sync {
6343    type CreateSocketResponseFut: std::future::Future<Output = Result<SocketCreateSocketResult, fidl::Error>>
6344        + Send;
6345    fn r#create_socket(
6346        &self,
6347        options: SocketType,
6348        handles: &[NewHandleId; 2],
6349    ) -> Self::CreateSocketResponseFut;
6350    type SetSocketDispositionResponseFut: std::future::Future<Output = Result<SocketSetSocketDispositionResult, fidl::Error>>
6351        + Send;
6352    fn r#set_socket_disposition(
6353        &self,
6354        handle: &HandleId,
6355        disposition: SocketDisposition,
6356        disposition_peer: SocketDisposition,
6357    ) -> Self::SetSocketDispositionResponseFut;
6358    type ReadSocketResponseFut: std::future::Future<Output = Result<SocketReadSocketResult, fidl::Error>>
6359        + Send;
6360    fn r#read_socket(&self, handle: &HandleId, max_bytes: u64) -> Self::ReadSocketResponseFut;
6361    type WriteSocketResponseFut: std::future::Future<Output = Result<SocketWriteSocketResult, fidl::Error>>
6362        + Send;
6363    fn r#write_socket(&self, handle: &HandleId, data: &[u8]) -> Self::WriteSocketResponseFut;
6364    type ReadSocketStreamingStartResponseFut: std::future::Future<Output = Result<SocketReadSocketStreamingStartResult, fidl::Error>>
6365        + Send;
6366    fn r#read_socket_streaming_start(
6367        &self,
6368        handle: &HandleId,
6369    ) -> Self::ReadSocketStreamingStartResponseFut;
6370    type ReadSocketStreamingStopResponseFut: std::future::Future<Output = Result<SocketReadSocketStreamingStopResult, fidl::Error>>
6371        + Send;
6372    fn r#read_socket_streaming_stop(
6373        &self,
6374        handle: &HandleId,
6375    ) -> Self::ReadSocketStreamingStopResponseFut;
6376}
6377#[derive(Debug)]
6378#[cfg(target_os = "fuchsia")]
6379pub struct SocketSynchronousProxy {
6380    client: fidl::client::sync::Client,
6381}
6382
6383#[cfg(target_os = "fuchsia")]
6384impl fidl::endpoints::SynchronousProxy for SocketSynchronousProxy {
6385    type Proxy = SocketProxy;
6386    type Protocol = SocketMarker;
6387
6388    fn from_channel(inner: fidl::Channel) -> Self {
6389        Self::new(inner)
6390    }
6391
6392    fn into_channel(self) -> fidl::Channel {
6393        self.client.into_channel()
6394    }
6395
6396    fn as_channel(&self) -> &fidl::Channel {
6397        self.client.as_channel()
6398    }
6399}
6400
6401#[cfg(target_os = "fuchsia")]
6402impl SocketSynchronousProxy {
6403    pub fn new(channel: fidl::Channel) -> Self {
6404        Self { client: fidl::client::sync::Client::new(channel) }
6405    }
6406
6407    pub fn into_channel(self) -> fidl::Channel {
6408        self.client.into_channel()
6409    }
6410
6411    /// Waits until an event arrives and returns it. It is safe for other
6412    /// threads to make concurrent requests while waiting for an event.
6413    pub fn wait_for_event(
6414        &self,
6415        deadline: zx::MonotonicInstant,
6416    ) -> Result<SocketEvent, fidl::Error> {
6417        SocketEvent::decode(self.client.wait_for_event::<SocketMarker>(deadline)?)
6418    }
6419
6420    /// Create a new socket in this FDomain and return both its ends.
6421    pub fn r#create_socket(
6422        &self,
6423        mut options: SocketType,
6424        mut handles: &[NewHandleId; 2],
6425        ___deadline: zx::MonotonicInstant,
6426    ) -> Result<SocketCreateSocketResult, fidl::Error> {
6427        let _response = self.client.send_query::<
6428            SocketCreateSocketRequest,
6429            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
6430            SocketMarker,
6431        >(
6432            (options, handles,),
6433            0x200bf0ea21932de0,
6434            fidl::encoding::DynamicFlags::FLEXIBLE,
6435            ___deadline,
6436        )?
6437        .into_result::<SocketMarker>("create_socket")?;
6438        Ok(_response.map(|x| x))
6439    }
6440
6441    /// Set the disposition of a given socket.
6442    pub fn r#set_socket_disposition(
6443        &self,
6444        mut handle: &HandleId,
6445        mut disposition: SocketDisposition,
6446        mut disposition_peer: SocketDisposition,
6447        ___deadline: zx::MonotonicInstant,
6448    ) -> Result<SocketSetSocketDispositionResult, fidl::Error> {
6449        let _response = self.client.send_query::<
6450            SocketSetSocketDispositionRequest,
6451            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
6452            SocketMarker,
6453        >(
6454            (handle, disposition, disposition_peer,),
6455            0x60d3c7ccb17f9bdf,
6456            fidl::encoding::DynamicFlags::FLEXIBLE,
6457            ___deadline,
6458        )?
6459        .into_result::<SocketMarker>("set_socket_disposition")?;
6460        Ok(_response.map(|x| x))
6461    }
6462
6463    /// Read data from a socket. This method will fail if the socket is currently being read
6464    /// asynchronously.
6465    pub fn r#read_socket(
6466        &self,
6467        mut handle: &HandleId,
6468        mut max_bytes: u64,
6469        ___deadline: zx::MonotonicInstant,
6470    ) -> Result<SocketReadSocketResult, fidl::Error> {
6471        let _response = self.client.send_query::<
6472            SocketReadSocketRequest,
6473            fidl::encoding::FlexibleResultType<SocketData, Error>,
6474            SocketMarker,
6475        >(
6476            (handle, max_bytes,),
6477            0x1da8aabec249c02e,
6478            fidl::encoding::DynamicFlags::FLEXIBLE,
6479            ___deadline,
6480        )?
6481        .into_result::<SocketMarker>("read_socket")?;
6482        Ok(_response.map(|x| (x.data, x.is_datagram)))
6483    }
6484
6485    /// Write to a socket. This will attempt to write all the data passed, and
6486    /// will block and retry whenever it is safe (e.g. it should never return
6487    /// SHOULD_WAIT). The `WriteSocketError` contains a `wrote` parameter to
6488    /// indicate if some bytes were written successfully before the failure
6489    /// occurred.
6490    pub fn r#write_socket(
6491        &self,
6492        mut handle: &HandleId,
6493        mut data: &[u8],
6494        ___deadline: zx::MonotonicInstant,
6495    ) -> Result<SocketWriteSocketResult, fidl::Error> {
6496        let _response = self.client.send_query::<
6497            SocketWriteSocketRequest,
6498            fidl::encoding::FlexibleResultType<SocketWriteSocketResponse, WriteSocketError>,
6499            SocketMarker,
6500        >(
6501            (handle, data,),
6502            0x5b541623cbbbf683,
6503            fidl::encoding::DynamicFlags::FLEXIBLE,
6504            ___deadline,
6505        )?
6506        .into_result::<SocketMarker>("write_socket")?;
6507        Ok(_response.map(|x| x.wrote))
6508    }
6509
6510    /// Starts reading from the given socket. Data is returned via the `SocketStreamingData` event. That
6511    /// event will occur repeatedly until `ReadSocketStreamingStop` is called for the same handle or the
6512    /// event indicates the handle is closed.
6513    pub fn r#read_socket_streaming_start(
6514        &self,
6515        mut handle: &HandleId,
6516        ___deadline: zx::MonotonicInstant,
6517    ) -> Result<SocketReadSocketStreamingStartResult, fidl::Error> {
6518        let _response = self.client.send_query::<
6519            SocketReadSocketStreamingStartRequest,
6520            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
6521            SocketMarker,
6522        >(
6523            (handle,),
6524            0x2a592748d5f33445,
6525            fidl::encoding::DynamicFlags::FLEXIBLE,
6526            ___deadline,
6527        )?
6528        .into_result::<SocketMarker>("read_socket_streaming_start")?;
6529        Ok(_response.map(|x| x))
6530    }
6531
6532    /// Stop asynchronous reading from the given socket.
6533    pub fn r#read_socket_streaming_stop(
6534        &self,
6535        mut handle: &HandleId,
6536        ___deadline: zx::MonotonicInstant,
6537    ) -> Result<SocketReadSocketStreamingStopResult, fidl::Error> {
6538        let _response = self.client.send_query::<
6539            SocketReadSocketStreamingStopRequest,
6540            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
6541            SocketMarker,
6542        >(
6543            (handle,),
6544            0x53e5cade5f4d22e7,
6545            fidl::encoding::DynamicFlags::FLEXIBLE,
6546            ___deadline,
6547        )?
6548        .into_result::<SocketMarker>("read_socket_streaming_stop")?;
6549        Ok(_response.map(|x| x))
6550    }
6551}
6552
6553#[cfg(target_os = "fuchsia")]
6554impl From<SocketSynchronousProxy> for zx::NullableHandle {
6555    fn from(value: SocketSynchronousProxy) -> Self {
6556        value.into_channel().into()
6557    }
6558}
6559
6560#[cfg(target_os = "fuchsia")]
6561impl From<fidl::Channel> for SocketSynchronousProxy {
6562    fn from(value: fidl::Channel) -> Self {
6563        Self::new(value)
6564    }
6565}
6566
6567#[cfg(target_os = "fuchsia")]
6568impl fidl::endpoints::FromClient for SocketSynchronousProxy {
6569    type Protocol = SocketMarker;
6570
6571    fn from_client(value: fidl::endpoints::ClientEnd<SocketMarker>) -> Self {
6572        Self::new(value.into_channel())
6573    }
6574}
6575
6576#[derive(Debug, Clone)]
6577pub struct SocketProxy {
6578    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
6579}
6580
6581impl fidl::endpoints::Proxy for SocketProxy {
6582    type Protocol = SocketMarker;
6583
6584    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
6585        Self::new(inner)
6586    }
6587
6588    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
6589        self.client.into_channel().map_err(|client| Self { client })
6590    }
6591
6592    fn as_channel(&self) -> &::fidl::AsyncChannel {
6593        self.client.as_channel()
6594    }
6595}
6596
6597impl SocketProxy {
6598    /// Create a new Proxy for fuchsia.fdomain/Socket.
6599    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
6600        let protocol_name = <SocketMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6601        Self { client: fidl::client::Client::new(channel, protocol_name) }
6602    }
6603
6604    /// Get a Stream of events from the remote end of the protocol.
6605    ///
6606    /// # Panics
6607    ///
6608    /// Panics if the event stream was already taken.
6609    pub fn take_event_stream(&self) -> SocketEventStream {
6610        SocketEventStream { event_receiver: self.client.take_event_receiver() }
6611    }
6612
6613    /// Create a new socket in this FDomain and return both its ends.
6614    pub fn r#create_socket(
6615        &self,
6616        mut options: SocketType,
6617        mut handles: &[NewHandleId; 2],
6618    ) -> fidl::client::QueryResponseFut<
6619        SocketCreateSocketResult,
6620        fidl::encoding::DefaultFuchsiaResourceDialect,
6621    > {
6622        SocketProxyInterface::r#create_socket(self, options, handles)
6623    }
6624
6625    /// Set the disposition of a given socket.
6626    pub fn r#set_socket_disposition(
6627        &self,
6628        mut handle: &HandleId,
6629        mut disposition: SocketDisposition,
6630        mut disposition_peer: SocketDisposition,
6631    ) -> fidl::client::QueryResponseFut<
6632        SocketSetSocketDispositionResult,
6633        fidl::encoding::DefaultFuchsiaResourceDialect,
6634    > {
6635        SocketProxyInterface::r#set_socket_disposition(self, handle, disposition, disposition_peer)
6636    }
6637
6638    /// Read data from a socket. This method will fail if the socket is currently being read
6639    /// asynchronously.
6640    pub fn r#read_socket(
6641        &self,
6642        mut handle: &HandleId,
6643        mut max_bytes: u64,
6644    ) -> fidl::client::QueryResponseFut<
6645        SocketReadSocketResult,
6646        fidl::encoding::DefaultFuchsiaResourceDialect,
6647    > {
6648        SocketProxyInterface::r#read_socket(self, handle, max_bytes)
6649    }
6650
6651    /// Write to a socket. This will attempt to write all the data passed, and
6652    /// will block and retry whenever it is safe (e.g. it should never return
6653    /// SHOULD_WAIT). The `WriteSocketError` contains a `wrote` parameter to
6654    /// indicate if some bytes were written successfully before the failure
6655    /// occurred.
6656    pub fn r#write_socket(
6657        &self,
6658        mut handle: &HandleId,
6659        mut data: &[u8],
6660    ) -> fidl::client::QueryResponseFut<
6661        SocketWriteSocketResult,
6662        fidl::encoding::DefaultFuchsiaResourceDialect,
6663    > {
6664        SocketProxyInterface::r#write_socket(self, handle, data)
6665    }
6666
6667    /// Starts reading from the given socket. Data is returned via the `SocketStreamingData` event. That
6668    /// event will occur repeatedly until `ReadSocketStreamingStop` is called for the same handle or the
6669    /// event indicates the handle is closed.
6670    pub fn r#read_socket_streaming_start(
6671        &self,
6672        mut handle: &HandleId,
6673    ) -> fidl::client::QueryResponseFut<
6674        SocketReadSocketStreamingStartResult,
6675        fidl::encoding::DefaultFuchsiaResourceDialect,
6676    > {
6677        SocketProxyInterface::r#read_socket_streaming_start(self, handle)
6678    }
6679
6680    /// Stop asynchronous reading from the given socket.
6681    pub fn r#read_socket_streaming_stop(
6682        &self,
6683        mut handle: &HandleId,
6684    ) -> fidl::client::QueryResponseFut<
6685        SocketReadSocketStreamingStopResult,
6686        fidl::encoding::DefaultFuchsiaResourceDialect,
6687    > {
6688        SocketProxyInterface::r#read_socket_streaming_stop(self, handle)
6689    }
6690}
6691
6692impl SocketProxyInterface for SocketProxy {
6693    type CreateSocketResponseFut = fidl::client::QueryResponseFut<
6694        SocketCreateSocketResult,
6695        fidl::encoding::DefaultFuchsiaResourceDialect,
6696    >;
6697    fn r#create_socket(
6698        &self,
6699        mut options: SocketType,
6700        mut handles: &[NewHandleId; 2],
6701    ) -> Self::CreateSocketResponseFut {
6702        fn _decode(
6703            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6704        ) -> Result<SocketCreateSocketResult, fidl::Error> {
6705            let _response = fidl::client::decode_transaction_body::<
6706                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
6707                fidl::encoding::DefaultFuchsiaResourceDialect,
6708                0x200bf0ea21932de0,
6709            >(_buf?)?
6710            .into_result::<SocketMarker>("create_socket")?;
6711            Ok(_response.map(|x| x))
6712        }
6713        self.client.send_query_and_decode::<SocketCreateSocketRequest, SocketCreateSocketResult>(
6714            (options, handles),
6715            0x200bf0ea21932de0,
6716            fidl::encoding::DynamicFlags::FLEXIBLE,
6717            _decode,
6718        )
6719    }
6720
6721    type SetSocketDispositionResponseFut = fidl::client::QueryResponseFut<
6722        SocketSetSocketDispositionResult,
6723        fidl::encoding::DefaultFuchsiaResourceDialect,
6724    >;
6725    fn r#set_socket_disposition(
6726        &self,
6727        mut handle: &HandleId,
6728        mut disposition: SocketDisposition,
6729        mut disposition_peer: SocketDisposition,
6730    ) -> Self::SetSocketDispositionResponseFut {
6731        fn _decode(
6732            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6733        ) -> Result<SocketSetSocketDispositionResult, fidl::Error> {
6734            let _response = fidl::client::decode_transaction_body::<
6735                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
6736                fidl::encoding::DefaultFuchsiaResourceDialect,
6737                0x60d3c7ccb17f9bdf,
6738            >(_buf?)?
6739            .into_result::<SocketMarker>("set_socket_disposition")?;
6740            Ok(_response.map(|x| x))
6741        }
6742        self.client.send_query_and_decode::<
6743            SocketSetSocketDispositionRequest,
6744            SocketSetSocketDispositionResult,
6745        >(
6746            (handle, disposition, disposition_peer,),
6747            0x60d3c7ccb17f9bdf,
6748            fidl::encoding::DynamicFlags::FLEXIBLE,
6749            _decode,
6750        )
6751    }
6752
6753    type ReadSocketResponseFut = fidl::client::QueryResponseFut<
6754        SocketReadSocketResult,
6755        fidl::encoding::DefaultFuchsiaResourceDialect,
6756    >;
6757    fn r#read_socket(
6758        &self,
6759        mut handle: &HandleId,
6760        mut max_bytes: u64,
6761    ) -> Self::ReadSocketResponseFut {
6762        fn _decode(
6763            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6764        ) -> Result<SocketReadSocketResult, fidl::Error> {
6765            let _response = fidl::client::decode_transaction_body::<
6766                fidl::encoding::FlexibleResultType<SocketData, Error>,
6767                fidl::encoding::DefaultFuchsiaResourceDialect,
6768                0x1da8aabec249c02e,
6769            >(_buf?)?
6770            .into_result::<SocketMarker>("read_socket")?;
6771            Ok(_response.map(|x| (x.data, x.is_datagram)))
6772        }
6773        self.client.send_query_and_decode::<SocketReadSocketRequest, SocketReadSocketResult>(
6774            (handle, max_bytes),
6775            0x1da8aabec249c02e,
6776            fidl::encoding::DynamicFlags::FLEXIBLE,
6777            _decode,
6778        )
6779    }
6780
6781    type WriteSocketResponseFut = fidl::client::QueryResponseFut<
6782        SocketWriteSocketResult,
6783        fidl::encoding::DefaultFuchsiaResourceDialect,
6784    >;
6785    fn r#write_socket(
6786        &self,
6787        mut handle: &HandleId,
6788        mut data: &[u8],
6789    ) -> Self::WriteSocketResponseFut {
6790        fn _decode(
6791            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6792        ) -> Result<SocketWriteSocketResult, fidl::Error> {
6793            let _response = fidl::client::decode_transaction_body::<
6794                fidl::encoding::FlexibleResultType<SocketWriteSocketResponse, WriteSocketError>,
6795                fidl::encoding::DefaultFuchsiaResourceDialect,
6796                0x5b541623cbbbf683,
6797            >(_buf?)?
6798            .into_result::<SocketMarker>("write_socket")?;
6799            Ok(_response.map(|x| x.wrote))
6800        }
6801        self.client.send_query_and_decode::<SocketWriteSocketRequest, SocketWriteSocketResult>(
6802            (handle, data),
6803            0x5b541623cbbbf683,
6804            fidl::encoding::DynamicFlags::FLEXIBLE,
6805            _decode,
6806        )
6807    }
6808
6809    type ReadSocketStreamingStartResponseFut = fidl::client::QueryResponseFut<
6810        SocketReadSocketStreamingStartResult,
6811        fidl::encoding::DefaultFuchsiaResourceDialect,
6812    >;
6813    fn r#read_socket_streaming_start(
6814        &self,
6815        mut handle: &HandleId,
6816    ) -> Self::ReadSocketStreamingStartResponseFut {
6817        fn _decode(
6818            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6819        ) -> Result<SocketReadSocketStreamingStartResult, fidl::Error> {
6820            let _response = fidl::client::decode_transaction_body::<
6821                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
6822                fidl::encoding::DefaultFuchsiaResourceDialect,
6823                0x2a592748d5f33445,
6824            >(_buf?)?
6825            .into_result::<SocketMarker>("read_socket_streaming_start")?;
6826            Ok(_response.map(|x| x))
6827        }
6828        self.client.send_query_and_decode::<
6829            SocketReadSocketStreamingStartRequest,
6830            SocketReadSocketStreamingStartResult,
6831        >(
6832            (handle,),
6833            0x2a592748d5f33445,
6834            fidl::encoding::DynamicFlags::FLEXIBLE,
6835            _decode,
6836        )
6837    }
6838
6839    type ReadSocketStreamingStopResponseFut = fidl::client::QueryResponseFut<
6840        SocketReadSocketStreamingStopResult,
6841        fidl::encoding::DefaultFuchsiaResourceDialect,
6842    >;
6843    fn r#read_socket_streaming_stop(
6844        &self,
6845        mut handle: &HandleId,
6846    ) -> Self::ReadSocketStreamingStopResponseFut {
6847        fn _decode(
6848            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6849        ) -> Result<SocketReadSocketStreamingStopResult, fidl::Error> {
6850            let _response = fidl::client::decode_transaction_body::<
6851                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
6852                fidl::encoding::DefaultFuchsiaResourceDialect,
6853                0x53e5cade5f4d22e7,
6854            >(_buf?)?
6855            .into_result::<SocketMarker>("read_socket_streaming_stop")?;
6856            Ok(_response.map(|x| x))
6857        }
6858        self.client.send_query_and_decode::<
6859            SocketReadSocketStreamingStopRequest,
6860            SocketReadSocketStreamingStopResult,
6861        >(
6862            (handle,),
6863            0x53e5cade5f4d22e7,
6864            fidl::encoding::DynamicFlags::FLEXIBLE,
6865            _decode,
6866        )
6867    }
6868}
6869
6870pub struct SocketEventStream {
6871    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
6872}
6873
6874impl std::marker::Unpin for SocketEventStream {}
6875
6876impl futures::stream::FusedStream for SocketEventStream {
6877    fn is_terminated(&self) -> bool {
6878        self.event_receiver.is_terminated()
6879    }
6880}
6881
6882impl futures::Stream for SocketEventStream {
6883    type Item = Result<SocketEvent, fidl::Error>;
6884
6885    fn poll_next(
6886        mut self: std::pin::Pin<&mut Self>,
6887        cx: &mut std::task::Context<'_>,
6888    ) -> std::task::Poll<Option<Self::Item>> {
6889        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
6890            &mut self.event_receiver,
6891            cx
6892        )?) {
6893            Some(buf) => std::task::Poll::Ready(Some(SocketEvent::decode(buf))),
6894            None => std::task::Poll::Ready(None),
6895        }
6896    }
6897}
6898
6899#[derive(Debug)]
6900pub enum SocketEvent {
6901    OnSocketStreamingData {
6902        handle: HandleId,
6903        socket_message: SocketMessage,
6904    },
6905    #[non_exhaustive]
6906    _UnknownEvent {
6907        /// Ordinal of the event that was sent.
6908        ordinal: u64,
6909    },
6910}
6911
6912impl SocketEvent {
6913    #[allow(irrefutable_let_patterns)]
6914    pub fn into_on_socket_streaming_data(self) -> Option<(HandleId, SocketMessage)> {
6915        if let SocketEvent::OnSocketStreamingData { handle, socket_message } = self {
6916            Some((handle, socket_message))
6917        } else {
6918            None
6919        }
6920    }
6921
6922    /// Decodes a message buffer as a [`SocketEvent`].
6923    fn decode(
6924        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
6925    ) -> Result<SocketEvent, fidl::Error> {
6926        let (bytes, _handles) = buf.split_mut();
6927        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6928        debug_assert_eq!(tx_header.tx_id, 0);
6929        match tx_header.ordinal {
6930            0x998b5e66b3c80a2 => {
6931                let mut out = fidl::new_empty!(
6932                    SocketOnSocketStreamingDataRequest,
6933                    fidl::encoding::DefaultFuchsiaResourceDialect
6934                );
6935                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SocketOnSocketStreamingDataRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
6936                Ok((SocketEvent::OnSocketStreamingData {
6937                    handle: out.handle,
6938                    socket_message: out.socket_message,
6939                }))
6940            }
6941            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
6942                Ok(SocketEvent::_UnknownEvent { ordinal: tx_header.ordinal })
6943            }
6944            _ => Err(fidl::Error::UnknownOrdinal {
6945                ordinal: tx_header.ordinal,
6946                protocol_name: <SocketMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6947            }),
6948        }
6949    }
6950}
6951
6952/// A Stream of incoming requests for fuchsia.fdomain/Socket.
6953pub struct SocketRequestStream {
6954    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6955    is_terminated: bool,
6956}
6957
6958impl std::marker::Unpin for SocketRequestStream {}
6959
6960impl futures::stream::FusedStream for SocketRequestStream {
6961    fn is_terminated(&self) -> bool {
6962        self.is_terminated
6963    }
6964}
6965
6966impl fidl::endpoints::RequestStream for SocketRequestStream {
6967    type Protocol = SocketMarker;
6968    type ControlHandle = SocketControlHandle;
6969
6970    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
6971        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
6972    }
6973
6974    fn control_handle(&self) -> Self::ControlHandle {
6975        SocketControlHandle { inner: self.inner.clone() }
6976    }
6977
6978    fn into_inner(
6979        self,
6980    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
6981    {
6982        (self.inner, self.is_terminated)
6983    }
6984
6985    fn from_inner(
6986        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6987        is_terminated: bool,
6988    ) -> Self {
6989        Self { inner, is_terminated }
6990    }
6991}
6992
6993impl futures::Stream for SocketRequestStream {
6994    type Item = Result<SocketRequest, fidl::Error>;
6995
6996    fn poll_next(
6997        mut self: std::pin::Pin<&mut Self>,
6998        cx: &mut std::task::Context<'_>,
6999    ) -> std::task::Poll<Option<Self::Item>> {
7000        let this = &mut *self;
7001        if this.inner.check_shutdown(cx) {
7002            this.is_terminated = true;
7003            return std::task::Poll::Ready(None);
7004        }
7005        if this.is_terminated {
7006            panic!("polled SocketRequestStream after completion");
7007        }
7008        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
7009            |bytes, handles| {
7010                match this.inner.channel().read_etc(cx, bytes, handles) {
7011                    std::task::Poll::Ready(Ok(())) => {}
7012                    std::task::Poll::Pending => return std::task::Poll::Pending,
7013                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
7014                        this.is_terminated = true;
7015                        return std::task::Poll::Ready(None);
7016                    }
7017                    std::task::Poll::Ready(Err(e)) => {
7018                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7019                            e.into(),
7020                        ))));
7021                    }
7022                }
7023
7024                // A message has been received from the channel
7025                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7026
7027                std::task::Poll::Ready(Some(match header.ordinal {
7028                    0x200bf0ea21932de0 => {
7029                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7030                        let mut req = fidl::new_empty!(
7031                            SocketCreateSocketRequest,
7032                            fidl::encoding::DefaultFuchsiaResourceDialect
7033                        );
7034                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SocketCreateSocketRequest>(&header, _body_bytes, handles, &mut req)?;
7035                        let control_handle = SocketControlHandle { inner: this.inner.clone() };
7036                        Ok(SocketRequest::CreateSocket {
7037                            options: req.options,
7038                            handles: req.handles,
7039
7040                            responder: SocketCreateSocketResponder {
7041                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7042                                tx_id: header.tx_id,
7043                            },
7044                        })
7045                    }
7046                    0x60d3c7ccb17f9bdf => {
7047                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7048                        let mut req = fidl::new_empty!(
7049                            SocketSetSocketDispositionRequest,
7050                            fidl::encoding::DefaultFuchsiaResourceDialect
7051                        );
7052                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SocketSetSocketDispositionRequest>(&header, _body_bytes, handles, &mut req)?;
7053                        let control_handle = SocketControlHandle { inner: this.inner.clone() };
7054                        Ok(SocketRequest::SetSocketDisposition {
7055                            handle: req.handle,
7056                            disposition: req.disposition,
7057                            disposition_peer: req.disposition_peer,
7058
7059                            responder: SocketSetSocketDispositionResponder {
7060                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7061                                tx_id: header.tx_id,
7062                            },
7063                        })
7064                    }
7065                    0x1da8aabec249c02e => {
7066                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7067                        let mut req = fidl::new_empty!(
7068                            SocketReadSocketRequest,
7069                            fidl::encoding::DefaultFuchsiaResourceDialect
7070                        );
7071                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SocketReadSocketRequest>(&header, _body_bytes, handles, &mut req)?;
7072                        let control_handle = SocketControlHandle { inner: this.inner.clone() };
7073                        Ok(SocketRequest::ReadSocket {
7074                            handle: req.handle,
7075                            max_bytes: req.max_bytes,
7076
7077                            responder: SocketReadSocketResponder {
7078                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7079                                tx_id: header.tx_id,
7080                            },
7081                        })
7082                    }
7083                    0x5b541623cbbbf683 => {
7084                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7085                        let mut req = fidl::new_empty!(
7086                            SocketWriteSocketRequest,
7087                            fidl::encoding::DefaultFuchsiaResourceDialect
7088                        );
7089                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SocketWriteSocketRequest>(&header, _body_bytes, handles, &mut req)?;
7090                        let control_handle = SocketControlHandle { inner: this.inner.clone() };
7091                        Ok(SocketRequest::WriteSocket {
7092                            handle: req.handle,
7093                            data: req.data,
7094
7095                            responder: SocketWriteSocketResponder {
7096                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7097                                tx_id: header.tx_id,
7098                            },
7099                        })
7100                    }
7101                    0x2a592748d5f33445 => {
7102                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7103                        let mut req = fidl::new_empty!(
7104                            SocketReadSocketStreamingStartRequest,
7105                            fidl::encoding::DefaultFuchsiaResourceDialect
7106                        );
7107                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SocketReadSocketStreamingStartRequest>(&header, _body_bytes, handles, &mut req)?;
7108                        let control_handle = SocketControlHandle { inner: this.inner.clone() };
7109                        Ok(SocketRequest::ReadSocketStreamingStart {
7110                            handle: req.handle,
7111
7112                            responder: SocketReadSocketStreamingStartResponder {
7113                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7114                                tx_id: header.tx_id,
7115                            },
7116                        })
7117                    }
7118                    0x53e5cade5f4d22e7 => {
7119                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7120                        let mut req = fidl::new_empty!(
7121                            SocketReadSocketStreamingStopRequest,
7122                            fidl::encoding::DefaultFuchsiaResourceDialect
7123                        );
7124                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SocketReadSocketStreamingStopRequest>(&header, _body_bytes, handles, &mut req)?;
7125                        let control_handle = SocketControlHandle { inner: this.inner.clone() };
7126                        Ok(SocketRequest::ReadSocketStreamingStop {
7127                            handle: req.handle,
7128
7129                            responder: SocketReadSocketStreamingStopResponder {
7130                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7131                                tx_id: header.tx_id,
7132                            },
7133                        })
7134                    }
7135                    _ if header.tx_id == 0
7136                        && header
7137                            .dynamic_flags()
7138                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
7139                    {
7140                        Ok(SocketRequest::_UnknownMethod {
7141                            ordinal: header.ordinal,
7142                            control_handle: SocketControlHandle { inner: this.inner.clone() },
7143                            method_type: fidl::MethodType::OneWay,
7144                        })
7145                    }
7146                    _ if header
7147                        .dynamic_flags()
7148                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
7149                    {
7150                        this.inner.send_framework_err(
7151                            fidl::encoding::FrameworkErr::UnknownMethod,
7152                            header.tx_id,
7153                            header.ordinal,
7154                            header.dynamic_flags(),
7155                            (bytes, handles),
7156                        )?;
7157                        Ok(SocketRequest::_UnknownMethod {
7158                            ordinal: header.ordinal,
7159                            control_handle: SocketControlHandle { inner: this.inner.clone() },
7160                            method_type: fidl::MethodType::TwoWay,
7161                        })
7162                    }
7163                    _ => Err(fidl::Error::UnknownOrdinal {
7164                        ordinal: header.ordinal,
7165                        protocol_name:
7166                            <SocketMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7167                    }),
7168                }))
7169            },
7170        )
7171    }
7172}
7173
7174/// FDomain operations on sockets
7175#[derive(Debug)]
7176pub enum SocketRequest {
7177    /// Create a new socket in this FDomain and return both its ends.
7178    CreateSocket {
7179        options: SocketType,
7180        handles: [NewHandleId; 2],
7181        responder: SocketCreateSocketResponder,
7182    },
7183    /// Set the disposition of a given socket.
7184    SetSocketDisposition {
7185        handle: HandleId,
7186        disposition: SocketDisposition,
7187        disposition_peer: SocketDisposition,
7188        responder: SocketSetSocketDispositionResponder,
7189    },
7190    /// Read data from a socket. This method will fail if the socket is currently being read
7191    /// asynchronously.
7192    ReadSocket { handle: HandleId, max_bytes: u64, responder: SocketReadSocketResponder },
7193    /// Write to a socket. This will attempt to write all the data passed, and
7194    /// will block and retry whenever it is safe (e.g. it should never return
7195    /// SHOULD_WAIT). The `WriteSocketError` contains a `wrote` parameter to
7196    /// indicate if some bytes were written successfully before the failure
7197    /// occurred.
7198    WriteSocket { handle: HandleId, data: Vec<u8>, responder: SocketWriteSocketResponder },
7199    /// Starts reading from the given socket. Data is returned via the `SocketStreamingData` event. That
7200    /// event will occur repeatedly until `ReadSocketStreamingStop` is called for the same handle or the
7201    /// event indicates the handle is closed.
7202    ReadSocketStreamingStart {
7203        handle: HandleId,
7204        responder: SocketReadSocketStreamingStartResponder,
7205    },
7206    /// Stop asynchronous reading from the given socket.
7207    ReadSocketStreamingStop { handle: HandleId, responder: SocketReadSocketStreamingStopResponder },
7208    /// An interaction was received which does not match any known method.
7209    #[non_exhaustive]
7210    _UnknownMethod {
7211        /// Ordinal of the method that was called.
7212        ordinal: u64,
7213        control_handle: SocketControlHandle,
7214        method_type: fidl::MethodType,
7215    },
7216}
7217
7218impl SocketRequest {
7219    #[allow(irrefutable_let_patterns)]
7220    pub fn into_create_socket(
7221        self,
7222    ) -> Option<(SocketType, [NewHandleId; 2], SocketCreateSocketResponder)> {
7223        if let SocketRequest::CreateSocket { options, handles, responder } = self {
7224            Some((options, handles, responder))
7225        } else {
7226            None
7227        }
7228    }
7229
7230    #[allow(irrefutable_let_patterns)]
7231    pub fn into_set_socket_disposition(
7232        self,
7233    ) -> Option<(HandleId, SocketDisposition, SocketDisposition, SocketSetSocketDispositionResponder)>
7234    {
7235        if let SocketRequest::SetSocketDisposition {
7236            handle,
7237            disposition,
7238            disposition_peer,
7239            responder,
7240        } = self
7241        {
7242            Some((handle, disposition, disposition_peer, responder))
7243        } else {
7244            None
7245        }
7246    }
7247
7248    #[allow(irrefutable_let_patterns)]
7249    pub fn into_read_socket(self) -> Option<(HandleId, u64, SocketReadSocketResponder)> {
7250        if let SocketRequest::ReadSocket { handle, max_bytes, responder } = self {
7251            Some((handle, max_bytes, responder))
7252        } else {
7253            None
7254        }
7255    }
7256
7257    #[allow(irrefutable_let_patterns)]
7258    pub fn into_write_socket(self) -> Option<(HandleId, Vec<u8>, SocketWriteSocketResponder)> {
7259        if let SocketRequest::WriteSocket { handle, data, responder } = self {
7260            Some((handle, data, responder))
7261        } else {
7262            None
7263        }
7264    }
7265
7266    #[allow(irrefutable_let_patterns)]
7267    pub fn into_read_socket_streaming_start(
7268        self,
7269    ) -> Option<(HandleId, SocketReadSocketStreamingStartResponder)> {
7270        if let SocketRequest::ReadSocketStreamingStart { handle, responder } = self {
7271            Some((handle, responder))
7272        } else {
7273            None
7274        }
7275    }
7276
7277    #[allow(irrefutable_let_patterns)]
7278    pub fn into_read_socket_streaming_stop(
7279        self,
7280    ) -> Option<(HandleId, SocketReadSocketStreamingStopResponder)> {
7281        if let SocketRequest::ReadSocketStreamingStop { handle, responder } = self {
7282            Some((handle, responder))
7283        } else {
7284            None
7285        }
7286    }
7287
7288    /// Name of the method defined in FIDL
7289    pub fn method_name(&self) -> &'static str {
7290        match *self {
7291            SocketRequest::CreateSocket { .. } => "create_socket",
7292            SocketRequest::SetSocketDisposition { .. } => "set_socket_disposition",
7293            SocketRequest::ReadSocket { .. } => "read_socket",
7294            SocketRequest::WriteSocket { .. } => "write_socket",
7295            SocketRequest::ReadSocketStreamingStart { .. } => "read_socket_streaming_start",
7296            SocketRequest::ReadSocketStreamingStop { .. } => "read_socket_streaming_stop",
7297            SocketRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
7298                "unknown one-way method"
7299            }
7300            SocketRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
7301                "unknown two-way method"
7302            }
7303        }
7304    }
7305}
7306
7307#[derive(Debug, Clone)]
7308pub struct SocketControlHandle {
7309    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7310}
7311
7312impl SocketControlHandle {
7313    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
7314        self.inner.shutdown_with_epitaph(status.into())
7315    }
7316}
7317
7318impl fidl::endpoints::ControlHandle for SocketControlHandle {
7319    fn shutdown(&self) {
7320        self.inner.shutdown()
7321    }
7322
7323    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
7324        self.inner.shutdown_with_epitaph(status)
7325    }
7326
7327    fn is_closed(&self) -> bool {
7328        self.inner.channel().is_closed()
7329    }
7330    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
7331        self.inner.channel().on_closed()
7332    }
7333
7334    #[cfg(target_os = "fuchsia")]
7335    fn signal_peer(
7336        &self,
7337        clear_mask: zx::Signals,
7338        set_mask: zx::Signals,
7339    ) -> Result<(), zx_status::Status> {
7340        use fidl::Peered;
7341        self.inner.channel().signal_peer(clear_mask, set_mask)
7342    }
7343}
7344
7345impl SocketControlHandle {
7346    pub fn send_on_socket_streaming_data(
7347        &self,
7348        mut handle: &HandleId,
7349        mut socket_message: &SocketMessage,
7350    ) -> Result<(), fidl::Error> {
7351        self.inner.send::<SocketOnSocketStreamingDataRequest>(
7352            (handle, socket_message),
7353            0,
7354            0x998b5e66b3c80a2,
7355            fidl::encoding::DynamicFlags::FLEXIBLE,
7356        )
7357    }
7358}
7359
7360#[must_use = "FIDL methods require a response to be sent"]
7361#[derive(Debug)]
7362pub struct SocketCreateSocketResponder {
7363    control_handle: std::mem::ManuallyDrop<SocketControlHandle>,
7364    tx_id: u32,
7365}
7366
7367/// Set the the channel to be shutdown (see [`SocketControlHandle::shutdown`])
7368/// if the responder is dropped without sending a response, so that the client
7369/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7370impl std::ops::Drop for SocketCreateSocketResponder {
7371    fn drop(&mut self) {
7372        self.control_handle.shutdown();
7373        // Safety: drops once, never accessed again
7374        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7375    }
7376}
7377
7378impl fidl::endpoints::Responder for SocketCreateSocketResponder {
7379    type ControlHandle = SocketControlHandle;
7380
7381    fn control_handle(&self) -> &SocketControlHandle {
7382        &self.control_handle
7383    }
7384
7385    fn drop_without_shutdown(mut self) {
7386        // Safety: drops once, never accessed again due to mem::forget
7387        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7388        // Prevent Drop from running (which would shut down the channel)
7389        std::mem::forget(self);
7390    }
7391}
7392
7393impl SocketCreateSocketResponder {
7394    /// Sends a response to the FIDL transaction.
7395    ///
7396    /// Sets the channel to shutdown if an error occurs.
7397    pub fn send(self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
7398        let _result = self.send_raw(result);
7399        if _result.is_err() {
7400            self.control_handle.shutdown();
7401        }
7402        self.drop_without_shutdown();
7403        _result
7404    }
7405
7406    /// Similar to "send" but does not shutdown the channel if an error occurs.
7407    pub fn send_no_shutdown_on_err(
7408        self,
7409        mut result: Result<(), &Error>,
7410    ) -> Result<(), fidl::Error> {
7411        let _result = self.send_raw(result);
7412        self.drop_without_shutdown();
7413        _result
7414    }
7415
7416    fn send_raw(&self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
7417        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
7418            fidl::encoding::EmptyStruct,
7419            Error,
7420        >>(
7421            fidl::encoding::FlexibleResult::new(result),
7422            self.tx_id,
7423            0x200bf0ea21932de0,
7424            fidl::encoding::DynamicFlags::FLEXIBLE,
7425        )
7426    }
7427}
7428
7429#[must_use = "FIDL methods require a response to be sent"]
7430#[derive(Debug)]
7431pub struct SocketSetSocketDispositionResponder {
7432    control_handle: std::mem::ManuallyDrop<SocketControlHandle>,
7433    tx_id: u32,
7434}
7435
7436/// Set the the channel to be shutdown (see [`SocketControlHandle::shutdown`])
7437/// if the responder is dropped without sending a response, so that the client
7438/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7439impl std::ops::Drop for SocketSetSocketDispositionResponder {
7440    fn drop(&mut self) {
7441        self.control_handle.shutdown();
7442        // Safety: drops once, never accessed again
7443        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7444    }
7445}
7446
7447impl fidl::endpoints::Responder for SocketSetSocketDispositionResponder {
7448    type ControlHandle = SocketControlHandle;
7449
7450    fn control_handle(&self) -> &SocketControlHandle {
7451        &self.control_handle
7452    }
7453
7454    fn drop_without_shutdown(mut self) {
7455        // Safety: drops once, never accessed again due to mem::forget
7456        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7457        // Prevent Drop from running (which would shut down the channel)
7458        std::mem::forget(self);
7459    }
7460}
7461
7462impl SocketSetSocketDispositionResponder {
7463    /// Sends a response to the FIDL transaction.
7464    ///
7465    /// Sets the channel to shutdown if an error occurs.
7466    pub fn send(self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
7467        let _result = self.send_raw(result);
7468        if _result.is_err() {
7469            self.control_handle.shutdown();
7470        }
7471        self.drop_without_shutdown();
7472        _result
7473    }
7474
7475    /// Similar to "send" but does not shutdown the channel if an error occurs.
7476    pub fn send_no_shutdown_on_err(
7477        self,
7478        mut result: Result<(), &Error>,
7479    ) -> Result<(), fidl::Error> {
7480        let _result = self.send_raw(result);
7481        self.drop_without_shutdown();
7482        _result
7483    }
7484
7485    fn send_raw(&self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
7486        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
7487            fidl::encoding::EmptyStruct,
7488            Error,
7489        >>(
7490            fidl::encoding::FlexibleResult::new(result),
7491            self.tx_id,
7492            0x60d3c7ccb17f9bdf,
7493            fidl::encoding::DynamicFlags::FLEXIBLE,
7494        )
7495    }
7496}
7497
7498#[must_use = "FIDL methods require a response to be sent"]
7499#[derive(Debug)]
7500pub struct SocketReadSocketResponder {
7501    control_handle: std::mem::ManuallyDrop<SocketControlHandle>,
7502    tx_id: u32,
7503}
7504
7505/// Set the the channel to be shutdown (see [`SocketControlHandle::shutdown`])
7506/// if the responder is dropped without sending a response, so that the client
7507/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7508impl std::ops::Drop for SocketReadSocketResponder {
7509    fn drop(&mut self) {
7510        self.control_handle.shutdown();
7511        // Safety: drops once, never accessed again
7512        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7513    }
7514}
7515
7516impl fidl::endpoints::Responder for SocketReadSocketResponder {
7517    type ControlHandle = SocketControlHandle;
7518
7519    fn control_handle(&self) -> &SocketControlHandle {
7520        &self.control_handle
7521    }
7522
7523    fn drop_without_shutdown(mut self) {
7524        // Safety: drops once, never accessed again due to mem::forget
7525        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7526        // Prevent Drop from running (which would shut down the channel)
7527        std::mem::forget(self);
7528    }
7529}
7530
7531impl SocketReadSocketResponder {
7532    /// Sends a response to the FIDL transaction.
7533    ///
7534    /// Sets the channel to shutdown if an error occurs.
7535    pub fn send(self, mut result: Result<(&[u8], bool), &Error>) -> Result<(), fidl::Error> {
7536        let _result = self.send_raw(result);
7537        if _result.is_err() {
7538            self.control_handle.shutdown();
7539        }
7540        self.drop_without_shutdown();
7541        _result
7542    }
7543
7544    /// Similar to "send" but does not shutdown the channel if an error occurs.
7545    pub fn send_no_shutdown_on_err(
7546        self,
7547        mut result: Result<(&[u8], bool), &Error>,
7548    ) -> Result<(), fidl::Error> {
7549        let _result = self.send_raw(result);
7550        self.drop_without_shutdown();
7551        _result
7552    }
7553
7554    fn send_raw(&self, mut result: Result<(&[u8], bool), &Error>) -> Result<(), fidl::Error> {
7555        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<SocketData, Error>>(
7556            fidl::encoding::FlexibleResult::new(result),
7557            self.tx_id,
7558            0x1da8aabec249c02e,
7559            fidl::encoding::DynamicFlags::FLEXIBLE,
7560        )
7561    }
7562}
7563
7564#[must_use = "FIDL methods require a response to be sent"]
7565#[derive(Debug)]
7566pub struct SocketWriteSocketResponder {
7567    control_handle: std::mem::ManuallyDrop<SocketControlHandle>,
7568    tx_id: u32,
7569}
7570
7571/// Set the the channel to be shutdown (see [`SocketControlHandle::shutdown`])
7572/// if the responder is dropped without sending a response, so that the client
7573/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7574impl std::ops::Drop for SocketWriteSocketResponder {
7575    fn drop(&mut self) {
7576        self.control_handle.shutdown();
7577        // Safety: drops once, never accessed again
7578        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7579    }
7580}
7581
7582impl fidl::endpoints::Responder for SocketWriteSocketResponder {
7583    type ControlHandle = SocketControlHandle;
7584
7585    fn control_handle(&self) -> &SocketControlHandle {
7586        &self.control_handle
7587    }
7588
7589    fn drop_without_shutdown(mut self) {
7590        // Safety: drops once, never accessed again due to mem::forget
7591        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7592        // Prevent Drop from running (which would shut down the channel)
7593        std::mem::forget(self);
7594    }
7595}
7596
7597impl SocketWriteSocketResponder {
7598    /// Sends a response to the FIDL transaction.
7599    ///
7600    /// Sets the channel to shutdown if an error occurs.
7601    pub fn send(self, mut result: Result<u64, &WriteSocketError>) -> Result<(), fidl::Error> {
7602        let _result = self.send_raw(result);
7603        if _result.is_err() {
7604            self.control_handle.shutdown();
7605        }
7606        self.drop_without_shutdown();
7607        _result
7608    }
7609
7610    /// Similar to "send" but does not shutdown the channel if an error occurs.
7611    pub fn send_no_shutdown_on_err(
7612        self,
7613        mut result: Result<u64, &WriteSocketError>,
7614    ) -> Result<(), fidl::Error> {
7615        let _result = self.send_raw(result);
7616        self.drop_without_shutdown();
7617        _result
7618    }
7619
7620    fn send_raw(&self, mut result: Result<u64, &WriteSocketError>) -> Result<(), fidl::Error> {
7621        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
7622            SocketWriteSocketResponse,
7623            WriteSocketError,
7624        >>(
7625            fidl::encoding::FlexibleResult::new(result.map(|wrote| (wrote,))),
7626            self.tx_id,
7627            0x5b541623cbbbf683,
7628            fidl::encoding::DynamicFlags::FLEXIBLE,
7629        )
7630    }
7631}
7632
7633#[must_use = "FIDL methods require a response to be sent"]
7634#[derive(Debug)]
7635pub struct SocketReadSocketStreamingStartResponder {
7636    control_handle: std::mem::ManuallyDrop<SocketControlHandle>,
7637    tx_id: u32,
7638}
7639
7640/// Set the the channel to be shutdown (see [`SocketControlHandle::shutdown`])
7641/// if the responder is dropped without sending a response, so that the client
7642/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7643impl std::ops::Drop for SocketReadSocketStreamingStartResponder {
7644    fn drop(&mut self) {
7645        self.control_handle.shutdown();
7646        // Safety: drops once, never accessed again
7647        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7648    }
7649}
7650
7651impl fidl::endpoints::Responder for SocketReadSocketStreamingStartResponder {
7652    type ControlHandle = SocketControlHandle;
7653
7654    fn control_handle(&self) -> &SocketControlHandle {
7655        &self.control_handle
7656    }
7657
7658    fn drop_without_shutdown(mut self) {
7659        // Safety: drops once, never accessed again due to mem::forget
7660        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7661        // Prevent Drop from running (which would shut down the channel)
7662        std::mem::forget(self);
7663    }
7664}
7665
7666impl SocketReadSocketStreamingStartResponder {
7667    /// Sends a response to the FIDL transaction.
7668    ///
7669    /// Sets the channel to shutdown if an error occurs.
7670    pub fn send(self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
7671        let _result = self.send_raw(result);
7672        if _result.is_err() {
7673            self.control_handle.shutdown();
7674        }
7675        self.drop_without_shutdown();
7676        _result
7677    }
7678
7679    /// Similar to "send" but does not shutdown the channel if an error occurs.
7680    pub fn send_no_shutdown_on_err(
7681        self,
7682        mut result: Result<(), &Error>,
7683    ) -> Result<(), fidl::Error> {
7684        let _result = self.send_raw(result);
7685        self.drop_without_shutdown();
7686        _result
7687    }
7688
7689    fn send_raw(&self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
7690        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
7691            fidl::encoding::EmptyStruct,
7692            Error,
7693        >>(
7694            fidl::encoding::FlexibleResult::new(result),
7695            self.tx_id,
7696            0x2a592748d5f33445,
7697            fidl::encoding::DynamicFlags::FLEXIBLE,
7698        )
7699    }
7700}
7701
7702#[must_use = "FIDL methods require a response to be sent"]
7703#[derive(Debug)]
7704pub struct SocketReadSocketStreamingStopResponder {
7705    control_handle: std::mem::ManuallyDrop<SocketControlHandle>,
7706    tx_id: u32,
7707}
7708
7709/// Set the the channel to be shutdown (see [`SocketControlHandle::shutdown`])
7710/// if the responder is dropped without sending a response, so that the client
7711/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7712impl std::ops::Drop for SocketReadSocketStreamingStopResponder {
7713    fn drop(&mut self) {
7714        self.control_handle.shutdown();
7715        // Safety: drops once, never accessed again
7716        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7717    }
7718}
7719
7720impl fidl::endpoints::Responder for SocketReadSocketStreamingStopResponder {
7721    type ControlHandle = SocketControlHandle;
7722
7723    fn control_handle(&self) -> &SocketControlHandle {
7724        &self.control_handle
7725    }
7726
7727    fn drop_without_shutdown(mut self) {
7728        // Safety: drops once, never accessed again due to mem::forget
7729        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7730        // Prevent Drop from running (which would shut down the channel)
7731        std::mem::forget(self);
7732    }
7733}
7734
7735impl SocketReadSocketStreamingStopResponder {
7736    /// Sends a response to the FIDL transaction.
7737    ///
7738    /// Sets the channel to shutdown if an error occurs.
7739    pub fn send(self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
7740        let _result = self.send_raw(result);
7741        if _result.is_err() {
7742            self.control_handle.shutdown();
7743        }
7744        self.drop_without_shutdown();
7745        _result
7746    }
7747
7748    /// Similar to "send" but does not shutdown the channel if an error occurs.
7749    pub fn send_no_shutdown_on_err(
7750        self,
7751        mut result: Result<(), &Error>,
7752    ) -> Result<(), fidl::Error> {
7753        let _result = self.send_raw(result);
7754        self.drop_without_shutdown();
7755        _result
7756    }
7757
7758    fn send_raw(&self, mut result: Result<(), &Error>) -> Result<(), fidl::Error> {
7759        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
7760            fidl::encoding::EmptyStruct,
7761            Error,
7762        >>(
7763            fidl::encoding::FlexibleResult::new(result),
7764            self.tx_id,
7765            0x53e5cade5f4d22e7,
7766            fidl::encoding::DynamicFlags::FLEXIBLE,
7767        )
7768    }
7769}
7770
7771mod internal {
7772    use super::*;
7773}