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