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