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