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