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