Skip to main content

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