fidl_fuchsia_net_http/
fidl_fuchsia_net_http.rs

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