fidl_fuchsia_net_http/
fidl_fuchsia_net_http.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_fuchsia_net_http_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct LoaderClientOnResponseRequest {
16    pub response: Response,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20    for LoaderClientOnResponseRequest
21{
22}
23
24#[derive(Debug, PartialEq)]
25pub struct LoaderFetchRequest {
26    pub request: Request,
27}
28
29impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for LoaderFetchRequest {}
30
31#[derive(Debug, PartialEq)]
32pub struct LoaderFetchResponse {
33    pub response: Response,
34}
35
36impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for LoaderFetchResponse {}
37
38#[derive(Debug, PartialEq)]
39pub struct LoaderStartRequest {
40    pub request: Request,
41    pub client: fidl::endpoints::ClientEnd<LoaderClientMarker>,
42}
43
44impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for LoaderStartRequest {}
45
46/// An HTTP request.
47#[derive(Debug, Default, PartialEq)]
48pub struct Request {
49    /// The HTTP method if applicable.
50    ///
51    /// Defaults to "GET".
52    pub method: Option<String>,
53    /// The URL to load.
54    ///
55    /// Required.
56    pub url: Option<String>,
57    /// Additional HTTP request headers.
58    pub headers: Option<Vec<Header>>,
59    /// The payload for the request body. For HTTP requests, the method must be
60    /// set to "POST" or "PUT". If a buffer is used for the body, a
61    /// Content-Length header will automatically be added.
62    pub body: Option<Body>,
63    /// Determines when to give up on waiting for a response from the server. If no deadline is
64    /// provided, the implementation will provide a reasonable default.
65    pub deadline: Option<i64>,
66    #[doc(hidden)]
67    pub __source_breaking: fidl::marker::SourceBreaking,
68}
69
70impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for Request {}
71
72/// A response to an HTTP request.
73#[derive(Debug, Default, PartialEq)]
74pub struct Response {
75    /// If the response resulted in a network level error, this field will be
76    /// set.
77    pub error: Option<Error>,
78    /// The response body.
79    pub body: Option<fidl::Socket>,
80    /// The final URL of the response, after redirects have been followed.
81    pub final_url: Option<String>,
82    /// The HTTP status code.
83    pub status_code: Option<u32>,
84    /// The HTTP status line.
85    pub status_line: Option<Vec<u8>>,
86    /// The HTTP response headers.
87    pub headers: Option<Vec<Header>>,
88    /// A description of the redirect the server requested, if any.
89    pub redirect: Option<RedirectTarget>,
90    #[doc(hidden)]
91    pub __source_breaking: fidl::marker::SourceBreaking,
92}
93
94impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for Response {}
95
96/// The body of an HTTP request.
97#[derive(Debug, PartialEq)]
98pub enum Body {
99    /// A buffer that will contain the complete request or response body.
100    Buffer(fidl_fuchsia_mem::Buffer),
101    /// A socket that will contain the streaming request or response body.
102    Stream(fidl::Socket),
103}
104
105impl Body {
106    #[inline]
107    pub fn ordinal(&self) -> u64 {
108        match *self {
109            Self::Buffer(_) => 1,
110            Self::Stream(_) => 2,
111        }
112    }
113}
114
115impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for Body {}
116
117#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
118pub struct LoaderMarker;
119
120impl fidl::endpoints::ProtocolMarker for LoaderMarker {
121    type Proxy = LoaderProxy;
122    type RequestStream = LoaderRequestStream;
123    #[cfg(target_os = "fuchsia")]
124    type SynchronousProxy = LoaderSynchronousProxy;
125
126    const DEBUG_NAME: &'static str = "fuchsia.net.http.Loader";
127}
128impl fidl::endpoints::DiscoverableProtocolMarker for LoaderMarker {}
129
130pub trait LoaderProxyInterface: Send + Sync {
131    type FetchResponseFut: std::future::Future<Output = Result<Response, fidl::Error>> + Send;
132    fn r#fetch(&self, request: Request) -> Self::FetchResponseFut;
133    fn r#start(
134        &self,
135        request: Request,
136        client: fidl::endpoints::ClientEnd<LoaderClientMarker>,
137    ) -> Result<(), fidl::Error>;
138}
139#[derive(Debug)]
140#[cfg(target_os = "fuchsia")]
141pub struct LoaderSynchronousProxy {
142    client: fidl::client::sync::Client,
143}
144
145#[cfg(target_os = "fuchsia")]
146impl fidl::endpoints::SynchronousProxy for LoaderSynchronousProxy {
147    type Proxy = LoaderProxy;
148    type Protocol = LoaderMarker;
149
150    fn from_channel(inner: fidl::Channel) -> Self {
151        Self::new(inner)
152    }
153
154    fn into_channel(self) -> fidl::Channel {
155        self.client.into_channel()
156    }
157
158    fn as_channel(&self) -> &fidl::Channel {
159        self.client.as_channel()
160    }
161}
162
163#[cfg(target_os = "fuchsia")]
164impl LoaderSynchronousProxy {
165    pub fn new(channel: fidl::Channel) -> Self {
166        let protocol_name = <LoaderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
167        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
168    }
169
170    pub fn into_channel(self) -> fidl::Channel {
171        self.client.into_channel()
172    }
173
174    /// Waits until an event arrives and returns it. It is safe for other
175    /// threads to make concurrent requests while waiting for an event.
176    pub fn wait_for_event(
177        &self,
178        deadline: zx::MonotonicInstant,
179    ) -> Result<LoaderEvent, fidl::Error> {
180        LoaderEvent::decode(self.client.wait_for_event(deadline)?)
181    }
182
183    /// Initiate the given HTTP or HTTPS request, follow redirects, and return the final
184    /// response.
185    ///
186    /// The loader will follow redirects (up to an implementation-defined limit)
187    /// and return the final response as a reply to this message. To cancel the
188    /// request, close the loader interface.
189    pub fn r#fetch(
190        &self,
191        mut request: Request,
192        ___deadline: zx::MonotonicInstant,
193    ) -> Result<Response, fidl::Error> {
194        let _response = self.client.send_query::<LoaderFetchRequest, LoaderFetchResponse>(
195            (&mut request,),
196            0x66d973be70dc2029,
197            fidl::encoding::DynamicFlags::empty(),
198            ___deadline,
199        )?;
200        Ok(_response.response)
201    }
202
203    /// Initiate the given HTTP or HTTPS request and return all intermediate responses to
204    /// the given client.
205    ///
206    /// Unlike `Fetch`, `Start` does not automatically follow all redirects.
207    /// Instead, each individual response along the redirect chain is delivered
208    /// to the `LoaderClient`.
209    pub fn r#start(
210        &self,
211        mut request: Request,
212        mut client: fidl::endpoints::ClientEnd<LoaderClientMarker>,
213    ) -> Result<(), fidl::Error> {
214        self.client.send::<LoaderStartRequest>(
215            (&mut request, client),
216            0x7165335e1d7dd48e,
217            fidl::encoding::DynamicFlags::empty(),
218        )
219    }
220}
221
222#[cfg(target_os = "fuchsia")]
223impl From<LoaderSynchronousProxy> for zx::Handle {
224    fn from(value: LoaderSynchronousProxy) -> Self {
225        value.into_channel().into()
226    }
227}
228
229#[cfg(target_os = "fuchsia")]
230impl From<fidl::Channel> for LoaderSynchronousProxy {
231    fn from(value: fidl::Channel) -> Self {
232        Self::new(value)
233    }
234}
235
236#[derive(Debug, Clone)]
237pub struct LoaderProxy {
238    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
239}
240
241impl fidl::endpoints::Proxy for LoaderProxy {
242    type Protocol = LoaderMarker;
243
244    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
245        Self::new(inner)
246    }
247
248    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
249        self.client.into_channel().map_err(|client| Self { client })
250    }
251
252    fn as_channel(&self) -> &::fidl::AsyncChannel {
253        self.client.as_channel()
254    }
255}
256
257impl LoaderProxy {
258    /// Create a new Proxy for fuchsia.net.http/Loader.
259    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
260        let protocol_name = <LoaderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
261        Self { client: fidl::client::Client::new(channel, protocol_name) }
262    }
263
264    /// Get a Stream of events from the remote end of the protocol.
265    ///
266    /// # Panics
267    ///
268    /// Panics if the event stream was already taken.
269    pub fn take_event_stream(&self) -> LoaderEventStream {
270        LoaderEventStream { event_receiver: self.client.take_event_receiver() }
271    }
272
273    /// Initiate the given HTTP or HTTPS request, follow redirects, and return the final
274    /// response.
275    ///
276    /// The loader will follow redirects (up to an implementation-defined limit)
277    /// and return the final response as a reply to this message. To cancel the
278    /// request, close the loader interface.
279    pub fn r#fetch(
280        &self,
281        mut request: Request,
282    ) -> fidl::client::QueryResponseFut<Response, fidl::encoding::DefaultFuchsiaResourceDialect>
283    {
284        LoaderProxyInterface::r#fetch(self, request)
285    }
286
287    /// Initiate the given HTTP or HTTPS request and return all intermediate responses to
288    /// the given client.
289    ///
290    /// Unlike `Fetch`, `Start` does not automatically follow all redirects.
291    /// Instead, each individual response along the redirect chain is delivered
292    /// to the `LoaderClient`.
293    pub fn r#start(
294        &self,
295        mut request: Request,
296        mut client: fidl::endpoints::ClientEnd<LoaderClientMarker>,
297    ) -> Result<(), fidl::Error> {
298        LoaderProxyInterface::r#start(self, request, client)
299    }
300}
301
302impl LoaderProxyInterface for LoaderProxy {
303    type FetchResponseFut =
304        fidl::client::QueryResponseFut<Response, fidl::encoding::DefaultFuchsiaResourceDialect>;
305    fn r#fetch(&self, mut request: Request) -> Self::FetchResponseFut {
306        fn _decode(
307            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
308        ) -> Result<Response, fidl::Error> {
309            let _response = fidl::client::decode_transaction_body::<
310                LoaderFetchResponse,
311                fidl::encoding::DefaultFuchsiaResourceDialect,
312                0x66d973be70dc2029,
313            >(_buf?)?;
314            Ok(_response.response)
315        }
316        self.client.send_query_and_decode::<LoaderFetchRequest, Response>(
317            (&mut request,),
318            0x66d973be70dc2029,
319            fidl::encoding::DynamicFlags::empty(),
320            _decode,
321        )
322    }
323
324    fn r#start(
325        &self,
326        mut request: Request,
327        mut client: fidl::endpoints::ClientEnd<LoaderClientMarker>,
328    ) -> Result<(), fidl::Error> {
329        self.client.send::<LoaderStartRequest>(
330            (&mut request, client),
331            0x7165335e1d7dd48e,
332            fidl::encoding::DynamicFlags::empty(),
333        )
334    }
335}
336
337pub struct LoaderEventStream {
338    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
339}
340
341impl std::marker::Unpin for LoaderEventStream {}
342
343impl futures::stream::FusedStream for LoaderEventStream {
344    fn is_terminated(&self) -> bool {
345        self.event_receiver.is_terminated()
346    }
347}
348
349impl futures::Stream for LoaderEventStream {
350    type Item = Result<LoaderEvent, fidl::Error>;
351
352    fn poll_next(
353        mut self: std::pin::Pin<&mut Self>,
354        cx: &mut std::task::Context<'_>,
355    ) -> std::task::Poll<Option<Self::Item>> {
356        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
357            &mut self.event_receiver,
358            cx
359        )?) {
360            Some(buf) => std::task::Poll::Ready(Some(LoaderEvent::decode(buf))),
361            None => std::task::Poll::Ready(None),
362        }
363    }
364}
365
366#[derive(Debug)]
367pub enum LoaderEvent {}
368
369impl LoaderEvent {
370    /// Decodes a message buffer as a [`LoaderEvent`].
371    fn decode(
372        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
373    ) -> Result<LoaderEvent, fidl::Error> {
374        let (bytes, _handles) = buf.split_mut();
375        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
376        debug_assert_eq!(tx_header.tx_id, 0);
377        match tx_header.ordinal {
378            _ => Err(fidl::Error::UnknownOrdinal {
379                ordinal: tx_header.ordinal,
380                protocol_name: <LoaderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
381            }),
382        }
383    }
384}
385
386/// A Stream of incoming requests for fuchsia.net.http/Loader.
387pub struct LoaderRequestStream {
388    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
389    is_terminated: bool,
390}
391
392impl std::marker::Unpin for LoaderRequestStream {}
393
394impl futures::stream::FusedStream for LoaderRequestStream {
395    fn is_terminated(&self) -> bool {
396        self.is_terminated
397    }
398}
399
400impl fidl::endpoints::RequestStream for LoaderRequestStream {
401    type Protocol = LoaderMarker;
402    type ControlHandle = LoaderControlHandle;
403
404    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
405        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
406    }
407
408    fn control_handle(&self) -> Self::ControlHandle {
409        LoaderControlHandle { inner: self.inner.clone() }
410    }
411
412    fn into_inner(
413        self,
414    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
415    {
416        (self.inner, self.is_terminated)
417    }
418
419    fn from_inner(
420        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
421        is_terminated: bool,
422    ) -> Self {
423        Self { inner, is_terminated }
424    }
425}
426
427impl futures::Stream for LoaderRequestStream {
428    type Item = Result<LoaderRequest, fidl::Error>;
429
430    fn poll_next(
431        mut self: std::pin::Pin<&mut Self>,
432        cx: &mut std::task::Context<'_>,
433    ) -> std::task::Poll<Option<Self::Item>> {
434        let this = &mut *self;
435        if this.inner.check_shutdown(cx) {
436            this.is_terminated = true;
437            return std::task::Poll::Ready(None);
438        }
439        if this.is_terminated {
440            panic!("polled LoaderRequestStream after completion");
441        }
442        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
443            |bytes, handles| {
444                match this.inner.channel().read_etc(cx, bytes, handles) {
445                    std::task::Poll::Ready(Ok(())) => {}
446                    std::task::Poll::Pending => return std::task::Poll::Pending,
447                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
448                        this.is_terminated = true;
449                        return std::task::Poll::Ready(None);
450                    }
451                    std::task::Poll::Ready(Err(e)) => {
452                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
453                            e.into(),
454                        ))))
455                    }
456                }
457
458                // A message has been received from the channel
459                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
460
461                std::task::Poll::Ready(Some(match header.ordinal {
462                    0x66d973be70dc2029 => {
463                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
464                        let mut req = fidl::new_empty!(
465                            LoaderFetchRequest,
466                            fidl::encoding::DefaultFuchsiaResourceDialect
467                        );
468                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LoaderFetchRequest>(&header, _body_bytes, handles, &mut req)?;
469                        let control_handle = LoaderControlHandle { inner: this.inner.clone() };
470                        Ok(LoaderRequest::Fetch {
471                            request: req.request,
472
473                            responder: LoaderFetchResponder {
474                                control_handle: std::mem::ManuallyDrop::new(control_handle),
475                                tx_id: header.tx_id,
476                            },
477                        })
478                    }
479                    0x7165335e1d7dd48e => {
480                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
481                        let mut req = fidl::new_empty!(
482                            LoaderStartRequest,
483                            fidl::encoding::DefaultFuchsiaResourceDialect
484                        );
485                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LoaderStartRequest>(&header, _body_bytes, handles, &mut req)?;
486                        let control_handle = LoaderControlHandle { inner: this.inner.clone() };
487                        Ok(LoaderRequest::Start {
488                            request: req.request,
489                            client: req.client,
490
491                            control_handle,
492                        })
493                    }
494                    _ => Err(fidl::Error::UnknownOrdinal {
495                        ordinal: header.ordinal,
496                        protocol_name:
497                            <LoaderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
498                    }),
499                }))
500            },
501        )
502    }
503}
504
505/// An HTTP and HTTPS loader.
506///
507/// The loader can service many HTTP or HTTPS requests concurrently. The loader tracks
508/// all the outstanding requests and will cancel them all if the client closes
509/// the loader interface.
510#[derive(Debug)]
511pub enum LoaderRequest {
512    /// Initiate the given HTTP or HTTPS request, follow redirects, and return the final
513    /// response.
514    ///
515    /// The loader will follow redirects (up to an implementation-defined limit)
516    /// and return the final response as a reply to this message. To cancel the
517    /// request, close the loader interface.
518    Fetch { request: Request, responder: LoaderFetchResponder },
519    /// Initiate the given HTTP or HTTPS request and return all intermediate responses to
520    /// the given client.
521    ///
522    /// Unlike `Fetch`, `Start` does not automatically follow all redirects.
523    /// Instead, each individual response along the redirect chain is delivered
524    /// to the `LoaderClient`.
525    Start {
526        request: Request,
527        client: fidl::endpoints::ClientEnd<LoaderClientMarker>,
528        control_handle: LoaderControlHandle,
529    },
530}
531
532impl LoaderRequest {
533    #[allow(irrefutable_let_patterns)]
534    pub fn into_fetch(self) -> Option<(Request, LoaderFetchResponder)> {
535        if let LoaderRequest::Fetch { request, responder } = self {
536            Some((request, responder))
537        } else {
538            None
539        }
540    }
541
542    #[allow(irrefutable_let_patterns)]
543    pub fn into_start(
544        self,
545    ) -> Option<(Request, fidl::endpoints::ClientEnd<LoaderClientMarker>, LoaderControlHandle)>
546    {
547        if let LoaderRequest::Start { request, client, control_handle } = self {
548            Some((request, client, control_handle))
549        } else {
550            None
551        }
552    }
553
554    /// Name of the method defined in FIDL
555    pub fn method_name(&self) -> &'static str {
556        match *self {
557            LoaderRequest::Fetch { .. } => "fetch",
558            LoaderRequest::Start { .. } => "start",
559        }
560    }
561}
562
563#[derive(Debug, Clone)]
564pub struct LoaderControlHandle {
565    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
566}
567
568impl fidl::endpoints::ControlHandle for LoaderControlHandle {
569    fn shutdown(&self) {
570        self.inner.shutdown()
571    }
572    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
573        self.inner.shutdown_with_epitaph(status)
574    }
575
576    fn is_closed(&self) -> bool {
577        self.inner.channel().is_closed()
578    }
579    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
580        self.inner.channel().on_closed()
581    }
582
583    #[cfg(target_os = "fuchsia")]
584    fn signal_peer(
585        &self,
586        clear_mask: zx::Signals,
587        set_mask: zx::Signals,
588    ) -> Result<(), zx_status::Status> {
589        use fidl::Peered;
590        self.inner.channel().signal_peer(clear_mask, set_mask)
591    }
592}
593
594impl LoaderControlHandle {}
595
596#[must_use = "FIDL methods require a response to be sent"]
597#[derive(Debug)]
598pub struct LoaderFetchResponder {
599    control_handle: std::mem::ManuallyDrop<LoaderControlHandle>,
600    tx_id: u32,
601}
602
603/// Set the the channel to be shutdown (see [`LoaderControlHandle::shutdown`])
604/// if the responder is dropped without sending a response, so that the client
605/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
606impl std::ops::Drop for LoaderFetchResponder {
607    fn drop(&mut self) {
608        self.control_handle.shutdown();
609        // Safety: drops once, never accessed again
610        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
611    }
612}
613
614impl fidl::endpoints::Responder for LoaderFetchResponder {
615    type ControlHandle = LoaderControlHandle;
616
617    fn control_handle(&self) -> &LoaderControlHandle {
618        &self.control_handle
619    }
620
621    fn drop_without_shutdown(mut self) {
622        // Safety: drops once, never accessed again due to mem::forget
623        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
624        // Prevent Drop from running (which would shut down the channel)
625        std::mem::forget(self);
626    }
627}
628
629impl LoaderFetchResponder {
630    /// Sends a response to the FIDL transaction.
631    ///
632    /// Sets the channel to shutdown if an error occurs.
633    pub fn send(self, mut response: Response) -> Result<(), fidl::Error> {
634        let _result = self.send_raw(response);
635        if _result.is_err() {
636            self.control_handle.shutdown();
637        }
638        self.drop_without_shutdown();
639        _result
640    }
641
642    /// Similar to "send" but does not shutdown the channel if an error occurs.
643    pub fn send_no_shutdown_on_err(self, mut response: Response) -> Result<(), fidl::Error> {
644        let _result = self.send_raw(response);
645        self.drop_without_shutdown();
646        _result
647    }
648
649    fn send_raw(&self, mut response: Response) -> Result<(), fidl::Error> {
650        self.control_handle.inner.send::<LoaderFetchResponse>(
651            (&mut response,),
652            self.tx_id,
653            0x66d973be70dc2029,
654            fidl::encoding::DynamicFlags::empty(),
655        )
656    }
657}
658
659#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
660pub struct LoaderClientMarker;
661
662impl fidl::endpoints::ProtocolMarker for LoaderClientMarker {
663    type Proxy = LoaderClientProxy;
664    type RequestStream = LoaderClientRequestStream;
665    #[cfg(target_os = "fuchsia")]
666    type SynchronousProxy = LoaderClientSynchronousProxy;
667
668    const DEBUG_NAME: &'static str = "(anonymous) LoaderClient";
669}
670
671pub trait LoaderClientProxyInterface: Send + Sync {
672    type OnResponseResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
673    fn r#on_response(&self, response: Response) -> Self::OnResponseResponseFut;
674}
675#[derive(Debug)]
676#[cfg(target_os = "fuchsia")]
677pub struct LoaderClientSynchronousProxy {
678    client: fidl::client::sync::Client,
679}
680
681#[cfg(target_os = "fuchsia")]
682impl fidl::endpoints::SynchronousProxy for LoaderClientSynchronousProxy {
683    type Proxy = LoaderClientProxy;
684    type Protocol = LoaderClientMarker;
685
686    fn from_channel(inner: fidl::Channel) -> Self {
687        Self::new(inner)
688    }
689
690    fn into_channel(self) -> fidl::Channel {
691        self.client.into_channel()
692    }
693
694    fn as_channel(&self) -> &fidl::Channel {
695        self.client.as_channel()
696    }
697}
698
699#[cfg(target_os = "fuchsia")]
700impl LoaderClientSynchronousProxy {
701    pub fn new(channel: fidl::Channel) -> Self {
702        let protocol_name = <LoaderClientMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
703        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
704    }
705
706    pub fn into_channel(self) -> fidl::Channel {
707        self.client.into_channel()
708    }
709
710    /// Waits until an event arrives and returns it. It is safe for other
711    /// threads to make concurrent requests while waiting for an event.
712    pub fn wait_for_event(
713        &self,
714        deadline: zx::MonotonicInstant,
715    ) -> Result<LoaderClientEvent, fidl::Error> {
716        LoaderClientEvent::decode(self.client.wait_for_event(deadline)?)
717    }
718
719    /// Called by the loader when the loader receives an HTTP response.
720    ///
721    /// If the server has requested a redirect, then `redirect` in `response`
722    /// table will describe the target the server requested. To follow the
723    /// redirect, reply to this message. To not follow the redirect, close the
724    /// underlying channel.
725    pub fn r#on_response(
726        &self,
727        mut response: Response,
728        ___deadline: zx::MonotonicInstant,
729    ) -> Result<(), fidl::Error> {
730        let _response =
731            self.client.send_query::<LoaderClientOnResponseRequest, fidl::encoding::EmptyPayload>(
732                (&mut response,),
733                0x595ada171c7ebf89,
734                fidl::encoding::DynamicFlags::empty(),
735                ___deadline,
736            )?;
737        Ok(_response)
738    }
739}
740
741#[cfg(target_os = "fuchsia")]
742impl From<LoaderClientSynchronousProxy> for zx::Handle {
743    fn from(value: LoaderClientSynchronousProxy) -> Self {
744        value.into_channel().into()
745    }
746}
747
748#[cfg(target_os = "fuchsia")]
749impl From<fidl::Channel> for LoaderClientSynchronousProxy {
750    fn from(value: fidl::Channel) -> Self {
751        Self::new(value)
752    }
753}
754
755#[derive(Debug, Clone)]
756pub struct LoaderClientProxy {
757    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
758}
759
760impl fidl::endpoints::Proxy for LoaderClientProxy {
761    type Protocol = LoaderClientMarker;
762
763    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
764        Self::new(inner)
765    }
766
767    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
768        self.client.into_channel().map_err(|client| Self { client })
769    }
770
771    fn as_channel(&self) -> &::fidl::AsyncChannel {
772        self.client.as_channel()
773    }
774}
775
776impl LoaderClientProxy {
777    /// Create a new Proxy for fuchsia.net.http/LoaderClient.
778    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
779        let protocol_name = <LoaderClientMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
780        Self { client: fidl::client::Client::new(channel, protocol_name) }
781    }
782
783    /// Get a Stream of events from the remote end of the protocol.
784    ///
785    /// # Panics
786    ///
787    /// Panics if the event stream was already taken.
788    pub fn take_event_stream(&self) -> LoaderClientEventStream {
789        LoaderClientEventStream { event_receiver: self.client.take_event_receiver() }
790    }
791
792    /// Called by the loader when the loader receives an HTTP response.
793    ///
794    /// If the server has requested a redirect, then `redirect` in `response`
795    /// table will describe the target the server requested. To follow the
796    /// redirect, reply to this message. To not follow the redirect, close the
797    /// underlying channel.
798    pub fn r#on_response(
799        &self,
800        mut response: Response,
801    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
802        LoaderClientProxyInterface::r#on_response(self, response)
803    }
804}
805
806impl LoaderClientProxyInterface for LoaderClientProxy {
807    type OnResponseResponseFut =
808        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
809    fn r#on_response(&self, mut response: Response) -> Self::OnResponseResponseFut {
810        fn _decode(
811            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
812        ) -> Result<(), fidl::Error> {
813            let _response = fidl::client::decode_transaction_body::<
814                fidl::encoding::EmptyPayload,
815                fidl::encoding::DefaultFuchsiaResourceDialect,
816                0x595ada171c7ebf89,
817            >(_buf?)?;
818            Ok(_response)
819        }
820        self.client.send_query_and_decode::<LoaderClientOnResponseRequest, ()>(
821            (&mut response,),
822            0x595ada171c7ebf89,
823            fidl::encoding::DynamicFlags::empty(),
824            _decode,
825        )
826    }
827}
828
829pub struct LoaderClientEventStream {
830    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
831}
832
833impl std::marker::Unpin for LoaderClientEventStream {}
834
835impl futures::stream::FusedStream for LoaderClientEventStream {
836    fn is_terminated(&self) -> bool {
837        self.event_receiver.is_terminated()
838    }
839}
840
841impl futures::Stream for LoaderClientEventStream {
842    type Item = Result<LoaderClientEvent, fidl::Error>;
843
844    fn poll_next(
845        mut self: std::pin::Pin<&mut Self>,
846        cx: &mut std::task::Context<'_>,
847    ) -> std::task::Poll<Option<Self::Item>> {
848        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
849            &mut self.event_receiver,
850            cx
851        )?) {
852            Some(buf) => std::task::Poll::Ready(Some(LoaderClientEvent::decode(buf))),
853            None => std::task::Poll::Ready(None),
854        }
855    }
856}
857
858#[derive(Debug)]
859pub enum LoaderClientEvent {}
860
861impl LoaderClientEvent {
862    /// Decodes a message buffer as a [`LoaderClientEvent`].
863    fn decode(
864        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
865    ) -> Result<LoaderClientEvent, fidl::Error> {
866        let (bytes, _handles) = buf.split_mut();
867        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
868        debug_assert_eq!(tx_header.tx_id, 0);
869        match tx_header.ordinal {
870            _ => Err(fidl::Error::UnknownOrdinal {
871                ordinal: tx_header.ordinal,
872                protocol_name: <LoaderClientMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
873            }),
874        }
875    }
876}
877
878/// A Stream of incoming requests for fuchsia.net.http/LoaderClient.
879pub struct LoaderClientRequestStream {
880    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
881    is_terminated: bool,
882}
883
884impl std::marker::Unpin for LoaderClientRequestStream {}
885
886impl futures::stream::FusedStream for LoaderClientRequestStream {
887    fn is_terminated(&self) -> bool {
888        self.is_terminated
889    }
890}
891
892impl fidl::endpoints::RequestStream for LoaderClientRequestStream {
893    type Protocol = LoaderClientMarker;
894    type ControlHandle = LoaderClientControlHandle;
895
896    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
897        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
898    }
899
900    fn control_handle(&self) -> Self::ControlHandle {
901        LoaderClientControlHandle { inner: self.inner.clone() }
902    }
903
904    fn into_inner(
905        self,
906    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
907    {
908        (self.inner, self.is_terminated)
909    }
910
911    fn from_inner(
912        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
913        is_terminated: bool,
914    ) -> Self {
915        Self { inner, is_terminated }
916    }
917}
918
919impl futures::Stream for LoaderClientRequestStream {
920    type Item = Result<LoaderClientRequest, fidl::Error>;
921
922    fn poll_next(
923        mut self: std::pin::Pin<&mut Self>,
924        cx: &mut std::task::Context<'_>,
925    ) -> std::task::Poll<Option<Self::Item>> {
926        let this = &mut *self;
927        if this.inner.check_shutdown(cx) {
928            this.is_terminated = true;
929            return std::task::Poll::Ready(None);
930        }
931        if this.is_terminated {
932            panic!("polled LoaderClientRequestStream after completion");
933        }
934        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
935            |bytes, handles| {
936                match this.inner.channel().read_etc(cx, bytes, handles) {
937                    std::task::Poll::Ready(Ok(())) => {}
938                    std::task::Poll::Pending => return std::task::Poll::Pending,
939                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
940                        this.is_terminated = true;
941                        return std::task::Poll::Ready(None);
942                    }
943                    std::task::Poll::Ready(Err(e)) => {
944                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
945                            e.into(),
946                        ))))
947                    }
948                }
949
950                // A message has been received from the channel
951                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
952
953                std::task::Poll::Ready(Some(match header.ordinal {
954                    0x595ada171c7ebf89 => {
955                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
956                        let mut req = fidl::new_empty!(
957                            LoaderClientOnResponseRequest,
958                            fidl::encoding::DefaultFuchsiaResourceDialect
959                        );
960                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LoaderClientOnResponseRequest>(&header, _body_bytes, handles, &mut req)?;
961                        let control_handle =
962                            LoaderClientControlHandle { inner: this.inner.clone() };
963                        Ok(LoaderClientRequest::OnResponse {
964                            response: req.response,
965
966                            responder: LoaderClientOnResponseResponder {
967                                control_handle: std::mem::ManuallyDrop::new(control_handle),
968                                tx_id: header.tx_id,
969                            },
970                        })
971                    }
972                    _ => Err(fidl::Error::UnknownOrdinal {
973                        ordinal: header.ordinal,
974                        protocol_name:
975                            <LoaderClientMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
976                    }),
977                }))
978            },
979        )
980    }
981}
982
983/// A client interface used with `Loader.Start`.
984///
985/// Closing the underlying channel will cancel the associated HTTP transaction.
986#[derive(Debug)]
987pub enum LoaderClientRequest {
988    /// Called by the loader when the loader receives an HTTP response.
989    ///
990    /// If the server has requested a redirect, then `redirect` in `response`
991    /// table will describe the target the server requested. To follow the
992    /// redirect, reply to this message. To not follow the redirect, close the
993    /// underlying channel.
994    OnResponse { response: Response, responder: LoaderClientOnResponseResponder },
995}
996
997impl LoaderClientRequest {
998    #[allow(irrefutable_let_patterns)]
999    pub fn into_on_response(self) -> Option<(Response, LoaderClientOnResponseResponder)> {
1000        if let LoaderClientRequest::OnResponse { response, responder } = self {
1001            Some((response, responder))
1002        } else {
1003            None
1004        }
1005    }
1006
1007    /// Name of the method defined in FIDL
1008    pub fn method_name(&self) -> &'static str {
1009        match *self {
1010            LoaderClientRequest::OnResponse { .. } => "on_response",
1011        }
1012    }
1013}
1014
1015#[derive(Debug, Clone)]
1016pub struct LoaderClientControlHandle {
1017    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1018}
1019
1020impl fidl::endpoints::ControlHandle for LoaderClientControlHandle {
1021    fn shutdown(&self) {
1022        self.inner.shutdown()
1023    }
1024    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1025        self.inner.shutdown_with_epitaph(status)
1026    }
1027
1028    fn is_closed(&self) -> bool {
1029        self.inner.channel().is_closed()
1030    }
1031    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1032        self.inner.channel().on_closed()
1033    }
1034
1035    #[cfg(target_os = "fuchsia")]
1036    fn signal_peer(
1037        &self,
1038        clear_mask: zx::Signals,
1039        set_mask: zx::Signals,
1040    ) -> Result<(), zx_status::Status> {
1041        use fidl::Peered;
1042        self.inner.channel().signal_peer(clear_mask, set_mask)
1043    }
1044}
1045
1046impl LoaderClientControlHandle {}
1047
1048#[must_use = "FIDL methods require a response to be sent"]
1049#[derive(Debug)]
1050pub struct LoaderClientOnResponseResponder {
1051    control_handle: std::mem::ManuallyDrop<LoaderClientControlHandle>,
1052    tx_id: u32,
1053}
1054
1055/// Set the the channel to be shutdown (see [`LoaderClientControlHandle::shutdown`])
1056/// if the responder is dropped without sending a response, so that the client
1057/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1058impl std::ops::Drop for LoaderClientOnResponseResponder {
1059    fn drop(&mut self) {
1060        self.control_handle.shutdown();
1061        // Safety: drops once, never accessed again
1062        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1063    }
1064}
1065
1066impl fidl::endpoints::Responder for LoaderClientOnResponseResponder {
1067    type ControlHandle = LoaderClientControlHandle;
1068
1069    fn control_handle(&self) -> &LoaderClientControlHandle {
1070        &self.control_handle
1071    }
1072
1073    fn drop_without_shutdown(mut self) {
1074        // Safety: drops once, never accessed again due to mem::forget
1075        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1076        // Prevent Drop from running (which would shut down the channel)
1077        std::mem::forget(self);
1078    }
1079}
1080
1081impl LoaderClientOnResponseResponder {
1082    /// Sends a response to the FIDL transaction.
1083    ///
1084    /// Sets the channel to shutdown if an error occurs.
1085    pub fn send(self) -> Result<(), fidl::Error> {
1086        let _result = self.send_raw();
1087        if _result.is_err() {
1088            self.control_handle.shutdown();
1089        }
1090        self.drop_without_shutdown();
1091        _result
1092    }
1093
1094    /// Similar to "send" but does not shutdown the channel if an error occurs.
1095    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1096        let _result = self.send_raw();
1097        self.drop_without_shutdown();
1098        _result
1099    }
1100
1101    fn send_raw(&self) -> Result<(), fidl::Error> {
1102        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1103            (),
1104            self.tx_id,
1105            0x595ada171c7ebf89,
1106            fidl::encoding::DynamicFlags::empty(),
1107        )
1108    }
1109}
1110
1111mod internal {
1112    use super::*;
1113
1114    impl fidl::encoding::ResourceTypeMarker for LoaderClientOnResponseRequest {
1115        type Borrowed<'a> = &'a mut Self;
1116        fn take_or_borrow<'a>(
1117            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1118        ) -> Self::Borrowed<'a> {
1119            value
1120        }
1121    }
1122
1123    unsafe impl fidl::encoding::TypeMarker for LoaderClientOnResponseRequest {
1124        type Owned = Self;
1125
1126        #[inline(always)]
1127        fn inline_align(_context: fidl::encoding::Context) -> usize {
1128            8
1129        }
1130
1131        #[inline(always)]
1132        fn inline_size(_context: fidl::encoding::Context) -> usize {
1133            16
1134        }
1135    }
1136
1137    unsafe impl
1138        fidl::encoding::Encode<
1139            LoaderClientOnResponseRequest,
1140            fidl::encoding::DefaultFuchsiaResourceDialect,
1141        > for &mut LoaderClientOnResponseRequest
1142    {
1143        #[inline]
1144        unsafe fn encode(
1145            self,
1146            encoder: &mut fidl::encoding::Encoder<
1147                '_,
1148                fidl::encoding::DefaultFuchsiaResourceDialect,
1149            >,
1150            offset: usize,
1151            _depth: fidl::encoding::Depth,
1152        ) -> fidl::Result<()> {
1153            encoder.debug_check_bounds::<LoaderClientOnResponseRequest>(offset);
1154            // Delegate to tuple encoding.
1155            fidl::encoding::Encode::<
1156                LoaderClientOnResponseRequest,
1157                fidl::encoding::DefaultFuchsiaResourceDialect,
1158            >::encode(
1159                (<Response as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1160                    &mut self.response,
1161                ),),
1162                encoder,
1163                offset,
1164                _depth,
1165            )
1166        }
1167    }
1168    unsafe impl<T0: fidl::encoding::Encode<Response, fidl::encoding::DefaultFuchsiaResourceDialect>>
1169        fidl::encoding::Encode<
1170            LoaderClientOnResponseRequest,
1171            fidl::encoding::DefaultFuchsiaResourceDialect,
1172        > for (T0,)
1173    {
1174        #[inline]
1175        unsafe fn encode(
1176            self,
1177            encoder: &mut fidl::encoding::Encoder<
1178                '_,
1179                fidl::encoding::DefaultFuchsiaResourceDialect,
1180            >,
1181            offset: usize,
1182            depth: fidl::encoding::Depth,
1183        ) -> fidl::Result<()> {
1184            encoder.debug_check_bounds::<LoaderClientOnResponseRequest>(offset);
1185            // Zero out padding regions. There's no need to apply masks
1186            // because the unmasked parts will be overwritten by fields.
1187            // Write the fields.
1188            self.0.encode(encoder, offset + 0, depth)?;
1189            Ok(())
1190        }
1191    }
1192
1193    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1194        for LoaderClientOnResponseRequest
1195    {
1196        #[inline(always)]
1197        fn new_empty() -> Self {
1198            Self {
1199                response: fidl::new_empty!(Response, fidl::encoding::DefaultFuchsiaResourceDialect),
1200            }
1201        }
1202
1203        #[inline]
1204        unsafe fn decode(
1205            &mut self,
1206            decoder: &mut fidl::encoding::Decoder<
1207                '_,
1208                fidl::encoding::DefaultFuchsiaResourceDialect,
1209            >,
1210            offset: usize,
1211            _depth: fidl::encoding::Depth,
1212        ) -> fidl::Result<()> {
1213            decoder.debug_check_bounds::<Self>(offset);
1214            // Verify that padding bytes are zero.
1215            fidl::decode!(
1216                Response,
1217                fidl::encoding::DefaultFuchsiaResourceDialect,
1218                &mut self.response,
1219                decoder,
1220                offset + 0,
1221                _depth
1222            )?;
1223            Ok(())
1224        }
1225    }
1226
1227    impl fidl::encoding::ResourceTypeMarker for LoaderFetchRequest {
1228        type Borrowed<'a> = &'a mut Self;
1229        fn take_or_borrow<'a>(
1230            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1231        ) -> Self::Borrowed<'a> {
1232            value
1233        }
1234    }
1235
1236    unsafe impl fidl::encoding::TypeMarker for LoaderFetchRequest {
1237        type Owned = Self;
1238
1239        #[inline(always)]
1240        fn inline_align(_context: fidl::encoding::Context) -> usize {
1241            8
1242        }
1243
1244        #[inline(always)]
1245        fn inline_size(_context: fidl::encoding::Context) -> usize {
1246            16
1247        }
1248    }
1249
1250    unsafe impl
1251        fidl::encoding::Encode<LoaderFetchRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
1252        for &mut LoaderFetchRequest
1253    {
1254        #[inline]
1255        unsafe fn encode(
1256            self,
1257            encoder: &mut fidl::encoding::Encoder<
1258                '_,
1259                fidl::encoding::DefaultFuchsiaResourceDialect,
1260            >,
1261            offset: usize,
1262            _depth: fidl::encoding::Depth,
1263        ) -> fidl::Result<()> {
1264            encoder.debug_check_bounds::<LoaderFetchRequest>(offset);
1265            // Delegate to tuple encoding.
1266            fidl::encoding::Encode::<
1267                LoaderFetchRequest,
1268                fidl::encoding::DefaultFuchsiaResourceDialect,
1269            >::encode(
1270                (<Request as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1271                    &mut self.request,
1272                ),),
1273                encoder,
1274                offset,
1275                _depth,
1276            )
1277        }
1278    }
1279    unsafe impl<T0: fidl::encoding::Encode<Request, fidl::encoding::DefaultFuchsiaResourceDialect>>
1280        fidl::encoding::Encode<LoaderFetchRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
1281        for (T0,)
1282    {
1283        #[inline]
1284        unsafe fn encode(
1285            self,
1286            encoder: &mut fidl::encoding::Encoder<
1287                '_,
1288                fidl::encoding::DefaultFuchsiaResourceDialect,
1289            >,
1290            offset: usize,
1291            depth: fidl::encoding::Depth,
1292        ) -> fidl::Result<()> {
1293            encoder.debug_check_bounds::<LoaderFetchRequest>(offset);
1294            // Zero out padding regions. There's no need to apply masks
1295            // because the unmasked parts will be overwritten by fields.
1296            // Write the fields.
1297            self.0.encode(encoder, offset + 0, depth)?;
1298            Ok(())
1299        }
1300    }
1301
1302    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1303        for LoaderFetchRequest
1304    {
1305        #[inline(always)]
1306        fn new_empty() -> Self {
1307            Self {
1308                request: fidl::new_empty!(Request, fidl::encoding::DefaultFuchsiaResourceDialect),
1309            }
1310        }
1311
1312        #[inline]
1313        unsafe fn decode(
1314            &mut self,
1315            decoder: &mut fidl::encoding::Decoder<
1316                '_,
1317                fidl::encoding::DefaultFuchsiaResourceDialect,
1318            >,
1319            offset: usize,
1320            _depth: fidl::encoding::Depth,
1321        ) -> fidl::Result<()> {
1322            decoder.debug_check_bounds::<Self>(offset);
1323            // Verify that padding bytes are zero.
1324            fidl::decode!(
1325                Request,
1326                fidl::encoding::DefaultFuchsiaResourceDialect,
1327                &mut self.request,
1328                decoder,
1329                offset + 0,
1330                _depth
1331            )?;
1332            Ok(())
1333        }
1334    }
1335
1336    impl fidl::encoding::ResourceTypeMarker for LoaderFetchResponse {
1337        type Borrowed<'a> = &'a mut Self;
1338        fn take_or_borrow<'a>(
1339            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1340        ) -> Self::Borrowed<'a> {
1341            value
1342        }
1343    }
1344
1345    unsafe impl fidl::encoding::TypeMarker for LoaderFetchResponse {
1346        type Owned = Self;
1347
1348        #[inline(always)]
1349        fn inline_align(_context: fidl::encoding::Context) -> usize {
1350            8
1351        }
1352
1353        #[inline(always)]
1354        fn inline_size(_context: fidl::encoding::Context) -> usize {
1355            16
1356        }
1357    }
1358
1359    unsafe impl
1360        fidl::encoding::Encode<LoaderFetchResponse, fidl::encoding::DefaultFuchsiaResourceDialect>
1361        for &mut LoaderFetchResponse
1362    {
1363        #[inline]
1364        unsafe fn encode(
1365            self,
1366            encoder: &mut fidl::encoding::Encoder<
1367                '_,
1368                fidl::encoding::DefaultFuchsiaResourceDialect,
1369            >,
1370            offset: usize,
1371            _depth: fidl::encoding::Depth,
1372        ) -> fidl::Result<()> {
1373            encoder.debug_check_bounds::<LoaderFetchResponse>(offset);
1374            // Delegate to tuple encoding.
1375            fidl::encoding::Encode::<
1376                LoaderFetchResponse,
1377                fidl::encoding::DefaultFuchsiaResourceDialect,
1378            >::encode(
1379                (<Response as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1380                    &mut self.response,
1381                ),),
1382                encoder,
1383                offset,
1384                _depth,
1385            )
1386        }
1387    }
1388    unsafe impl<T0: fidl::encoding::Encode<Response, fidl::encoding::DefaultFuchsiaResourceDialect>>
1389        fidl::encoding::Encode<LoaderFetchResponse, fidl::encoding::DefaultFuchsiaResourceDialect>
1390        for (T0,)
1391    {
1392        #[inline]
1393        unsafe fn encode(
1394            self,
1395            encoder: &mut fidl::encoding::Encoder<
1396                '_,
1397                fidl::encoding::DefaultFuchsiaResourceDialect,
1398            >,
1399            offset: usize,
1400            depth: fidl::encoding::Depth,
1401        ) -> fidl::Result<()> {
1402            encoder.debug_check_bounds::<LoaderFetchResponse>(offset);
1403            // Zero out padding regions. There's no need to apply masks
1404            // because the unmasked parts will be overwritten by fields.
1405            // Write the fields.
1406            self.0.encode(encoder, offset + 0, depth)?;
1407            Ok(())
1408        }
1409    }
1410
1411    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1412        for LoaderFetchResponse
1413    {
1414        #[inline(always)]
1415        fn new_empty() -> Self {
1416            Self {
1417                response: fidl::new_empty!(Response, fidl::encoding::DefaultFuchsiaResourceDialect),
1418            }
1419        }
1420
1421        #[inline]
1422        unsafe fn decode(
1423            &mut self,
1424            decoder: &mut fidl::encoding::Decoder<
1425                '_,
1426                fidl::encoding::DefaultFuchsiaResourceDialect,
1427            >,
1428            offset: usize,
1429            _depth: fidl::encoding::Depth,
1430        ) -> fidl::Result<()> {
1431            decoder.debug_check_bounds::<Self>(offset);
1432            // Verify that padding bytes are zero.
1433            fidl::decode!(
1434                Response,
1435                fidl::encoding::DefaultFuchsiaResourceDialect,
1436                &mut self.response,
1437                decoder,
1438                offset + 0,
1439                _depth
1440            )?;
1441            Ok(())
1442        }
1443    }
1444
1445    impl fidl::encoding::ResourceTypeMarker for LoaderStartRequest {
1446        type Borrowed<'a> = &'a mut Self;
1447        fn take_or_borrow<'a>(
1448            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1449        ) -> Self::Borrowed<'a> {
1450            value
1451        }
1452    }
1453
1454    unsafe impl fidl::encoding::TypeMarker for LoaderStartRequest {
1455        type Owned = Self;
1456
1457        #[inline(always)]
1458        fn inline_align(_context: fidl::encoding::Context) -> usize {
1459            8
1460        }
1461
1462        #[inline(always)]
1463        fn inline_size(_context: fidl::encoding::Context) -> usize {
1464            24
1465        }
1466    }
1467
1468    unsafe impl
1469        fidl::encoding::Encode<LoaderStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
1470        for &mut LoaderStartRequest
1471    {
1472        #[inline]
1473        unsafe fn encode(
1474            self,
1475            encoder: &mut fidl::encoding::Encoder<
1476                '_,
1477                fidl::encoding::DefaultFuchsiaResourceDialect,
1478            >,
1479            offset: usize,
1480            _depth: fidl::encoding::Depth,
1481        ) -> fidl::Result<()> {
1482            encoder.debug_check_bounds::<LoaderStartRequest>(offset);
1483            // Delegate to tuple encoding.
1484            fidl::encoding::Encode::<LoaderStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1485                (
1486                    <Request as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.request),
1487                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<LoaderClientMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.client),
1488                ),
1489                encoder, offset, _depth
1490            )
1491        }
1492    }
1493    unsafe impl<
1494            T0: fidl::encoding::Encode<Request, fidl::encoding::DefaultFuchsiaResourceDialect>,
1495            T1: fidl::encoding::Encode<
1496                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<LoaderClientMarker>>,
1497                fidl::encoding::DefaultFuchsiaResourceDialect,
1498            >,
1499        >
1500        fidl::encoding::Encode<LoaderStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
1501        for (T0, T1)
1502    {
1503        #[inline]
1504        unsafe fn encode(
1505            self,
1506            encoder: &mut fidl::encoding::Encoder<
1507                '_,
1508                fidl::encoding::DefaultFuchsiaResourceDialect,
1509            >,
1510            offset: usize,
1511            depth: fidl::encoding::Depth,
1512        ) -> fidl::Result<()> {
1513            encoder.debug_check_bounds::<LoaderStartRequest>(offset);
1514            // Zero out padding regions. There's no need to apply masks
1515            // because the unmasked parts will be overwritten by fields.
1516            unsafe {
1517                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
1518                (ptr as *mut u64).write_unaligned(0);
1519            }
1520            // Write the fields.
1521            self.0.encode(encoder, offset + 0, depth)?;
1522            self.1.encode(encoder, offset + 16, depth)?;
1523            Ok(())
1524        }
1525    }
1526
1527    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1528        for LoaderStartRequest
1529    {
1530        #[inline(always)]
1531        fn new_empty() -> Self {
1532            Self {
1533                request: fidl::new_empty!(Request, fidl::encoding::DefaultFuchsiaResourceDialect),
1534                client: fidl::new_empty!(
1535                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<LoaderClientMarker>>,
1536                    fidl::encoding::DefaultFuchsiaResourceDialect
1537                ),
1538            }
1539        }
1540
1541        #[inline]
1542        unsafe fn decode(
1543            &mut self,
1544            decoder: &mut fidl::encoding::Decoder<
1545                '_,
1546                fidl::encoding::DefaultFuchsiaResourceDialect,
1547            >,
1548            offset: usize,
1549            _depth: fidl::encoding::Depth,
1550        ) -> fidl::Result<()> {
1551            decoder.debug_check_bounds::<Self>(offset);
1552            // Verify that padding bytes are zero.
1553            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1554            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1555            let mask = 0xffffffff00000000u64;
1556            let maskedval = padval & mask;
1557            if maskedval != 0 {
1558                return Err(fidl::Error::NonZeroPadding {
1559                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1560                });
1561            }
1562            fidl::decode!(
1563                Request,
1564                fidl::encoding::DefaultFuchsiaResourceDialect,
1565                &mut self.request,
1566                decoder,
1567                offset + 0,
1568                _depth
1569            )?;
1570            fidl::decode!(
1571                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<LoaderClientMarker>>,
1572                fidl::encoding::DefaultFuchsiaResourceDialect,
1573                &mut self.client,
1574                decoder,
1575                offset + 16,
1576                _depth
1577            )?;
1578            Ok(())
1579        }
1580    }
1581
1582    impl Request {
1583        #[inline(always)]
1584        fn max_ordinal_present(&self) -> u64 {
1585            if let Some(_) = self.deadline {
1586                return 5;
1587            }
1588            if let Some(_) = self.body {
1589                return 4;
1590            }
1591            if let Some(_) = self.headers {
1592                return 3;
1593            }
1594            if let Some(_) = self.url {
1595                return 2;
1596            }
1597            if let Some(_) = self.method {
1598                return 1;
1599            }
1600            0
1601        }
1602    }
1603
1604    impl fidl::encoding::ResourceTypeMarker for Request {
1605        type Borrowed<'a> = &'a mut Self;
1606        fn take_or_borrow<'a>(
1607            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1608        ) -> Self::Borrowed<'a> {
1609            value
1610        }
1611    }
1612
1613    unsafe impl fidl::encoding::TypeMarker for Request {
1614        type Owned = Self;
1615
1616        #[inline(always)]
1617        fn inline_align(_context: fidl::encoding::Context) -> usize {
1618            8
1619        }
1620
1621        #[inline(always)]
1622        fn inline_size(_context: fidl::encoding::Context) -> usize {
1623            16
1624        }
1625    }
1626
1627    unsafe impl fidl::encoding::Encode<Request, fidl::encoding::DefaultFuchsiaResourceDialect>
1628        for &mut Request
1629    {
1630        unsafe fn encode(
1631            self,
1632            encoder: &mut fidl::encoding::Encoder<
1633                '_,
1634                fidl::encoding::DefaultFuchsiaResourceDialect,
1635            >,
1636            offset: usize,
1637            mut depth: fidl::encoding::Depth,
1638        ) -> fidl::Result<()> {
1639            encoder.debug_check_bounds::<Request>(offset);
1640            // Vector header
1641            let max_ordinal: u64 = self.max_ordinal_present();
1642            encoder.write_num(max_ordinal, offset);
1643            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1644            // Calling encoder.out_of_line_offset(0) is not allowed.
1645            if max_ordinal == 0 {
1646                return Ok(());
1647            }
1648            depth.increment()?;
1649            let envelope_size = 8;
1650            let bytes_len = max_ordinal as usize * envelope_size;
1651            #[allow(unused_variables)]
1652            let offset = encoder.out_of_line_offset(bytes_len);
1653            let mut _prev_end_offset: usize = 0;
1654            if 1 > max_ordinal {
1655                return Ok(());
1656            }
1657
1658            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1659            // are envelope_size bytes.
1660            let cur_offset: usize = (1 - 1) * envelope_size;
1661
1662            // Zero reserved fields.
1663            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1664
1665            // Safety:
1666            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1667            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1668            //   envelope_size bytes, there is always sufficient room.
1669            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<1024>, fidl::encoding::DefaultFuchsiaResourceDialect>(
1670            self.method.as_ref().map(<fidl::encoding::BoundedString<1024> as fidl::encoding::ValueTypeMarker>::borrow),
1671            encoder, offset + cur_offset, depth
1672        )?;
1673
1674            _prev_end_offset = cur_offset + envelope_size;
1675            if 2 > max_ordinal {
1676                return Ok(());
1677            }
1678
1679            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1680            // are envelope_size bytes.
1681            let cur_offset: usize = (2 - 1) * envelope_size;
1682
1683            // Zero reserved fields.
1684            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1685
1686            // Safety:
1687            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1688            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1689            //   envelope_size bytes, there is always sufficient room.
1690            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<4096>, fidl::encoding::DefaultFuchsiaResourceDialect>(
1691            self.url.as_ref().map(<fidl::encoding::BoundedString<4096> as fidl::encoding::ValueTypeMarker>::borrow),
1692            encoder, offset + cur_offset, depth
1693        )?;
1694
1695            _prev_end_offset = cur_offset + envelope_size;
1696            if 3 > max_ordinal {
1697                return Ok(());
1698            }
1699
1700            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1701            // are envelope_size bytes.
1702            let cur_offset: usize = (3 - 1) * envelope_size;
1703
1704            // Zero reserved fields.
1705            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1706
1707            // Safety:
1708            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1709            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1710            //   envelope_size bytes, there is always sufficient room.
1711            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<Header>, fidl::encoding::DefaultFuchsiaResourceDialect>(
1712            self.headers.as_ref().map(<fidl::encoding::UnboundedVector<Header> as fidl::encoding::ValueTypeMarker>::borrow),
1713            encoder, offset + cur_offset, depth
1714        )?;
1715
1716            _prev_end_offset = cur_offset + envelope_size;
1717            if 4 > max_ordinal {
1718                return Ok(());
1719            }
1720
1721            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1722            // are envelope_size bytes.
1723            let cur_offset: usize = (4 - 1) * envelope_size;
1724
1725            // Zero reserved fields.
1726            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1727
1728            // Safety:
1729            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1730            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1731            //   envelope_size bytes, there is always sufficient room.
1732            fidl::encoding::encode_in_envelope_optional::<
1733                Body,
1734                fidl::encoding::DefaultFuchsiaResourceDialect,
1735            >(
1736                self.body
1737                    .as_mut()
1738                    .map(<Body as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
1739                encoder,
1740                offset + cur_offset,
1741                depth,
1742            )?;
1743
1744            _prev_end_offset = cur_offset + envelope_size;
1745            if 5 > max_ordinal {
1746                return Ok(());
1747            }
1748
1749            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1750            // are envelope_size bytes.
1751            let cur_offset: usize = (5 - 1) * envelope_size;
1752
1753            // Zero reserved fields.
1754            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1755
1756            // Safety:
1757            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1758            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1759            //   envelope_size bytes, there is always sufficient room.
1760            fidl::encoding::encode_in_envelope_optional::<
1761                i64,
1762                fidl::encoding::DefaultFuchsiaResourceDialect,
1763            >(
1764                self.deadline.as_ref().map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
1765                encoder,
1766                offset + cur_offset,
1767                depth,
1768            )?;
1769
1770            _prev_end_offset = cur_offset + envelope_size;
1771
1772            Ok(())
1773        }
1774    }
1775
1776    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Request {
1777        #[inline(always)]
1778        fn new_empty() -> Self {
1779            Self::default()
1780        }
1781
1782        unsafe fn decode(
1783            &mut self,
1784            decoder: &mut fidl::encoding::Decoder<
1785                '_,
1786                fidl::encoding::DefaultFuchsiaResourceDialect,
1787            >,
1788            offset: usize,
1789            mut depth: fidl::encoding::Depth,
1790        ) -> fidl::Result<()> {
1791            decoder.debug_check_bounds::<Self>(offset);
1792            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1793                None => return Err(fidl::Error::NotNullable),
1794                Some(len) => len,
1795            };
1796            // Calling decoder.out_of_line_offset(0) is not allowed.
1797            if len == 0 {
1798                return Ok(());
1799            };
1800            depth.increment()?;
1801            let envelope_size = 8;
1802            let bytes_len = len * envelope_size;
1803            let offset = decoder.out_of_line_offset(bytes_len)?;
1804            // Decode the envelope for each type.
1805            let mut _next_ordinal_to_read = 0;
1806            let mut next_offset = offset;
1807            let end_offset = offset + bytes_len;
1808            _next_ordinal_to_read += 1;
1809            if next_offset >= end_offset {
1810                return Ok(());
1811            }
1812
1813            // Decode unknown envelopes for gaps in ordinals.
1814            while _next_ordinal_to_read < 1 {
1815                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1816                _next_ordinal_to_read += 1;
1817                next_offset += envelope_size;
1818            }
1819
1820            let next_out_of_line = decoder.next_out_of_line();
1821            let handles_before = decoder.remaining_handles();
1822            if let Some((inlined, num_bytes, num_handles)) =
1823                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1824            {
1825                let member_inline_size = <fidl::encoding::BoundedString<1024> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1826                if inlined != (member_inline_size <= 4) {
1827                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1828                }
1829                let inner_offset;
1830                let mut inner_depth = depth.clone();
1831                if inlined {
1832                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1833                    inner_offset = next_offset;
1834                } else {
1835                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1836                    inner_depth.increment()?;
1837                }
1838                let val_ref = self.method.get_or_insert_with(|| {
1839                    fidl::new_empty!(
1840                        fidl::encoding::BoundedString<1024>,
1841                        fidl::encoding::DefaultFuchsiaResourceDialect
1842                    )
1843                });
1844                fidl::decode!(
1845                    fidl::encoding::BoundedString<1024>,
1846                    fidl::encoding::DefaultFuchsiaResourceDialect,
1847                    val_ref,
1848                    decoder,
1849                    inner_offset,
1850                    inner_depth
1851                )?;
1852                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1853                {
1854                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1855                }
1856                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1857                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1858                }
1859            }
1860
1861            next_offset += envelope_size;
1862            _next_ordinal_to_read += 1;
1863            if next_offset >= end_offset {
1864                return Ok(());
1865            }
1866
1867            // Decode unknown envelopes for gaps in ordinals.
1868            while _next_ordinal_to_read < 2 {
1869                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1870                _next_ordinal_to_read += 1;
1871                next_offset += envelope_size;
1872            }
1873
1874            let next_out_of_line = decoder.next_out_of_line();
1875            let handles_before = decoder.remaining_handles();
1876            if let Some((inlined, num_bytes, num_handles)) =
1877                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1878            {
1879                let member_inline_size = <fidl::encoding::BoundedString<4096> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1880                if inlined != (member_inline_size <= 4) {
1881                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1882                }
1883                let inner_offset;
1884                let mut inner_depth = depth.clone();
1885                if inlined {
1886                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1887                    inner_offset = next_offset;
1888                } else {
1889                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1890                    inner_depth.increment()?;
1891                }
1892                let val_ref = self.url.get_or_insert_with(|| {
1893                    fidl::new_empty!(
1894                        fidl::encoding::BoundedString<4096>,
1895                        fidl::encoding::DefaultFuchsiaResourceDialect
1896                    )
1897                });
1898                fidl::decode!(
1899                    fidl::encoding::BoundedString<4096>,
1900                    fidl::encoding::DefaultFuchsiaResourceDialect,
1901                    val_ref,
1902                    decoder,
1903                    inner_offset,
1904                    inner_depth
1905                )?;
1906                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1907                {
1908                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1909                }
1910                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1911                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1912                }
1913            }
1914
1915            next_offset += envelope_size;
1916            _next_ordinal_to_read += 1;
1917            if next_offset >= end_offset {
1918                return Ok(());
1919            }
1920
1921            // Decode unknown envelopes for gaps in ordinals.
1922            while _next_ordinal_to_read < 3 {
1923                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1924                _next_ordinal_to_read += 1;
1925                next_offset += envelope_size;
1926            }
1927
1928            let next_out_of_line = decoder.next_out_of_line();
1929            let handles_before = decoder.remaining_handles();
1930            if let Some((inlined, num_bytes, num_handles)) =
1931                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1932            {
1933                let member_inline_size = <fidl::encoding::UnboundedVector<Header> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1934                if inlined != (member_inline_size <= 4) {
1935                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1936                }
1937                let inner_offset;
1938                let mut inner_depth = depth.clone();
1939                if inlined {
1940                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1941                    inner_offset = next_offset;
1942                } else {
1943                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1944                    inner_depth.increment()?;
1945                }
1946                let val_ref = self.headers.get_or_insert_with(|| {
1947                    fidl::new_empty!(
1948                        fidl::encoding::UnboundedVector<Header>,
1949                        fidl::encoding::DefaultFuchsiaResourceDialect
1950                    )
1951                });
1952                fidl::decode!(
1953                    fidl::encoding::UnboundedVector<Header>,
1954                    fidl::encoding::DefaultFuchsiaResourceDialect,
1955                    val_ref,
1956                    decoder,
1957                    inner_offset,
1958                    inner_depth
1959                )?;
1960                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1961                {
1962                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1963                }
1964                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1965                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1966                }
1967            }
1968
1969            next_offset += envelope_size;
1970            _next_ordinal_to_read += 1;
1971            if next_offset >= end_offset {
1972                return Ok(());
1973            }
1974
1975            // Decode unknown envelopes for gaps in ordinals.
1976            while _next_ordinal_to_read < 4 {
1977                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1978                _next_ordinal_to_read += 1;
1979                next_offset += envelope_size;
1980            }
1981
1982            let next_out_of_line = decoder.next_out_of_line();
1983            let handles_before = decoder.remaining_handles();
1984            if let Some((inlined, num_bytes, num_handles)) =
1985                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1986            {
1987                let member_inline_size =
1988                    <Body as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1989                if inlined != (member_inline_size <= 4) {
1990                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1991                }
1992                let inner_offset;
1993                let mut inner_depth = depth.clone();
1994                if inlined {
1995                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1996                    inner_offset = next_offset;
1997                } else {
1998                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1999                    inner_depth.increment()?;
2000                }
2001                let val_ref = self.body.get_or_insert_with(|| {
2002                    fidl::new_empty!(Body, fidl::encoding::DefaultFuchsiaResourceDialect)
2003                });
2004                fidl::decode!(
2005                    Body,
2006                    fidl::encoding::DefaultFuchsiaResourceDialect,
2007                    val_ref,
2008                    decoder,
2009                    inner_offset,
2010                    inner_depth
2011                )?;
2012                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2013                {
2014                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2015                }
2016                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2017                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2018                }
2019            }
2020
2021            next_offset += envelope_size;
2022            _next_ordinal_to_read += 1;
2023            if next_offset >= end_offset {
2024                return Ok(());
2025            }
2026
2027            // Decode unknown envelopes for gaps in ordinals.
2028            while _next_ordinal_to_read < 5 {
2029                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2030                _next_ordinal_to_read += 1;
2031                next_offset += envelope_size;
2032            }
2033
2034            let next_out_of_line = decoder.next_out_of_line();
2035            let handles_before = decoder.remaining_handles();
2036            if let Some((inlined, num_bytes, num_handles)) =
2037                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2038            {
2039                let member_inline_size =
2040                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2041                if inlined != (member_inline_size <= 4) {
2042                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2043                }
2044                let inner_offset;
2045                let mut inner_depth = depth.clone();
2046                if inlined {
2047                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2048                    inner_offset = next_offset;
2049                } else {
2050                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2051                    inner_depth.increment()?;
2052                }
2053                let val_ref = self.deadline.get_or_insert_with(|| {
2054                    fidl::new_empty!(i64, fidl::encoding::DefaultFuchsiaResourceDialect)
2055                });
2056                fidl::decode!(
2057                    i64,
2058                    fidl::encoding::DefaultFuchsiaResourceDialect,
2059                    val_ref,
2060                    decoder,
2061                    inner_offset,
2062                    inner_depth
2063                )?;
2064                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2065                {
2066                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2067                }
2068                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2069                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2070                }
2071            }
2072
2073            next_offset += envelope_size;
2074
2075            // Decode the remaining unknown envelopes.
2076            while next_offset < end_offset {
2077                _next_ordinal_to_read += 1;
2078                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2079                next_offset += envelope_size;
2080            }
2081
2082            Ok(())
2083        }
2084    }
2085
2086    impl Response {
2087        #[inline(always)]
2088        fn max_ordinal_present(&self) -> u64 {
2089            if let Some(_) = self.redirect {
2090                return 7;
2091            }
2092            if let Some(_) = self.headers {
2093                return 6;
2094            }
2095            if let Some(_) = self.status_line {
2096                return 5;
2097            }
2098            if let Some(_) = self.status_code {
2099                return 4;
2100            }
2101            if let Some(_) = self.final_url {
2102                return 3;
2103            }
2104            if let Some(_) = self.body {
2105                return 2;
2106            }
2107            if let Some(_) = self.error {
2108                return 1;
2109            }
2110            0
2111        }
2112    }
2113
2114    impl fidl::encoding::ResourceTypeMarker for Response {
2115        type Borrowed<'a> = &'a mut Self;
2116        fn take_or_borrow<'a>(
2117            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2118        ) -> Self::Borrowed<'a> {
2119            value
2120        }
2121    }
2122
2123    unsafe impl fidl::encoding::TypeMarker for Response {
2124        type Owned = Self;
2125
2126        #[inline(always)]
2127        fn inline_align(_context: fidl::encoding::Context) -> usize {
2128            8
2129        }
2130
2131        #[inline(always)]
2132        fn inline_size(_context: fidl::encoding::Context) -> usize {
2133            16
2134        }
2135    }
2136
2137    unsafe impl fidl::encoding::Encode<Response, fidl::encoding::DefaultFuchsiaResourceDialect>
2138        for &mut Response
2139    {
2140        unsafe fn encode(
2141            self,
2142            encoder: &mut fidl::encoding::Encoder<
2143                '_,
2144                fidl::encoding::DefaultFuchsiaResourceDialect,
2145            >,
2146            offset: usize,
2147            mut depth: fidl::encoding::Depth,
2148        ) -> fidl::Result<()> {
2149            encoder.debug_check_bounds::<Response>(offset);
2150            // Vector header
2151            let max_ordinal: u64 = self.max_ordinal_present();
2152            encoder.write_num(max_ordinal, offset);
2153            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2154            // Calling encoder.out_of_line_offset(0) is not allowed.
2155            if max_ordinal == 0 {
2156                return Ok(());
2157            }
2158            depth.increment()?;
2159            let envelope_size = 8;
2160            let bytes_len = max_ordinal as usize * envelope_size;
2161            #[allow(unused_variables)]
2162            let offset = encoder.out_of_line_offset(bytes_len);
2163            let mut _prev_end_offset: usize = 0;
2164            if 1 > max_ordinal {
2165                return Ok(());
2166            }
2167
2168            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2169            // are envelope_size bytes.
2170            let cur_offset: usize = (1 - 1) * envelope_size;
2171
2172            // Zero reserved fields.
2173            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2174
2175            // Safety:
2176            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2177            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2178            //   envelope_size bytes, there is always sufficient room.
2179            fidl::encoding::encode_in_envelope_optional::<
2180                Error,
2181                fidl::encoding::DefaultFuchsiaResourceDialect,
2182            >(
2183                self.error.as_ref().map(<Error as fidl::encoding::ValueTypeMarker>::borrow),
2184                encoder,
2185                offset + cur_offset,
2186                depth,
2187            )?;
2188
2189            _prev_end_offset = cur_offset + envelope_size;
2190            if 2 > max_ordinal {
2191                return Ok(());
2192            }
2193
2194            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2195            // are envelope_size bytes.
2196            let cur_offset: usize = (2 - 1) * envelope_size;
2197
2198            // Zero reserved fields.
2199            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2200
2201            // Safety:
2202            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2203            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2204            //   envelope_size bytes, there is always sufficient room.
2205            fidl::encoding::encode_in_envelope_optional::<
2206                fidl::encoding::HandleType<
2207                    fidl::Socket,
2208                    { fidl::ObjectType::SOCKET.into_raw() },
2209                    2147483648,
2210                >,
2211                fidl::encoding::DefaultFuchsiaResourceDialect,
2212            >(
2213                self.body.as_mut().map(
2214                    <fidl::encoding::HandleType<
2215                        fidl::Socket,
2216                        { fidl::ObjectType::SOCKET.into_raw() },
2217                        2147483648,
2218                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
2219                ),
2220                encoder,
2221                offset + cur_offset,
2222                depth,
2223            )?;
2224
2225            _prev_end_offset = cur_offset + envelope_size;
2226            if 3 > max_ordinal {
2227                return Ok(());
2228            }
2229
2230            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2231            // are envelope_size bytes.
2232            let cur_offset: usize = (3 - 1) * envelope_size;
2233
2234            // Zero reserved fields.
2235            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2236
2237            // Safety:
2238            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2239            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2240            //   envelope_size bytes, there is always sufficient room.
2241            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<4096>, fidl::encoding::DefaultFuchsiaResourceDialect>(
2242            self.final_url.as_ref().map(<fidl::encoding::BoundedString<4096> as fidl::encoding::ValueTypeMarker>::borrow),
2243            encoder, offset + cur_offset, depth
2244        )?;
2245
2246            _prev_end_offset = cur_offset + envelope_size;
2247            if 4 > max_ordinal {
2248                return Ok(());
2249            }
2250
2251            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2252            // are envelope_size bytes.
2253            let cur_offset: usize = (4 - 1) * envelope_size;
2254
2255            // Zero reserved fields.
2256            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2257
2258            // Safety:
2259            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2260            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2261            //   envelope_size bytes, there is always sufficient room.
2262            fidl::encoding::encode_in_envelope_optional::<
2263                u32,
2264                fidl::encoding::DefaultFuchsiaResourceDialect,
2265            >(
2266                self.status_code.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
2267                encoder,
2268                offset + cur_offset,
2269                depth,
2270            )?;
2271
2272            _prev_end_offset = cur_offset + envelope_size;
2273            if 5 > max_ordinal {
2274                return Ok(());
2275            }
2276
2277            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2278            // are envelope_size bytes.
2279            let cur_offset: usize = (5 - 1) * envelope_size;
2280
2281            // Zero reserved fields.
2282            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2283
2284            // Safety:
2285            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2286            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2287            //   envelope_size bytes, there is always sufficient room.
2288            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<u8>, fidl::encoding::DefaultFuchsiaResourceDialect>(
2289            self.status_line.as_ref().map(<fidl::encoding::UnboundedVector<u8> as fidl::encoding::ValueTypeMarker>::borrow),
2290            encoder, offset + cur_offset, depth
2291        )?;
2292
2293            _prev_end_offset = cur_offset + envelope_size;
2294            if 6 > max_ordinal {
2295                return Ok(());
2296            }
2297
2298            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2299            // are envelope_size bytes.
2300            let cur_offset: usize = (6 - 1) * envelope_size;
2301
2302            // Zero reserved fields.
2303            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2304
2305            // Safety:
2306            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2307            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2308            //   envelope_size bytes, there is always sufficient room.
2309            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<Header>, fidl::encoding::DefaultFuchsiaResourceDialect>(
2310            self.headers.as_ref().map(<fidl::encoding::UnboundedVector<Header> as fidl::encoding::ValueTypeMarker>::borrow),
2311            encoder, offset + cur_offset, depth
2312        )?;
2313
2314            _prev_end_offset = cur_offset + envelope_size;
2315            if 7 > max_ordinal {
2316                return Ok(());
2317            }
2318
2319            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2320            // are envelope_size bytes.
2321            let cur_offset: usize = (7 - 1) * envelope_size;
2322
2323            // Zero reserved fields.
2324            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2325
2326            // Safety:
2327            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2328            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2329            //   envelope_size bytes, there is always sufficient room.
2330            fidl::encoding::encode_in_envelope_optional::<
2331                RedirectTarget,
2332                fidl::encoding::DefaultFuchsiaResourceDialect,
2333            >(
2334                self.redirect
2335                    .as_ref()
2336                    .map(<RedirectTarget as fidl::encoding::ValueTypeMarker>::borrow),
2337                encoder,
2338                offset + cur_offset,
2339                depth,
2340            )?;
2341
2342            _prev_end_offset = cur_offset + envelope_size;
2343
2344            Ok(())
2345        }
2346    }
2347
2348    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Response {
2349        #[inline(always)]
2350        fn new_empty() -> Self {
2351            Self::default()
2352        }
2353
2354        unsafe fn decode(
2355            &mut self,
2356            decoder: &mut fidl::encoding::Decoder<
2357                '_,
2358                fidl::encoding::DefaultFuchsiaResourceDialect,
2359            >,
2360            offset: usize,
2361            mut depth: fidl::encoding::Depth,
2362        ) -> fidl::Result<()> {
2363            decoder.debug_check_bounds::<Self>(offset);
2364            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2365                None => return Err(fidl::Error::NotNullable),
2366                Some(len) => len,
2367            };
2368            // Calling decoder.out_of_line_offset(0) is not allowed.
2369            if len == 0 {
2370                return Ok(());
2371            };
2372            depth.increment()?;
2373            let envelope_size = 8;
2374            let bytes_len = len * envelope_size;
2375            let offset = decoder.out_of_line_offset(bytes_len)?;
2376            // Decode the envelope for each type.
2377            let mut _next_ordinal_to_read = 0;
2378            let mut next_offset = offset;
2379            let end_offset = offset + bytes_len;
2380            _next_ordinal_to_read += 1;
2381            if next_offset >= end_offset {
2382                return Ok(());
2383            }
2384
2385            // Decode unknown envelopes for gaps in ordinals.
2386            while _next_ordinal_to_read < 1 {
2387                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2388                _next_ordinal_to_read += 1;
2389                next_offset += envelope_size;
2390            }
2391
2392            let next_out_of_line = decoder.next_out_of_line();
2393            let handles_before = decoder.remaining_handles();
2394            if let Some((inlined, num_bytes, num_handles)) =
2395                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2396            {
2397                let member_inline_size =
2398                    <Error as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2399                if inlined != (member_inline_size <= 4) {
2400                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2401                }
2402                let inner_offset;
2403                let mut inner_depth = depth.clone();
2404                if inlined {
2405                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2406                    inner_offset = next_offset;
2407                } else {
2408                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2409                    inner_depth.increment()?;
2410                }
2411                let val_ref = self.error.get_or_insert_with(|| {
2412                    fidl::new_empty!(Error, fidl::encoding::DefaultFuchsiaResourceDialect)
2413                });
2414                fidl::decode!(
2415                    Error,
2416                    fidl::encoding::DefaultFuchsiaResourceDialect,
2417                    val_ref,
2418                    decoder,
2419                    inner_offset,
2420                    inner_depth
2421                )?;
2422                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2423                {
2424                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2425                }
2426                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2427                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2428                }
2429            }
2430
2431            next_offset += envelope_size;
2432            _next_ordinal_to_read += 1;
2433            if next_offset >= end_offset {
2434                return Ok(());
2435            }
2436
2437            // Decode unknown envelopes for gaps in ordinals.
2438            while _next_ordinal_to_read < 2 {
2439                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2440                _next_ordinal_to_read += 1;
2441                next_offset += envelope_size;
2442            }
2443
2444            let next_out_of_line = decoder.next_out_of_line();
2445            let handles_before = decoder.remaining_handles();
2446            if let Some((inlined, num_bytes, num_handles)) =
2447                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2448            {
2449                let member_inline_size = <fidl::encoding::HandleType<
2450                    fidl::Socket,
2451                    { fidl::ObjectType::SOCKET.into_raw() },
2452                    2147483648,
2453                > as fidl::encoding::TypeMarker>::inline_size(
2454                    decoder.context
2455                );
2456                if inlined != (member_inline_size <= 4) {
2457                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2458                }
2459                let inner_offset;
2460                let mut inner_depth = depth.clone();
2461                if inlined {
2462                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2463                    inner_offset = next_offset;
2464                } else {
2465                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2466                    inner_depth.increment()?;
2467                }
2468                let val_ref =
2469                self.body.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
2470                fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
2471                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2472                {
2473                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2474                }
2475                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2476                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2477                }
2478            }
2479
2480            next_offset += envelope_size;
2481            _next_ordinal_to_read += 1;
2482            if next_offset >= end_offset {
2483                return Ok(());
2484            }
2485
2486            // Decode unknown envelopes for gaps in ordinals.
2487            while _next_ordinal_to_read < 3 {
2488                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2489                _next_ordinal_to_read += 1;
2490                next_offset += envelope_size;
2491            }
2492
2493            let next_out_of_line = decoder.next_out_of_line();
2494            let handles_before = decoder.remaining_handles();
2495            if let Some((inlined, num_bytes, num_handles)) =
2496                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2497            {
2498                let member_inline_size = <fidl::encoding::BoundedString<4096> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2499                if inlined != (member_inline_size <= 4) {
2500                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2501                }
2502                let inner_offset;
2503                let mut inner_depth = depth.clone();
2504                if inlined {
2505                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2506                    inner_offset = next_offset;
2507                } else {
2508                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2509                    inner_depth.increment()?;
2510                }
2511                let val_ref = self.final_url.get_or_insert_with(|| {
2512                    fidl::new_empty!(
2513                        fidl::encoding::BoundedString<4096>,
2514                        fidl::encoding::DefaultFuchsiaResourceDialect
2515                    )
2516                });
2517                fidl::decode!(
2518                    fidl::encoding::BoundedString<4096>,
2519                    fidl::encoding::DefaultFuchsiaResourceDialect,
2520                    val_ref,
2521                    decoder,
2522                    inner_offset,
2523                    inner_depth
2524                )?;
2525                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2526                {
2527                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2528                }
2529                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2530                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2531                }
2532            }
2533
2534            next_offset += envelope_size;
2535            _next_ordinal_to_read += 1;
2536            if next_offset >= end_offset {
2537                return Ok(());
2538            }
2539
2540            // Decode unknown envelopes for gaps in ordinals.
2541            while _next_ordinal_to_read < 4 {
2542                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2543                _next_ordinal_to_read += 1;
2544                next_offset += envelope_size;
2545            }
2546
2547            let next_out_of_line = decoder.next_out_of_line();
2548            let handles_before = decoder.remaining_handles();
2549            if let Some((inlined, num_bytes, num_handles)) =
2550                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2551            {
2552                let member_inline_size =
2553                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2554                if inlined != (member_inline_size <= 4) {
2555                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2556                }
2557                let inner_offset;
2558                let mut inner_depth = depth.clone();
2559                if inlined {
2560                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2561                    inner_offset = next_offset;
2562                } else {
2563                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2564                    inner_depth.increment()?;
2565                }
2566                let val_ref = self.status_code.get_or_insert_with(|| {
2567                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
2568                });
2569                fidl::decode!(
2570                    u32,
2571                    fidl::encoding::DefaultFuchsiaResourceDialect,
2572                    val_ref,
2573                    decoder,
2574                    inner_offset,
2575                    inner_depth
2576                )?;
2577                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2578                {
2579                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2580                }
2581                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2582                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2583                }
2584            }
2585
2586            next_offset += envelope_size;
2587            _next_ordinal_to_read += 1;
2588            if next_offset >= end_offset {
2589                return Ok(());
2590            }
2591
2592            // Decode unknown envelopes for gaps in ordinals.
2593            while _next_ordinal_to_read < 5 {
2594                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2595                _next_ordinal_to_read += 1;
2596                next_offset += envelope_size;
2597            }
2598
2599            let next_out_of_line = decoder.next_out_of_line();
2600            let handles_before = decoder.remaining_handles();
2601            if let Some((inlined, num_bytes, num_handles)) =
2602                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2603            {
2604                let member_inline_size = <fidl::encoding::UnboundedVector<u8> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2605                if inlined != (member_inline_size <= 4) {
2606                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2607                }
2608                let inner_offset;
2609                let mut inner_depth = depth.clone();
2610                if inlined {
2611                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2612                    inner_offset = next_offset;
2613                } else {
2614                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2615                    inner_depth.increment()?;
2616                }
2617                let val_ref = self.status_line.get_or_insert_with(|| {
2618                    fidl::new_empty!(
2619                        fidl::encoding::UnboundedVector<u8>,
2620                        fidl::encoding::DefaultFuchsiaResourceDialect
2621                    )
2622                });
2623                fidl::decode!(
2624                    fidl::encoding::UnboundedVector<u8>,
2625                    fidl::encoding::DefaultFuchsiaResourceDialect,
2626                    val_ref,
2627                    decoder,
2628                    inner_offset,
2629                    inner_depth
2630                )?;
2631                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2632                {
2633                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2634                }
2635                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2636                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2637                }
2638            }
2639
2640            next_offset += envelope_size;
2641            _next_ordinal_to_read += 1;
2642            if next_offset >= end_offset {
2643                return Ok(());
2644            }
2645
2646            // Decode unknown envelopes for gaps in ordinals.
2647            while _next_ordinal_to_read < 6 {
2648                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2649                _next_ordinal_to_read += 1;
2650                next_offset += envelope_size;
2651            }
2652
2653            let next_out_of_line = decoder.next_out_of_line();
2654            let handles_before = decoder.remaining_handles();
2655            if let Some((inlined, num_bytes, num_handles)) =
2656                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2657            {
2658                let member_inline_size = <fidl::encoding::UnboundedVector<Header> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2659                if inlined != (member_inline_size <= 4) {
2660                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2661                }
2662                let inner_offset;
2663                let mut inner_depth = depth.clone();
2664                if inlined {
2665                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2666                    inner_offset = next_offset;
2667                } else {
2668                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2669                    inner_depth.increment()?;
2670                }
2671                let val_ref = self.headers.get_or_insert_with(|| {
2672                    fidl::new_empty!(
2673                        fidl::encoding::UnboundedVector<Header>,
2674                        fidl::encoding::DefaultFuchsiaResourceDialect
2675                    )
2676                });
2677                fidl::decode!(
2678                    fidl::encoding::UnboundedVector<Header>,
2679                    fidl::encoding::DefaultFuchsiaResourceDialect,
2680                    val_ref,
2681                    decoder,
2682                    inner_offset,
2683                    inner_depth
2684                )?;
2685                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2686                {
2687                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2688                }
2689                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2690                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2691                }
2692            }
2693
2694            next_offset += envelope_size;
2695            _next_ordinal_to_read += 1;
2696            if next_offset >= end_offset {
2697                return Ok(());
2698            }
2699
2700            // Decode unknown envelopes for gaps in ordinals.
2701            while _next_ordinal_to_read < 7 {
2702                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2703                _next_ordinal_to_read += 1;
2704                next_offset += envelope_size;
2705            }
2706
2707            let next_out_of_line = decoder.next_out_of_line();
2708            let handles_before = decoder.remaining_handles();
2709            if let Some((inlined, num_bytes, num_handles)) =
2710                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2711            {
2712                let member_inline_size =
2713                    <RedirectTarget as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2714                if inlined != (member_inline_size <= 4) {
2715                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2716                }
2717                let inner_offset;
2718                let mut inner_depth = depth.clone();
2719                if inlined {
2720                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2721                    inner_offset = next_offset;
2722                } else {
2723                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2724                    inner_depth.increment()?;
2725                }
2726                let val_ref = self.redirect.get_or_insert_with(|| {
2727                    fidl::new_empty!(RedirectTarget, fidl::encoding::DefaultFuchsiaResourceDialect)
2728                });
2729                fidl::decode!(
2730                    RedirectTarget,
2731                    fidl::encoding::DefaultFuchsiaResourceDialect,
2732                    val_ref,
2733                    decoder,
2734                    inner_offset,
2735                    inner_depth
2736                )?;
2737                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2738                {
2739                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2740                }
2741                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2742                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2743                }
2744            }
2745
2746            next_offset += envelope_size;
2747
2748            // Decode the remaining unknown envelopes.
2749            while next_offset < end_offset {
2750                _next_ordinal_to_read += 1;
2751                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2752                next_offset += envelope_size;
2753            }
2754
2755            Ok(())
2756        }
2757    }
2758
2759    impl fidl::encoding::ResourceTypeMarker for Body {
2760        type Borrowed<'a> = &'a mut Self;
2761        fn take_or_borrow<'a>(
2762            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2763        ) -> Self::Borrowed<'a> {
2764            value
2765        }
2766    }
2767
2768    unsafe impl fidl::encoding::TypeMarker for Body {
2769        type Owned = Self;
2770
2771        #[inline(always)]
2772        fn inline_align(_context: fidl::encoding::Context) -> usize {
2773            8
2774        }
2775
2776        #[inline(always)]
2777        fn inline_size(_context: fidl::encoding::Context) -> usize {
2778            16
2779        }
2780    }
2781
2782    unsafe impl fidl::encoding::Encode<Body, fidl::encoding::DefaultFuchsiaResourceDialect>
2783        for &mut Body
2784    {
2785        #[inline]
2786        unsafe fn encode(
2787            self,
2788            encoder: &mut fidl::encoding::Encoder<
2789                '_,
2790                fidl::encoding::DefaultFuchsiaResourceDialect,
2791            >,
2792            offset: usize,
2793            _depth: fidl::encoding::Depth,
2794        ) -> fidl::Result<()> {
2795            encoder.debug_check_bounds::<Body>(offset);
2796            encoder.write_num::<u64>(self.ordinal(), offset);
2797            match self {
2798            Body::Buffer(ref mut val) => {
2799                fidl::encoding::encode_in_envelope::<fidl_fuchsia_mem::Buffer, fidl::encoding::DefaultFuchsiaResourceDialect>(
2800                    <fidl_fuchsia_mem::Buffer as fidl::encoding::ResourceTypeMarker>::take_or_borrow(val),
2801                    encoder, offset + 8, _depth
2802                )
2803            }
2804            Body::Stream(ref mut val) => {
2805                fidl::encoding::encode_in_envelope::<fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect>(
2806                    <fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(val),
2807                    encoder, offset + 8, _depth
2808                )
2809            }
2810        }
2811        }
2812    }
2813
2814    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Body {
2815        #[inline(always)]
2816        fn new_empty() -> Self {
2817            Self::Buffer(fidl::new_empty!(
2818                fidl_fuchsia_mem::Buffer,
2819                fidl::encoding::DefaultFuchsiaResourceDialect
2820            ))
2821        }
2822
2823        #[inline]
2824        unsafe fn decode(
2825            &mut self,
2826            decoder: &mut fidl::encoding::Decoder<
2827                '_,
2828                fidl::encoding::DefaultFuchsiaResourceDialect,
2829            >,
2830            offset: usize,
2831            mut depth: fidl::encoding::Depth,
2832        ) -> fidl::Result<()> {
2833            decoder.debug_check_bounds::<Self>(offset);
2834            #[allow(unused_variables)]
2835            let next_out_of_line = decoder.next_out_of_line();
2836            let handles_before = decoder.remaining_handles();
2837            let (ordinal, inlined, num_bytes, num_handles) =
2838                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2839
2840            let member_inline_size = match ordinal {
2841                1 => <fidl_fuchsia_mem::Buffer as fidl::encoding::TypeMarker>::inline_size(
2842                    decoder.context,
2843                ),
2844                2 => <fidl::encoding::HandleType<
2845                    fidl::Socket,
2846                    { fidl::ObjectType::SOCKET.into_raw() },
2847                    2147483648,
2848                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2849                _ => return Err(fidl::Error::UnknownUnionTag),
2850            };
2851
2852            if inlined != (member_inline_size <= 4) {
2853                return Err(fidl::Error::InvalidInlineBitInEnvelope);
2854            }
2855            let _inner_offset;
2856            if inlined {
2857                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2858                _inner_offset = offset + 8;
2859            } else {
2860                depth.increment()?;
2861                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2862            }
2863            match ordinal {
2864                1 => {
2865                    #[allow(irrefutable_let_patterns)]
2866                    if let Body::Buffer(_) = self {
2867                        // Do nothing, read the value into the object
2868                    } else {
2869                        // Initialize `self` to the right variant
2870                        *self = Body::Buffer(fidl::new_empty!(
2871                            fidl_fuchsia_mem::Buffer,
2872                            fidl::encoding::DefaultFuchsiaResourceDialect
2873                        ));
2874                    }
2875                    #[allow(irrefutable_let_patterns)]
2876                    if let Body::Buffer(ref mut val) = self {
2877                        fidl::decode!(
2878                            fidl_fuchsia_mem::Buffer,
2879                            fidl::encoding::DefaultFuchsiaResourceDialect,
2880                            val,
2881                            decoder,
2882                            _inner_offset,
2883                            depth
2884                        )?;
2885                    } else {
2886                        unreachable!()
2887                    }
2888                }
2889                2 => {
2890                    #[allow(irrefutable_let_patterns)]
2891                    if let Body::Stream(_) = self {
2892                        // Do nothing, read the value into the object
2893                    } else {
2894                        // Initialize `self` to the right variant
2895                        *self = Body::Stream(
2896                            fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
2897                        );
2898                    }
2899                    #[allow(irrefutable_let_patterns)]
2900                    if let Body::Stream(ref mut val) = self {
2901                        fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val, decoder, _inner_offset, depth)?;
2902                    } else {
2903                        unreachable!()
2904                    }
2905                }
2906                ordinal => panic!("unexpected ordinal {:?}", ordinal),
2907            }
2908            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2909                return Err(fidl::Error::InvalidNumBytesInEnvelope);
2910            }
2911            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2912                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2913            }
2914            Ok(())
2915        }
2916    }
2917}