Skip to main content

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