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