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