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