fidl_fuchsia_developer_remotecontrol_connector/
fidl_fuchsia_developer_remotecontrol_connector.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10use futures::future::{self, MaybeDone, TryFutureExt};
11use zx_status;
12
13#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
14pub struct ConnectorEstablishCircuitRequest {
15    pub id: u64,
16    pub socket: fidl::Socket,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20    for ConnectorEstablishCircuitRequest
21{
22}
23
24#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
25pub struct ConnectorFdomainToolboxSocketRequest {
26    pub socket: fidl::Socket,
27}
28
29impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
30    for ConnectorFdomainToolboxSocketRequest
31{
32}
33
34#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
35pub struct ConnectorMarker;
36
37impl fidl::endpoints::ProtocolMarker for ConnectorMarker {
38    type Proxy = ConnectorProxy;
39    type RequestStream = ConnectorRequestStream;
40    #[cfg(target_os = "fuchsia")]
41    type SynchronousProxy = ConnectorSynchronousProxy;
42
43    const DEBUG_NAME: &'static str = "fuchsia.developer.remotecontrol.connector.Connector";
44}
45impl fidl::endpoints::DiscoverableProtocolMarker for ConnectorMarker {}
46
47pub trait ConnectorProxyInterface: Send + Sync {
48    type EstablishCircuitResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
49    fn r#establish_circuit(
50        &self,
51        id: u64,
52        socket: fidl::Socket,
53    ) -> Self::EstablishCircuitResponseFut;
54    type FdomainToolboxSocketResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
55        + Send;
56    fn r#fdomain_toolbox_socket(
57        &self,
58        socket: fidl::Socket,
59    ) -> Self::FdomainToolboxSocketResponseFut;
60}
61#[derive(Debug)]
62#[cfg(target_os = "fuchsia")]
63pub struct ConnectorSynchronousProxy {
64    client: fidl::client::sync::Client,
65}
66
67#[cfg(target_os = "fuchsia")]
68impl fidl::endpoints::SynchronousProxy for ConnectorSynchronousProxy {
69    type Proxy = ConnectorProxy;
70    type Protocol = ConnectorMarker;
71
72    fn from_channel(inner: fidl::Channel) -> Self {
73        Self::new(inner)
74    }
75
76    fn into_channel(self) -> fidl::Channel {
77        self.client.into_channel()
78    }
79
80    fn as_channel(&self) -> &fidl::Channel {
81        self.client.as_channel()
82    }
83}
84
85#[cfg(target_os = "fuchsia")]
86impl ConnectorSynchronousProxy {
87    pub fn new(channel: fidl::Channel) -> Self {
88        let protocol_name = <ConnectorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
89        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
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<ConnectorEvent, fidl::Error> {
102        ConnectorEvent::decode(self.client.wait_for_event(deadline)?)
103    }
104
105    pub fn r#establish_circuit(
106        &self,
107        mut id: u64,
108        mut socket: fidl::Socket,
109        ___deadline: zx::MonotonicInstant,
110    ) -> Result<(), fidl::Error> {
111        let _response = self
112            .client
113            .send_query::<ConnectorEstablishCircuitRequest, fidl::encoding::EmptyPayload>(
114                (id, socket),
115                0x34f64270f6eb7feb,
116                fidl::encoding::DynamicFlags::empty(),
117                ___deadline,
118            )?;
119        Ok(_response)
120    }
121
122    pub fn r#fdomain_toolbox_socket(
123        &self,
124        mut socket: fidl::Socket,
125        ___deadline: zx::MonotonicInstant,
126    ) -> Result<(), fidl::Error> {
127        let _response = self
128            .client
129            .send_query::<ConnectorFdomainToolboxSocketRequest, fidl::encoding::EmptyPayload>(
130                (socket,),
131                0x6fec63852eec8566,
132                fidl::encoding::DynamicFlags::empty(),
133                ___deadline,
134            )?;
135        Ok(_response)
136    }
137}
138
139#[derive(Debug, Clone)]
140pub struct ConnectorProxy {
141    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
142}
143
144impl fidl::endpoints::Proxy for ConnectorProxy {
145    type Protocol = ConnectorMarker;
146
147    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
148        Self::new(inner)
149    }
150
151    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
152        self.client.into_channel().map_err(|client| Self { client })
153    }
154
155    fn as_channel(&self) -> &::fidl::AsyncChannel {
156        self.client.as_channel()
157    }
158}
159
160impl ConnectorProxy {
161    /// Create a new Proxy for fuchsia.developer.remotecontrol.connector/Connector.
162    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
163        let protocol_name = <ConnectorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
164        Self { client: fidl::client::Client::new(channel, protocol_name) }
165    }
166
167    /// Get a Stream of events from the remote end of the protocol.
168    ///
169    /// # Panics
170    ///
171    /// Panics if the event stream was already taken.
172    pub fn take_event_stream(&self) -> ConnectorEventStream {
173        ConnectorEventStream { event_receiver: self.client.take_event_receiver() }
174    }
175
176    pub fn r#establish_circuit(
177        &self,
178        mut id: u64,
179        mut socket: fidl::Socket,
180    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
181        ConnectorProxyInterface::r#establish_circuit(self, id, socket)
182    }
183
184    pub fn r#fdomain_toolbox_socket(
185        &self,
186        mut socket: fidl::Socket,
187    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
188        ConnectorProxyInterface::r#fdomain_toolbox_socket(self, socket)
189    }
190}
191
192impl ConnectorProxyInterface for ConnectorProxy {
193    type EstablishCircuitResponseFut =
194        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
195    fn r#establish_circuit(
196        &self,
197        mut id: u64,
198        mut socket: fidl::Socket,
199    ) -> Self::EstablishCircuitResponseFut {
200        fn _decode(
201            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
202        ) -> Result<(), fidl::Error> {
203            let _response = fidl::client::decode_transaction_body::<
204                fidl::encoding::EmptyPayload,
205                fidl::encoding::DefaultFuchsiaResourceDialect,
206                0x34f64270f6eb7feb,
207            >(_buf?)?;
208            Ok(_response)
209        }
210        self.client.send_query_and_decode::<ConnectorEstablishCircuitRequest, ()>(
211            (id, socket),
212            0x34f64270f6eb7feb,
213            fidl::encoding::DynamicFlags::empty(),
214            _decode,
215        )
216    }
217
218    type FdomainToolboxSocketResponseFut =
219        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
220    fn r#fdomain_toolbox_socket(
221        &self,
222        mut socket: fidl::Socket,
223    ) -> Self::FdomainToolboxSocketResponseFut {
224        fn _decode(
225            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
226        ) -> Result<(), fidl::Error> {
227            let _response = fidl::client::decode_transaction_body::<
228                fidl::encoding::EmptyPayload,
229                fidl::encoding::DefaultFuchsiaResourceDialect,
230                0x6fec63852eec8566,
231            >(_buf?)?;
232            Ok(_response)
233        }
234        self.client.send_query_and_decode::<ConnectorFdomainToolboxSocketRequest, ()>(
235            (socket,),
236            0x6fec63852eec8566,
237            fidl::encoding::DynamicFlags::empty(),
238            _decode,
239        )
240    }
241}
242
243pub struct ConnectorEventStream {
244    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
245}
246
247impl std::marker::Unpin for ConnectorEventStream {}
248
249impl futures::stream::FusedStream for ConnectorEventStream {
250    fn is_terminated(&self) -> bool {
251        self.event_receiver.is_terminated()
252    }
253}
254
255impl futures::Stream for ConnectorEventStream {
256    type Item = Result<ConnectorEvent, fidl::Error>;
257
258    fn poll_next(
259        mut self: std::pin::Pin<&mut Self>,
260        cx: &mut std::task::Context<'_>,
261    ) -> std::task::Poll<Option<Self::Item>> {
262        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
263            &mut self.event_receiver,
264            cx
265        )?) {
266            Some(buf) => std::task::Poll::Ready(Some(ConnectorEvent::decode(buf))),
267            None => std::task::Poll::Ready(None),
268        }
269    }
270}
271
272#[derive(Debug)]
273pub enum ConnectorEvent {}
274
275impl ConnectorEvent {
276    /// Decodes a message buffer as a [`ConnectorEvent`].
277    fn decode(
278        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
279    ) -> Result<ConnectorEvent, fidl::Error> {
280        let (bytes, _handles) = buf.split_mut();
281        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
282        debug_assert_eq!(tx_header.tx_id, 0);
283        match tx_header.ordinal {
284            _ => Err(fidl::Error::UnknownOrdinal {
285                ordinal: tx_header.ordinal,
286                protocol_name: <ConnectorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
287            }),
288        }
289    }
290}
291
292/// A Stream of incoming requests for fuchsia.developer.remotecontrol.connector/Connector.
293pub struct ConnectorRequestStream {
294    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
295    is_terminated: bool,
296}
297
298impl std::marker::Unpin for ConnectorRequestStream {}
299
300impl futures::stream::FusedStream for ConnectorRequestStream {
301    fn is_terminated(&self) -> bool {
302        self.is_terminated
303    }
304}
305
306impl fidl::endpoints::RequestStream for ConnectorRequestStream {
307    type Protocol = ConnectorMarker;
308    type ControlHandle = ConnectorControlHandle;
309
310    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
311        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
312    }
313
314    fn control_handle(&self) -> Self::ControlHandle {
315        ConnectorControlHandle { inner: self.inner.clone() }
316    }
317
318    fn into_inner(
319        self,
320    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
321    {
322        (self.inner, self.is_terminated)
323    }
324
325    fn from_inner(
326        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
327        is_terminated: bool,
328    ) -> Self {
329        Self { inner, is_terminated }
330    }
331}
332
333impl futures::Stream for ConnectorRequestStream {
334    type Item = Result<ConnectorRequest, fidl::Error>;
335
336    fn poll_next(
337        mut self: std::pin::Pin<&mut Self>,
338        cx: &mut std::task::Context<'_>,
339    ) -> std::task::Poll<Option<Self::Item>> {
340        let this = &mut *self;
341        if this.inner.check_shutdown(cx) {
342            this.is_terminated = true;
343            return std::task::Poll::Ready(None);
344        }
345        if this.is_terminated {
346            panic!("polled ConnectorRequestStream after completion");
347        }
348        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
349            |bytes, handles| {
350                match this.inner.channel().read_etc(cx, bytes, handles) {
351                    std::task::Poll::Ready(Ok(())) => {}
352                    std::task::Poll::Pending => return std::task::Poll::Pending,
353                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
354                        this.is_terminated = true;
355                        return std::task::Poll::Ready(None);
356                    }
357                    std::task::Poll::Ready(Err(e)) => {
358                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
359                            e.into(),
360                        ))))
361                    }
362                }
363
364                // A message has been received from the channel
365                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
366
367                std::task::Poll::Ready(Some(match header.ordinal {
368                    0x34f64270f6eb7feb => {
369                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
370                        let mut req = fidl::new_empty!(
371                            ConnectorEstablishCircuitRequest,
372                            fidl::encoding::DefaultFuchsiaResourceDialect
373                        );
374                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ConnectorEstablishCircuitRequest>(&header, _body_bytes, handles, &mut req)?;
375                        let control_handle = ConnectorControlHandle { inner: this.inner.clone() };
376                        Ok(ConnectorRequest::EstablishCircuit {
377                            id: req.id,
378                            socket: req.socket,
379
380                            responder: ConnectorEstablishCircuitResponder {
381                                control_handle: std::mem::ManuallyDrop::new(control_handle),
382                                tx_id: header.tx_id,
383                            },
384                        })
385                    }
386                    0x6fec63852eec8566 => {
387                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
388                        let mut req = fidl::new_empty!(
389                            ConnectorFdomainToolboxSocketRequest,
390                            fidl::encoding::DefaultFuchsiaResourceDialect
391                        );
392                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ConnectorFdomainToolboxSocketRequest>(&header, _body_bytes, handles, &mut req)?;
393                        let control_handle = ConnectorControlHandle { inner: this.inner.clone() };
394                        Ok(ConnectorRequest::FdomainToolboxSocket {
395                            socket: req.socket,
396
397                            responder: ConnectorFdomainToolboxSocketResponder {
398                                control_handle: std::mem::ManuallyDrop::new(control_handle),
399                                tx_id: header.tx_id,
400                            },
401                        })
402                    }
403                    _ => Err(fidl::Error::UnknownOrdinal {
404                        ordinal: header.ordinal,
405                        protocol_name:
406                            <ConnectorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
407                    }),
408                }))
409            },
410        )
411    }
412}
413
414#[derive(Debug)]
415pub enum ConnectorRequest {
416    EstablishCircuit {
417        id: u64,
418        socket: fidl::Socket,
419        responder: ConnectorEstablishCircuitResponder,
420    },
421    FdomainToolboxSocket {
422        socket: fidl::Socket,
423        responder: ConnectorFdomainToolboxSocketResponder,
424    },
425}
426
427impl ConnectorRequest {
428    #[allow(irrefutable_let_patterns)]
429    pub fn into_establish_circuit(
430        self,
431    ) -> Option<(u64, fidl::Socket, ConnectorEstablishCircuitResponder)> {
432        if let ConnectorRequest::EstablishCircuit { id, socket, responder } = self {
433            Some((id, socket, responder))
434        } else {
435            None
436        }
437    }
438
439    #[allow(irrefutable_let_patterns)]
440    pub fn into_fdomain_toolbox_socket(
441        self,
442    ) -> Option<(fidl::Socket, ConnectorFdomainToolboxSocketResponder)> {
443        if let ConnectorRequest::FdomainToolboxSocket { socket, responder } = self {
444            Some((socket, responder))
445        } else {
446            None
447        }
448    }
449
450    /// Name of the method defined in FIDL
451    pub fn method_name(&self) -> &'static str {
452        match *self {
453            ConnectorRequest::EstablishCircuit { .. } => "establish_circuit",
454            ConnectorRequest::FdomainToolboxSocket { .. } => "fdomain_toolbox_socket",
455        }
456    }
457}
458
459#[derive(Debug, Clone)]
460pub struct ConnectorControlHandle {
461    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
462}
463
464impl fidl::endpoints::ControlHandle for ConnectorControlHandle {
465    fn shutdown(&self) {
466        self.inner.shutdown()
467    }
468    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
469        self.inner.shutdown_with_epitaph(status)
470    }
471
472    fn is_closed(&self) -> bool {
473        self.inner.channel().is_closed()
474    }
475    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
476        self.inner.channel().on_closed()
477    }
478
479    #[cfg(target_os = "fuchsia")]
480    fn signal_peer(
481        &self,
482        clear_mask: zx::Signals,
483        set_mask: zx::Signals,
484    ) -> Result<(), zx_status::Status> {
485        use fidl::Peered;
486        self.inner.channel().signal_peer(clear_mask, set_mask)
487    }
488}
489
490impl ConnectorControlHandle {}
491
492#[must_use = "FIDL methods require a response to be sent"]
493#[derive(Debug)]
494pub struct ConnectorEstablishCircuitResponder {
495    control_handle: std::mem::ManuallyDrop<ConnectorControlHandle>,
496    tx_id: u32,
497}
498
499/// Set the the channel to be shutdown (see [`ConnectorControlHandle::shutdown`])
500/// if the responder is dropped without sending a response, so that the client
501/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
502impl std::ops::Drop for ConnectorEstablishCircuitResponder {
503    fn drop(&mut self) {
504        self.control_handle.shutdown();
505        // Safety: drops once, never accessed again
506        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
507    }
508}
509
510impl fidl::endpoints::Responder for ConnectorEstablishCircuitResponder {
511    type ControlHandle = ConnectorControlHandle;
512
513    fn control_handle(&self) -> &ConnectorControlHandle {
514        &self.control_handle
515    }
516
517    fn drop_without_shutdown(mut self) {
518        // Safety: drops once, never accessed again due to mem::forget
519        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
520        // Prevent Drop from running (which would shut down the channel)
521        std::mem::forget(self);
522    }
523}
524
525impl ConnectorEstablishCircuitResponder {
526    /// Sends a response to the FIDL transaction.
527    ///
528    /// Sets the channel to shutdown if an error occurs.
529    pub fn send(self) -> Result<(), fidl::Error> {
530        let _result = self.send_raw();
531        if _result.is_err() {
532            self.control_handle.shutdown();
533        }
534        self.drop_without_shutdown();
535        _result
536    }
537
538    /// Similar to "send" but does not shutdown the channel if an error occurs.
539    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
540        let _result = self.send_raw();
541        self.drop_without_shutdown();
542        _result
543    }
544
545    fn send_raw(&self) -> Result<(), fidl::Error> {
546        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
547            (),
548            self.tx_id,
549            0x34f64270f6eb7feb,
550            fidl::encoding::DynamicFlags::empty(),
551        )
552    }
553}
554
555#[must_use = "FIDL methods require a response to be sent"]
556#[derive(Debug)]
557pub struct ConnectorFdomainToolboxSocketResponder {
558    control_handle: std::mem::ManuallyDrop<ConnectorControlHandle>,
559    tx_id: u32,
560}
561
562/// Set the the channel to be shutdown (see [`ConnectorControlHandle::shutdown`])
563/// if the responder is dropped without sending a response, so that the client
564/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
565impl std::ops::Drop for ConnectorFdomainToolboxSocketResponder {
566    fn drop(&mut self) {
567        self.control_handle.shutdown();
568        // Safety: drops once, never accessed again
569        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
570    }
571}
572
573impl fidl::endpoints::Responder for ConnectorFdomainToolboxSocketResponder {
574    type ControlHandle = ConnectorControlHandle;
575
576    fn control_handle(&self) -> &ConnectorControlHandle {
577        &self.control_handle
578    }
579
580    fn drop_without_shutdown(mut self) {
581        // Safety: drops once, never accessed again due to mem::forget
582        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
583        // Prevent Drop from running (which would shut down the channel)
584        std::mem::forget(self);
585    }
586}
587
588impl ConnectorFdomainToolboxSocketResponder {
589    /// Sends a response to the FIDL transaction.
590    ///
591    /// Sets the channel to shutdown if an error occurs.
592    pub fn send(self) -> Result<(), fidl::Error> {
593        let _result = self.send_raw();
594        if _result.is_err() {
595            self.control_handle.shutdown();
596        }
597        self.drop_without_shutdown();
598        _result
599    }
600
601    /// Similar to "send" but does not shutdown the channel if an error occurs.
602    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
603        let _result = self.send_raw();
604        self.drop_without_shutdown();
605        _result
606    }
607
608    fn send_raw(&self) -> Result<(), fidl::Error> {
609        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
610            (),
611            self.tx_id,
612            0x6fec63852eec8566,
613            fidl::encoding::DynamicFlags::empty(),
614        )
615    }
616}
617
618mod internal {
619    use super::*;
620
621    impl fidl::encoding::ResourceTypeMarker for ConnectorEstablishCircuitRequest {
622        type Borrowed<'a> = &'a mut Self;
623        fn take_or_borrow<'a>(
624            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
625        ) -> Self::Borrowed<'a> {
626            value
627        }
628    }
629
630    unsafe impl fidl::encoding::TypeMarker for ConnectorEstablishCircuitRequest {
631        type Owned = Self;
632
633        #[inline(always)]
634        fn inline_align(_context: fidl::encoding::Context) -> usize {
635            8
636        }
637
638        #[inline(always)]
639        fn inline_size(_context: fidl::encoding::Context) -> usize {
640            16
641        }
642    }
643
644    unsafe impl
645        fidl::encoding::Encode<
646            ConnectorEstablishCircuitRequest,
647            fidl::encoding::DefaultFuchsiaResourceDialect,
648        > for &mut ConnectorEstablishCircuitRequest
649    {
650        #[inline]
651        unsafe fn encode(
652            self,
653            encoder: &mut fidl::encoding::Encoder<
654                '_,
655                fidl::encoding::DefaultFuchsiaResourceDialect,
656            >,
657            offset: usize,
658            _depth: fidl::encoding::Depth,
659        ) -> fidl::Result<()> {
660            encoder.debug_check_bounds::<ConnectorEstablishCircuitRequest>(offset);
661            // Delegate to tuple encoding.
662            fidl::encoding::Encode::<
663                ConnectorEstablishCircuitRequest,
664                fidl::encoding::DefaultFuchsiaResourceDialect,
665            >::encode(
666                (
667                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
668                    <fidl::encoding::HandleType<
669                        fidl::Socket,
670                        { fidl::ObjectType::SOCKET.into_raw() },
671                        2147483648,
672                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
673                        &mut self.socket
674                    ),
675                ),
676                encoder,
677                offset,
678                _depth,
679            )
680        }
681    }
682    unsafe impl<
683            T0: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
684            T1: fidl::encoding::Encode<
685                fidl::encoding::HandleType<
686                    fidl::Socket,
687                    { fidl::ObjectType::SOCKET.into_raw() },
688                    2147483648,
689                >,
690                fidl::encoding::DefaultFuchsiaResourceDialect,
691            >,
692        >
693        fidl::encoding::Encode<
694            ConnectorEstablishCircuitRequest,
695            fidl::encoding::DefaultFuchsiaResourceDialect,
696        > for (T0, T1)
697    {
698        #[inline]
699        unsafe fn encode(
700            self,
701            encoder: &mut fidl::encoding::Encoder<
702                '_,
703                fidl::encoding::DefaultFuchsiaResourceDialect,
704            >,
705            offset: usize,
706            depth: fidl::encoding::Depth,
707        ) -> fidl::Result<()> {
708            encoder.debug_check_bounds::<ConnectorEstablishCircuitRequest>(offset);
709            // Zero out padding regions. There's no need to apply masks
710            // because the unmasked parts will be overwritten by fields.
711            unsafe {
712                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
713                (ptr as *mut u64).write_unaligned(0);
714            }
715            // Write the fields.
716            self.0.encode(encoder, offset + 0, depth)?;
717            self.1.encode(encoder, offset + 8, depth)?;
718            Ok(())
719        }
720    }
721
722    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
723        for ConnectorEstablishCircuitRequest
724    {
725        #[inline(always)]
726        fn new_empty() -> Self {
727            Self {
728                id: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
729                socket: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
730            }
731        }
732
733        #[inline]
734        unsafe fn decode(
735            &mut self,
736            decoder: &mut fidl::encoding::Decoder<
737                '_,
738                fidl::encoding::DefaultFuchsiaResourceDialect,
739            >,
740            offset: usize,
741            _depth: fidl::encoding::Depth,
742        ) -> fidl::Result<()> {
743            decoder.debug_check_bounds::<Self>(offset);
744            // Verify that padding bytes are zero.
745            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
746            let padval = unsafe { (ptr as *const u64).read_unaligned() };
747            let mask = 0xffffffff00000000u64;
748            let maskedval = padval & mask;
749            if maskedval != 0 {
750                return Err(fidl::Error::NonZeroPadding {
751                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
752                });
753            }
754            fidl::decode!(
755                u64,
756                fidl::encoding::DefaultFuchsiaResourceDialect,
757                &mut self.id,
758                decoder,
759                offset + 0,
760                _depth
761            )?;
762            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.socket, decoder, offset + 8, _depth)?;
763            Ok(())
764        }
765    }
766
767    impl fidl::encoding::ResourceTypeMarker for ConnectorFdomainToolboxSocketRequest {
768        type Borrowed<'a> = &'a mut Self;
769        fn take_or_borrow<'a>(
770            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
771        ) -> Self::Borrowed<'a> {
772            value
773        }
774    }
775
776    unsafe impl fidl::encoding::TypeMarker for ConnectorFdomainToolboxSocketRequest {
777        type Owned = Self;
778
779        #[inline(always)]
780        fn inline_align(_context: fidl::encoding::Context) -> usize {
781            4
782        }
783
784        #[inline(always)]
785        fn inline_size(_context: fidl::encoding::Context) -> usize {
786            4
787        }
788    }
789
790    unsafe impl
791        fidl::encoding::Encode<
792            ConnectorFdomainToolboxSocketRequest,
793            fidl::encoding::DefaultFuchsiaResourceDialect,
794        > for &mut ConnectorFdomainToolboxSocketRequest
795    {
796        #[inline]
797        unsafe fn encode(
798            self,
799            encoder: &mut fidl::encoding::Encoder<
800                '_,
801                fidl::encoding::DefaultFuchsiaResourceDialect,
802            >,
803            offset: usize,
804            _depth: fidl::encoding::Depth,
805        ) -> fidl::Result<()> {
806            encoder.debug_check_bounds::<ConnectorFdomainToolboxSocketRequest>(offset);
807            // Delegate to tuple encoding.
808            fidl::encoding::Encode::<
809                ConnectorFdomainToolboxSocketRequest,
810                fidl::encoding::DefaultFuchsiaResourceDialect,
811            >::encode(
812                (<fidl::encoding::HandleType<
813                    fidl::Socket,
814                    { fidl::ObjectType::SOCKET.into_raw() },
815                    2147483648,
816                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
817                    &mut self.socket
818                ),),
819                encoder,
820                offset,
821                _depth,
822            )
823        }
824    }
825    unsafe impl<
826            T0: fidl::encoding::Encode<
827                fidl::encoding::HandleType<
828                    fidl::Socket,
829                    { fidl::ObjectType::SOCKET.into_raw() },
830                    2147483648,
831                >,
832                fidl::encoding::DefaultFuchsiaResourceDialect,
833            >,
834        >
835        fidl::encoding::Encode<
836            ConnectorFdomainToolboxSocketRequest,
837            fidl::encoding::DefaultFuchsiaResourceDialect,
838        > for (T0,)
839    {
840        #[inline]
841        unsafe fn encode(
842            self,
843            encoder: &mut fidl::encoding::Encoder<
844                '_,
845                fidl::encoding::DefaultFuchsiaResourceDialect,
846            >,
847            offset: usize,
848            depth: fidl::encoding::Depth,
849        ) -> fidl::Result<()> {
850            encoder.debug_check_bounds::<ConnectorFdomainToolboxSocketRequest>(offset);
851            // Zero out padding regions. There's no need to apply masks
852            // because the unmasked parts will be overwritten by fields.
853            // Write the fields.
854            self.0.encode(encoder, offset + 0, depth)?;
855            Ok(())
856        }
857    }
858
859    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
860        for ConnectorFdomainToolboxSocketRequest
861    {
862        #[inline(always)]
863        fn new_empty() -> Self {
864            Self {
865                socket: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
866            }
867        }
868
869        #[inline]
870        unsafe fn decode(
871            &mut self,
872            decoder: &mut fidl::encoding::Decoder<
873                '_,
874                fidl::encoding::DefaultFuchsiaResourceDialect,
875            >,
876            offset: usize,
877            _depth: fidl::encoding::Depth,
878        ) -> fidl::Result<()> {
879            decoder.debug_check_bounds::<Self>(offset);
880            // Verify that padding bytes are zero.
881            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.socket, decoder, offset + 0, _depth)?;
882            Ok(())
883        }
884    }
885}