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#[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    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
466        self.inner.shutdown_with_epitaph(status)
467    }
468
469    fn is_closed(&self) -> bool {
470        self.inner.channel().is_closed()
471    }
472    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
473        self.inner.channel().on_closed()
474    }
475
476    #[cfg(target_os = "fuchsia")]
477    fn signal_peer(
478        &self,
479        clear_mask: zx::Signals,
480        set_mask: zx::Signals,
481    ) -> Result<(), zx_status::Status> {
482        use fidl::Peered;
483        self.inner.channel().signal_peer(clear_mask, set_mask)
484    }
485}
486
487impl ConscriptControlHandle {}
488
489#[must_use = "FIDL methods require a response to be sent"]
490#[derive(Debug)]
491pub struct ConscriptIssueResponder {
492    control_handle: std::mem::ManuallyDrop<ConscriptControlHandle>,
493    tx_id: u32,
494}
495
496/// Set the the channel to be shutdown (see [`ConscriptControlHandle::shutdown`])
497/// if the responder is dropped without sending a response, so that the client
498/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
499impl std::ops::Drop for ConscriptIssueResponder {
500    fn drop(&mut self) {
501        self.control_handle.shutdown();
502        // Safety: drops once, never accessed again
503        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
504    }
505}
506
507impl fidl::endpoints::Responder for ConscriptIssueResponder {
508    type ControlHandle = ConscriptControlHandle;
509
510    fn control_handle(&self) -> &ConscriptControlHandle {
511        &self.control_handle
512    }
513
514    fn drop_without_shutdown(mut self) {
515        // Safety: drops once, never accessed again due to mem::forget
516        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
517        // Prevent Drop from running (which would shut down the channel)
518        std::mem::forget(self);
519    }
520}
521
522impl ConscriptIssueResponder {
523    /// Sends a response to the FIDL transaction.
524    ///
525    /// Sets the channel to shutdown if an error occurs.
526    pub fn send(self, mut response: Option<&str>) -> Result<(), fidl::Error> {
527        let _result = self.send_raw(response);
528        if _result.is_err() {
529            self.control_handle.shutdown();
530        }
531        self.drop_without_shutdown();
532        _result
533    }
534
535    /// Similar to "send" but does not shutdown the channel if an error occurs.
536    pub fn send_no_shutdown_on_err(self, mut response: Option<&str>) -> Result<(), fidl::Error> {
537        let _result = self.send_raw(response);
538        self.drop_without_shutdown();
539        _result
540    }
541
542    fn send_raw(&self, mut response: Option<&str>) -> Result<(), fidl::Error> {
543        self.control_handle.inner.send::<ConscriptIssueResponse>(
544            (response,),
545            self.tx_id,
546            0x4bcc695ef98ec8a9,
547            fidl::encoding::DynamicFlags::empty(),
548        )
549    }
550}
551
552mod internal {
553    use super::*;
554
555    impl fidl::encoding::ResourceTypeMarker for ConscriptIssueRequest {
556        type Borrowed<'a> = &'a mut Self;
557        fn take_or_borrow<'a>(
558            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
559        ) -> Self::Borrowed<'a> {
560            value
561        }
562    }
563
564    unsafe impl fidl::encoding::TypeMarker for ConscriptIssueRequest {
565        type Owned = Self;
566
567        #[inline(always)]
568        fn inline_align(_context: fidl::encoding::Context) -> usize {
569            8
570        }
571
572        #[inline(always)]
573        fn inline_size(_context: fidl::encoding::Context) -> usize {
574            24
575        }
576    }
577
578    unsafe impl
579        fidl::encoding::Encode<ConscriptIssueRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
580        for &mut ConscriptIssueRequest
581    {
582        #[inline]
583        unsafe fn encode(
584            self,
585            encoder: &mut fidl::encoding::Encoder<
586                '_,
587                fidl::encoding::DefaultFuchsiaResourceDialect,
588            >,
589            offset: usize,
590            _depth: fidl::encoding::Depth,
591        ) -> fidl::Result<()> {
592            encoder.debug_check_bounds::<ConscriptIssueRequest>(offset);
593            // Delegate to tuple encoding.
594            fidl::encoding::Encode::<ConscriptIssueRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
595                (
596                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_test_echo::EchoMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.iface),
597                    <fidl::encoding::Optional<fidl::encoding::UnboundedString> as fidl::encoding::ValueTypeMarker>::borrow(&self.request),
598                ),
599                encoder, offset, _depth
600            )
601        }
602    }
603    unsafe impl<
604            T0: fidl::encoding::Encode<
605                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_test_echo::EchoMarker>>,
606                fidl::encoding::DefaultFuchsiaResourceDialect,
607            >,
608            T1: fidl::encoding::Encode<
609                fidl::encoding::Optional<fidl::encoding::UnboundedString>,
610                fidl::encoding::DefaultFuchsiaResourceDialect,
611            >,
612        >
613        fidl::encoding::Encode<ConscriptIssueRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
614        for (T0, T1)
615    {
616        #[inline]
617        unsafe fn encode(
618            self,
619            encoder: &mut fidl::encoding::Encoder<
620                '_,
621                fidl::encoding::DefaultFuchsiaResourceDialect,
622            >,
623            offset: usize,
624            depth: fidl::encoding::Depth,
625        ) -> fidl::Result<()> {
626            encoder.debug_check_bounds::<ConscriptIssueRequest>(offset);
627            // Zero out padding regions. There's no need to apply masks
628            // because the unmasked parts will be overwritten by fields.
629            unsafe {
630                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
631                (ptr as *mut u64).write_unaligned(0);
632            }
633            // Write the fields.
634            self.0.encode(encoder, offset + 0, depth)?;
635            self.1.encode(encoder, offset + 8, depth)?;
636            Ok(())
637        }
638    }
639
640    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
641        for ConscriptIssueRequest
642    {
643        #[inline(always)]
644        fn new_empty() -> Self {
645            Self {
646                iface: fidl::new_empty!(
647                    fidl::encoding::Endpoint<
648                        fidl::endpoints::ClientEnd<fidl_test_echo::EchoMarker>,
649                    >,
650                    fidl::encoding::DefaultFuchsiaResourceDialect
651                ),
652                request: fidl::new_empty!(
653                    fidl::encoding::Optional<fidl::encoding::UnboundedString>,
654                    fidl::encoding::DefaultFuchsiaResourceDialect
655                ),
656            }
657        }
658
659        #[inline]
660        unsafe fn decode(
661            &mut self,
662            decoder: &mut fidl::encoding::Decoder<
663                '_,
664                fidl::encoding::DefaultFuchsiaResourceDialect,
665            >,
666            offset: usize,
667            _depth: fidl::encoding::Depth,
668        ) -> fidl::Result<()> {
669            decoder.debug_check_bounds::<Self>(offset);
670            // Verify that padding bytes are zero.
671            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
672            let padval = unsafe { (ptr as *const u64).read_unaligned() };
673            let mask = 0xffffffff00000000u64;
674            let maskedval = padval & mask;
675            if maskedval != 0 {
676                return Err(fidl::Error::NonZeroPadding {
677                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
678                });
679            }
680            fidl::decode!(
681                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_test_echo::EchoMarker>>,
682                fidl::encoding::DefaultFuchsiaResourceDialect,
683                &mut self.iface,
684                decoder,
685                offset + 0,
686                _depth
687            )?;
688            fidl::decode!(
689                fidl::encoding::Optional<fidl::encoding::UnboundedString>,
690                fidl::encoding::DefaultFuchsiaResourceDialect,
691                &mut self.request,
692                decoder,
693                offset + 8,
694                _depth
695            )?;
696            Ok(())
697        }
698    }
699
700    impl fidl::encoding::ResourceTypeMarker for ConscriptServeRequest {
701        type Borrowed<'a> = &'a mut Self;
702        fn take_or_borrow<'a>(
703            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
704        ) -> Self::Borrowed<'a> {
705            value
706        }
707    }
708
709    unsafe impl fidl::encoding::TypeMarker for ConscriptServeRequest {
710        type Owned = Self;
711
712        #[inline(always)]
713        fn inline_align(_context: fidl::encoding::Context) -> usize {
714            4
715        }
716
717        #[inline(always)]
718        fn inline_size(_context: fidl::encoding::Context) -> usize {
719            4
720        }
721    }
722
723    unsafe impl
724        fidl::encoding::Encode<ConscriptServeRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
725        for &mut ConscriptServeRequest
726    {
727        #[inline]
728        unsafe fn encode(
729            self,
730            encoder: &mut fidl::encoding::Encoder<
731                '_,
732                fidl::encoding::DefaultFuchsiaResourceDialect,
733            >,
734            offset: usize,
735            _depth: fidl::encoding::Depth,
736        ) -> fidl::Result<()> {
737            encoder.debug_check_bounds::<ConscriptServeRequest>(offset);
738            // Delegate to tuple encoding.
739            fidl::encoding::Encode::<
740                ConscriptServeRequest,
741                fidl::encoding::DefaultFuchsiaResourceDialect,
742            >::encode(
743                (
744                    <fidl::encoding::Endpoint<
745                        fidl::endpoints::ServerEnd<fidl_test_echo::EchoMarker>,
746                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
747                        &mut self.iface
748                    ),
749                ),
750                encoder,
751                offset,
752                _depth,
753            )
754        }
755    }
756    unsafe impl<
757            T0: fidl::encoding::Encode<
758                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<fidl_test_echo::EchoMarker>>,
759                fidl::encoding::DefaultFuchsiaResourceDialect,
760            >,
761        >
762        fidl::encoding::Encode<ConscriptServeRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
763        for (T0,)
764    {
765        #[inline]
766        unsafe fn encode(
767            self,
768            encoder: &mut fidl::encoding::Encoder<
769                '_,
770                fidl::encoding::DefaultFuchsiaResourceDialect,
771            >,
772            offset: usize,
773            depth: fidl::encoding::Depth,
774        ) -> fidl::Result<()> {
775            encoder.debug_check_bounds::<ConscriptServeRequest>(offset);
776            // Zero out padding regions. There's no need to apply masks
777            // because the unmasked parts will be overwritten by fields.
778            // Write the fields.
779            self.0.encode(encoder, offset + 0, depth)?;
780            Ok(())
781        }
782    }
783
784    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
785        for ConscriptServeRequest
786    {
787        #[inline(always)]
788        fn new_empty() -> Self {
789            Self {
790                iface: fidl::new_empty!(
791                    fidl::encoding::Endpoint<
792                        fidl::endpoints::ServerEnd<fidl_test_echo::EchoMarker>,
793                    >,
794                    fidl::encoding::DefaultFuchsiaResourceDialect
795                ),
796            }
797        }
798
799        #[inline]
800        unsafe fn decode(
801            &mut self,
802            decoder: &mut fidl::encoding::Decoder<
803                '_,
804                fidl::encoding::DefaultFuchsiaResourceDialect,
805            >,
806            offset: usize,
807            _depth: fidl::encoding::Depth,
808        ) -> fidl::Result<()> {
809            decoder.debug_check_bounds::<Self>(offset);
810            // Verify that padding bytes are zero.
811            fidl::decode!(
812                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<fidl_test_echo::EchoMarker>>,
813                fidl::encoding::DefaultFuchsiaResourceDialect,
814                &mut self.iface,
815                decoder,
816                offset + 0,
817                _depth
818            )?;
819            Ok(())
820        }
821    }
822}