Skip to main content

fidl_fuchsia_pkg_http/
fidl_fuchsia_pkg_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_pkg_http__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct ClientDownloadBlobRequest {
16    pub url: String,
17    pub destination: fidl::endpoints::ClientEnd<fidl_fuchsia_fxfs::BlobWriterMarker>,
18    pub header_timeout: i64,
19    pub body_timeout: i64,
20    pub resumption_attempt_limit: u32,
21}
22
23impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ClientDownloadBlobRequest {}
24
25#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
26pub struct ClientMarker;
27
28impl fidl::endpoints::ProtocolMarker for ClientMarker {
29    type Proxy = ClientProxy;
30    type RequestStream = ClientRequestStream;
31    #[cfg(target_os = "fuchsia")]
32    type SynchronousProxy = ClientSynchronousProxy;
33
34    const DEBUG_NAME: &'static str = "fuchsia.pkg.http.Client";
35}
36impl fidl::endpoints::DiscoverableProtocolMarker for ClientMarker {}
37pub type ClientDownloadBlobResult = Result<u64, ClientDownloadBlobError>;
38
39pub trait ClientProxyInterface: Send + Sync {
40    type DownloadBlobResponseFut: std::future::Future<Output = Result<ClientDownloadBlobResult, fidl::Error>>
41        + Send;
42    fn r#download_blob(
43        &self,
44        url: &str,
45        destination: fidl::endpoints::ClientEnd<fidl_fuchsia_fxfs::BlobWriterMarker>,
46        header_timeout: i64,
47        body_timeout: i64,
48        resumption_attempt_limit: u32,
49    ) -> Self::DownloadBlobResponseFut;
50}
51#[derive(Debug)]
52#[cfg(target_os = "fuchsia")]
53pub struct ClientSynchronousProxy {
54    client: fidl::client::sync::Client,
55}
56
57#[cfg(target_os = "fuchsia")]
58impl fidl::endpoints::SynchronousProxy for ClientSynchronousProxy {
59    type Proxy = ClientProxy;
60    type Protocol = ClientMarker;
61
62    fn from_channel(inner: fidl::Channel) -> Self {
63        Self::new(inner)
64    }
65
66    fn into_channel(self) -> fidl::Channel {
67        self.client.into_channel()
68    }
69
70    fn as_channel(&self) -> &fidl::Channel {
71        self.client.as_channel()
72    }
73}
74
75#[cfg(target_os = "fuchsia")]
76impl ClientSynchronousProxy {
77    pub fn new(channel: fidl::Channel) -> Self {
78        Self { client: fidl::client::sync::Client::new(channel) }
79    }
80
81    pub fn into_channel(self) -> fidl::Channel {
82        self.client.into_channel()
83    }
84
85    /// Waits until an event arrives and returns it. It is safe for other
86    /// threads to make concurrent requests while waiting for an event.
87    pub fn wait_for_event(
88        &self,
89        deadline: zx::MonotonicInstant,
90    ) -> Result<ClientEvent, fidl::Error> {
91        ClientEvent::decode(self.client.wait_for_event::<ClientMarker>(deadline)?)
92    }
93
94    /// Makes an HTTP GET request for `url` and writes the response body to `destination`.
95    ///
96    /// As long as forward progress is being made (response stream contains some body bytes before
97    /// terminating early), this method will repeatedly (up to `resumption_attempt_limit`) make
98    /// follow-up HTTP GET requests with the RANGE header set to the outstanding content.
99    ///
100    /// + request `url` the URL of the file to be downloaded.
101    /// + request `destination` where the file will be written.
102    /// + request `header_timeout` the timeout to use when waiting for the entire HTTP response
103    ///     header to be downloaded.
104    /// + request `body_timeout` the timeout to use when waiting for every chunk of bytes while
105    ///     downloading the HTTP response body.
106    /// + request `resumption_attempt_limit` the number of resumption attempts to make.
107    /// - response `size` the size in bytes of the downloaded file.
108    pub fn r#download_blob(
109        &self,
110        mut url: &str,
111        mut destination: fidl::endpoints::ClientEnd<fidl_fuchsia_fxfs::BlobWriterMarker>,
112        mut header_timeout: i64,
113        mut body_timeout: i64,
114        mut resumption_attempt_limit: u32,
115        ___deadline: zx::MonotonicInstant,
116    ) -> Result<ClientDownloadBlobResult, fidl::Error> {
117        let _response =
118            self.client.send_query::<ClientDownloadBlobRequest, fidl::encoding::ResultType<
119                ClientDownloadBlobResponse,
120                ClientDownloadBlobError,
121            >, ClientMarker>(
122                (url, destination, header_timeout, body_timeout, resumption_attempt_limit),
123                0x829250010b00abb,
124                fidl::encoding::DynamicFlags::empty(),
125                ___deadline,
126            )?;
127        Ok(_response.map(|x| x.size))
128    }
129}
130
131#[cfg(target_os = "fuchsia")]
132impl From<ClientSynchronousProxy> for zx::NullableHandle {
133    fn from(value: ClientSynchronousProxy) -> Self {
134        value.into_channel().into()
135    }
136}
137
138#[cfg(target_os = "fuchsia")]
139impl From<fidl::Channel> for ClientSynchronousProxy {
140    fn from(value: fidl::Channel) -> Self {
141        Self::new(value)
142    }
143}
144
145#[cfg(target_os = "fuchsia")]
146impl fidl::endpoints::FromClient for ClientSynchronousProxy {
147    type Protocol = ClientMarker;
148
149    fn from_client(value: fidl::endpoints::ClientEnd<ClientMarker>) -> Self {
150        Self::new(value.into_channel())
151    }
152}
153
154#[derive(Debug, Clone)]
155pub struct ClientProxy {
156    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
157}
158
159impl fidl::endpoints::Proxy for ClientProxy {
160    type Protocol = ClientMarker;
161
162    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
163        Self::new(inner)
164    }
165
166    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
167        self.client.into_channel().map_err(|client| Self { client })
168    }
169
170    fn as_channel(&self) -> &::fidl::AsyncChannel {
171        self.client.as_channel()
172    }
173}
174
175impl ClientProxy {
176    /// Create a new Proxy for fuchsia.pkg.http/Client.
177    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
178        let protocol_name = <ClientMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
179        Self { client: fidl::client::Client::new(channel, protocol_name) }
180    }
181
182    /// Get a Stream of events from the remote end of the protocol.
183    ///
184    /// # Panics
185    ///
186    /// Panics if the event stream was already taken.
187    pub fn take_event_stream(&self) -> ClientEventStream {
188        ClientEventStream { event_receiver: self.client.take_event_receiver() }
189    }
190
191    /// Makes an HTTP GET request for `url` and writes the response body to `destination`.
192    ///
193    /// As long as forward progress is being made (response stream contains some body bytes before
194    /// terminating early), this method will repeatedly (up to `resumption_attempt_limit`) make
195    /// follow-up HTTP GET requests with the RANGE header set to the outstanding content.
196    ///
197    /// + request `url` the URL of the file to be downloaded.
198    /// + request `destination` where the file will be written.
199    /// + request `header_timeout` the timeout to use when waiting for the entire HTTP response
200    ///     header to be downloaded.
201    /// + request `body_timeout` the timeout to use when waiting for every chunk of bytes while
202    ///     downloading the HTTP response body.
203    /// + request `resumption_attempt_limit` the number of resumption attempts to make.
204    /// - response `size` the size in bytes of the downloaded file.
205    pub fn r#download_blob(
206        &self,
207        mut url: &str,
208        mut destination: fidl::endpoints::ClientEnd<fidl_fuchsia_fxfs::BlobWriterMarker>,
209        mut header_timeout: i64,
210        mut body_timeout: i64,
211        mut resumption_attempt_limit: u32,
212    ) -> fidl::client::QueryResponseFut<
213        ClientDownloadBlobResult,
214        fidl::encoding::DefaultFuchsiaResourceDialect,
215    > {
216        ClientProxyInterface::r#download_blob(
217            self,
218            url,
219            destination,
220            header_timeout,
221            body_timeout,
222            resumption_attempt_limit,
223        )
224    }
225}
226
227impl ClientProxyInterface for ClientProxy {
228    type DownloadBlobResponseFut = fidl::client::QueryResponseFut<
229        ClientDownloadBlobResult,
230        fidl::encoding::DefaultFuchsiaResourceDialect,
231    >;
232    fn r#download_blob(
233        &self,
234        mut url: &str,
235        mut destination: fidl::endpoints::ClientEnd<fidl_fuchsia_fxfs::BlobWriterMarker>,
236        mut header_timeout: i64,
237        mut body_timeout: i64,
238        mut resumption_attempt_limit: u32,
239    ) -> Self::DownloadBlobResponseFut {
240        fn _decode(
241            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
242        ) -> Result<ClientDownloadBlobResult, fidl::Error> {
243            let _response = fidl::client::decode_transaction_body::<
244                fidl::encoding::ResultType<ClientDownloadBlobResponse, ClientDownloadBlobError>,
245                fidl::encoding::DefaultFuchsiaResourceDialect,
246                0x829250010b00abb,
247            >(_buf?)?;
248            Ok(_response.map(|x| x.size))
249        }
250        self.client.send_query_and_decode::<ClientDownloadBlobRequest, ClientDownloadBlobResult>(
251            (url, destination, header_timeout, body_timeout, resumption_attempt_limit),
252            0x829250010b00abb,
253            fidl::encoding::DynamicFlags::empty(),
254            _decode,
255        )
256    }
257}
258
259pub struct ClientEventStream {
260    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
261}
262
263impl std::marker::Unpin for ClientEventStream {}
264
265impl futures::stream::FusedStream for ClientEventStream {
266    fn is_terminated(&self) -> bool {
267        self.event_receiver.is_terminated()
268    }
269}
270
271impl futures::Stream for ClientEventStream {
272    type Item = Result<ClientEvent, fidl::Error>;
273
274    fn poll_next(
275        mut self: std::pin::Pin<&mut Self>,
276        cx: &mut std::task::Context<'_>,
277    ) -> std::task::Poll<Option<Self::Item>> {
278        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
279            &mut self.event_receiver,
280            cx
281        )?) {
282            Some(buf) => std::task::Poll::Ready(Some(ClientEvent::decode(buf))),
283            None => std::task::Poll::Ready(None),
284        }
285    }
286}
287
288#[derive(Debug)]
289pub enum ClientEvent {}
290
291impl ClientEvent {
292    /// Decodes a message buffer as a [`ClientEvent`].
293    fn decode(
294        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
295    ) -> Result<ClientEvent, fidl::Error> {
296        let (bytes, _handles) = buf.split_mut();
297        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
298        debug_assert_eq!(tx_header.tx_id, 0);
299        match tx_header.ordinal {
300            _ => Err(fidl::Error::UnknownOrdinal {
301                ordinal: tx_header.ordinal,
302                protocol_name: <ClientMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
303            }),
304        }
305    }
306}
307
308/// A Stream of incoming requests for fuchsia.pkg.http/Client.
309pub struct ClientRequestStream {
310    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
311    is_terminated: bool,
312}
313
314impl std::marker::Unpin for ClientRequestStream {}
315
316impl futures::stream::FusedStream for ClientRequestStream {
317    fn is_terminated(&self) -> bool {
318        self.is_terminated
319    }
320}
321
322impl fidl::endpoints::RequestStream for ClientRequestStream {
323    type Protocol = ClientMarker;
324    type ControlHandle = ClientControlHandle;
325
326    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
327        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
328    }
329
330    fn control_handle(&self) -> Self::ControlHandle {
331        ClientControlHandle { inner: self.inner.clone() }
332    }
333
334    fn into_inner(
335        self,
336    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
337    {
338        (self.inner, self.is_terminated)
339    }
340
341    fn from_inner(
342        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
343        is_terminated: bool,
344    ) -> Self {
345        Self { inner, is_terminated }
346    }
347}
348
349impl futures::Stream for ClientRequestStream {
350    type Item = Result<ClientRequest, fidl::Error>;
351
352    fn poll_next(
353        mut self: std::pin::Pin<&mut Self>,
354        cx: &mut std::task::Context<'_>,
355    ) -> std::task::Poll<Option<Self::Item>> {
356        let this = &mut *self;
357        if this.inner.check_shutdown(cx) {
358            this.is_terminated = true;
359            return std::task::Poll::Ready(None);
360        }
361        if this.is_terminated {
362            panic!("polled ClientRequestStream after completion");
363        }
364        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
365            |bytes, handles| {
366                match this.inner.channel().read_etc(cx, bytes, handles) {
367                    std::task::Poll::Ready(Ok(())) => {}
368                    std::task::Poll::Pending => return std::task::Poll::Pending,
369                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
370                        this.is_terminated = true;
371                        return std::task::Poll::Ready(None);
372                    }
373                    std::task::Poll::Ready(Err(e)) => {
374                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
375                            e.into(),
376                        ))));
377                    }
378                }
379
380                // A message has been received from the channel
381                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
382
383                std::task::Poll::Ready(Some(match header.ordinal {
384                    0x829250010b00abb => {
385                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
386                        let mut req = fidl::new_empty!(
387                            ClientDownloadBlobRequest,
388                            fidl::encoding::DefaultFuchsiaResourceDialect
389                        );
390                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ClientDownloadBlobRequest>(&header, _body_bytes, handles, &mut req)?;
391                        let control_handle = ClientControlHandle { inner: this.inner.clone() };
392                        Ok(ClientRequest::DownloadBlob {
393                            url: req.url,
394                            destination: req.destination,
395                            header_timeout: req.header_timeout,
396                            body_timeout: req.body_timeout,
397                            resumption_attempt_limit: req.resumption_attempt_limit,
398
399                            responder: ClientDownloadBlobResponder {
400                                control_handle: std::mem::ManuallyDrop::new(control_handle),
401                                tx_id: header.tx_id,
402                            },
403                        })
404                    }
405                    _ => Err(fidl::Error::UnknownOrdinal {
406                        ordinal: header.ordinal,
407                        protocol_name:
408                            <ClientMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
409                    }),
410                }))
411            },
412        )
413    }
414}
415
416/// An HTTP client for package resolution and OTAs.
417#[derive(Debug)]
418pub enum ClientRequest {
419    /// Makes an HTTP GET request for `url` and writes the response body to `destination`.
420    ///
421    /// As long as forward progress is being made (response stream contains some body bytes before
422    /// terminating early), this method will repeatedly (up to `resumption_attempt_limit`) make
423    /// follow-up HTTP GET requests with the RANGE header set to the outstanding content.
424    ///
425    /// + request `url` the URL of the file to be downloaded.
426    /// + request `destination` where the file will be written.
427    /// + request `header_timeout` the timeout to use when waiting for the entire HTTP response
428    ///     header to be downloaded.
429    /// + request `body_timeout` the timeout to use when waiting for every chunk of bytes while
430    ///     downloading the HTTP response body.
431    /// + request `resumption_attempt_limit` the number of resumption attempts to make.
432    /// - response `size` the size in bytes of the downloaded file.
433    DownloadBlob {
434        url: String,
435        destination: fidl::endpoints::ClientEnd<fidl_fuchsia_fxfs::BlobWriterMarker>,
436        header_timeout: i64,
437        body_timeout: i64,
438        resumption_attempt_limit: u32,
439        responder: ClientDownloadBlobResponder,
440    },
441}
442
443impl ClientRequest {
444    #[allow(irrefutable_let_patterns)]
445    pub fn into_download_blob(
446        self,
447    ) -> Option<(
448        String,
449        fidl::endpoints::ClientEnd<fidl_fuchsia_fxfs::BlobWriterMarker>,
450        i64,
451        i64,
452        u32,
453        ClientDownloadBlobResponder,
454    )> {
455        if let ClientRequest::DownloadBlob {
456            url,
457            destination,
458            header_timeout,
459            body_timeout,
460            resumption_attempt_limit,
461            responder,
462        } = self
463        {
464            Some((
465                url,
466                destination,
467                header_timeout,
468                body_timeout,
469                resumption_attempt_limit,
470                responder,
471            ))
472        } else {
473            None
474        }
475    }
476
477    /// Name of the method defined in FIDL
478    pub fn method_name(&self) -> &'static str {
479        match *self {
480            ClientRequest::DownloadBlob { .. } => "download_blob",
481        }
482    }
483}
484
485#[derive(Debug, Clone)]
486pub struct ClientControlHandle {
487    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
488}
489
490impl fidl::endpoints::ControlHandle for ClientControlHandle {
491    fn shutdown(&self) {
492        self.inner.shutdown()
493    }
494
495    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
496        self.inner.shutdown_with_epitaph(status)
497    }
498
499    fn is_closed(&self) -> bool {
500        self.inner.channel().is_closed()
501    }
502    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
503        self.inner.channel().on_closed()
504    }
505
506    #[cfg(target_os = "fuchsia")]
507    fn signal_peer(
508        &self,
509        clear_mask: zx::Signals,
510        set_mask: zx::Signals,
511    ) -> Result<(), zx_status::Status> {
512        use fidl::Peered;
513        self.inner.channel().signal_peer(clear_mask, set_mask)
514    }
515}
516
517impl ClientControlHandle {}
518
519#[must_use = "FIDL methods require a response to be sent"]
520#[derive(Debug)]
521pub struct ClientDownloadBlobResponder {
522    control_handle: std::mem::ManuallyDrop<ClientControlHandle>,
523    tx_id: u32,
524}
525
526/// Set the the channel to be shutdown (see [`ClientControlHandle::shutdown`])
527/// if the responder is dropped without sending a response, so that the client
528/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
529impl std::ops::Drop for ClientDownloadBlobResponder {
530    fn drop(&mut self) {
531        self.control_handle.shutdown();
532        // Safety: drops once, never accessed again
533        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
534    }
535}
536
537impl fidl::endpoints::Responder for ClientDownloadBlobResponder {
538    type ControlHandle = ClientControlHandle;
539
540    fn control_handle(&self) -> &ClientControlHandle {
541        &self.control_handle
542    }
543
544    fn drop_without_shutdown(mut self) {
545        // Safety: drops once, never accessed again due to mem::forget
546        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
547        // Prevent Drop from running (which would shut down the channel)
548        std::mem::forget(self);
549    }
550}
551
552impl ClientDownloadBlobResponder {
553    /// Sends a response to the FIDL transaction.
554    ///
555    /// Sets the channel to shutdown if an error occurs.
556    pub fn send(self, mut result: Result<u64, ClientDownloadBlobError>) -> Result<(), fidl::Error> {
557        let _result = self.send_raw(result);
558        if _result.is_err() {
559            self.control_handle.shutdown();
560        }
561        self.drop_without_shutdown();
562        _result
563    }
564
565    /// Similar to "send" but does not shutdown the channel if an error occurs.
566    pub fn send_no_shutdown_on_err(
567        self,
568        mut result: Result<u64, ClientDownloadBlobError>,
569    ) -> Result<(), fidl::Error> {
570        let _result = self.send_raw(result);
571        self.drop_without_shutdown();
572        _result
573    }
574
575    fn send_raw(
576        &self,
577        mut result: Result<u64, ClientDownloadBlobError>,
578    ) -> Result<(), fidl::Error> {
579        self.control_handle.inner.send::<fidl::encoding::ResultType<
580            ClientDownloadBlobResponse,
581            ClientDownloadBlobError,
582        >>(
583            result.map(|size| (size,)),
584            self.tx_id,
585            0x829250010b00abb,
586            fidl::encoding::DynamicFlags::empty(),
587        )
588    }
589}
590
591mod internal {
592    use super::*;
593
594    impl fidl::encoding::ResourceTypeMarker for ClientDownloadBlobRequest {
595        type Borrowed<'a> = &'a mut Self;
596        fn take_or_borrow<'a>(
597            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
598        ) -> Self::Borrowed<'a> {
599            value
600        }
601    }
602
603    unsafe impl fidl::encoding::TypeMarker for ClientDownloadBlobRequest {
604        type Owned = Self;
605
606        #[inline(always)]
607        fn inline_align(_context: fidl::encoding::Context) -> usize {
608            8
609        }
610
611        #[inline(always)]
612        fn inline_size(_context: fidl::encoding::Context) -> usize {
613            48
614        }
615    }
616
617    unsafe impl
618        fidl::encoding::Encode<
619            ClientDownloadBlobRequest,
620            fidl::encoding::DefaultFuchsiaResourceDialect,
621        > for &mut ClientDownloadBlobRequest
622    {
623        #[inline]
624        unsafe fn encode(
625            self,
626            encoder: &mut fidl::encoding::Encoder<
627                '_,
628                fidl::encoding::DefaultFuchsiaResourceDialect,
629            >,
630            offset: usize,
631            _depth: fidl::encoding::Depth,
632        ) -> fidl::Result<()> {
633            encoder.debug_check_bounds::<ClientDownloadBlobRequest>(offset);
634            // Delegate to tuple encoding.
635            fidl::encoding::Encode::<ClientDownloadBlobRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
636                (
637                    <fidl::encoding::BoundedString<4096> as fidl::encoding::ValueTypeMarker>::borrow(&self.url),
638                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_fxfs::BlobWriterMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.destination),
639                    <i64 as fidl::encoding::ValueTypeMarker>::borrow(&self.header_timeout),
640                    <i64 as fidl::encoding::ValueTypeMarker>::borrow(&self.body_timeout),
641                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.resumption_attempt_limit),
642                ),
643                encoder, offset, _depth
644            )
645        }
646    }
647    unsafe impl<
648        T0: fidl::encoding::Encode<
649                fidl::encoding::BoundedString<4096>,
650                fidl::encoding::DefaultFuchsiaResourceDialect,
651            >,
652        T1: fidl::encoding::Encode<
653                fidl::encoding::Endpoint<
654                    fidl::endpoints::ClientEnd<fidl_fuchsia_fxfs::BlobWriterMarker>,
655                >,
656                fidl::encoding::DefaultFuchsiaResourceDialect,
657            >,
658        T2: fidl::encoding::Encode<i64, fidl::encoding::DefaultFuchsiaResourceDialect>,
659        T3: fidl::encoding::Encode<i64, fidl::encoding::DefaultFuchsiaResourceDialect>,
660        T4: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
661    >
662        fidl::encoding::Encode<
663            ClientDownloadBlobRequest,
664            fidl::encoding::DefaultFuchsiaResourceDialect,
665        > for (T0, T1, T2, T3, T4)
666    {
667        #[inline]
668        unsafe fn encode(
669            self,
670            encoder: &mut fidl::encoding::Encoder<
671                '_,
672                fidl::encoding::DefaultFuchsiaResourceDialect,
673            >,
674            offset: usize,
675            depth: fidl::encoding::Depth,
676        ) -> fidl::Result<()> {
677            encoder.debug_check_bounds::<ClientDownloadBlobRequest>(offset);
678            // Zero out padding regions. There's no need to apply masks
679            // because the unmasked parts will be overwritten by fields.
680            unsafe {
681                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
682                (ptr as *mut u64).write_unaligned(0);
683            }
684            unsafe {
685                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(40);
686                (ptr as *mut u64).write_unaligned(0);
687            }
688            // Write the fields.
689            self.0.encode(encoder, offset + 0, depth)?;
690            self.1.encode(encoder, offset + 16, depth)?;
691            self.2.encode(encoder, offset + 24, depth)?;
692            self.3.encode(encoder, offset + 32, depth)?;
693            self.4.encode(encoder, offset + 40, depth)?;
694            Ok(())
695        }
696    }
697
698    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
699        for ClientDownloadBlobRequest
700    {
701        #[inline(always)]
702        fn new_empty() -> Self {
703            Self {
704                url: fidl::new_empty!(
705                    fidl::encoding::BoundedString<4096>,
706                    fidl::encoding::DefaultFuchsiaResourceDialect
707                ),
708                destination: fidl::new_empty!(
709                    fidl::encoding::Endpoint<
710                        fidl::endpoints::ClientEnd<fidl_fuchsia_fxfs::BlobWriterMarker>,
711                    >,
712                    fidl::encoding::DefaultFuchsiaResourceDialect
713                ),
714                header_timeout: fidl::new_empty!(
715                    i64,
716                    fidl::encoding::DefaultFuchsiaResourceDialect
717                ),
718                body_timeout: fidl::new_empty!(i64, fidl::encoding::DefaultFuchsiaResourceDialect),
719                resumption_attempt_limit: fidl::new_empty!(
720                    u32,
721                    fidl::encoding::DefaultFuchsiaResourceDialect
722                ),
723            }
724        }
725
726        #[inline]
727        unsafe fn decode(
728            &mut self,
729            decoder: &mut fidl::encoding::Decoder<
730                '_,
731                fidl::encoding::DefaultFuchsiaResourceDialect,
732            >,
733            offset: usize,
734            _depth: fidl::encoding::Depth,
735        ) -> fidl::Result<()> {
736            decoder.debug_check_bounds::<Self>(offset);
737            // Verify that padding bytes are zero.
738            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
739            let padval = unsafe { (ptr as *const u64).read_unaligned() };
740            let mask = 0xffffffff00000000u64;
741            let maskedval = padval & mask;
742            if maskedval != 0 {
743                return Err(fidl::Error::NonZeroPadding {
744                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
745                });
746            }
747            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(40) };
748            let padval = unsafe { (ptr as *const u64).read_unaligned() };
749            let mask = 0xffffffff00000000u64;
750            let maskedval = padval & mask;
751            if maskedval != 0 {
752                return Err(fidl::Error::NonZeroPadding {
753                    padding_start: offset + 40 + ((mask as u64).trailing_zeros() / 8) as usize,
754                });
755            }
756            fidl::decode!(
757                fidl::encoding::BoundedString<4096>,
758                fidl::encoding::DefaultFuchsiaResourceDialect,
759                &mut self.url,
760                decoder,
761                offset + 0,
762                _depth
763            )?;
764            fidl::decode!(
765                fidl::encoding::Endpoint<
766                    fidl::endpoints::ClientEnd<fidl_fuchsia_fxfs::BlobWriterMarker>,
767                >,
768                fidl::encoding::DefaultFuchsiaResourceDialect,
769                &mut self.destination,
770                decoder,
771                offset + 16,
772                _depth
773            )?;
774            fidl::decode!(
775                i64,
776                fidl::encoding::DefaultFuchsiaResourceDialect,
777                &mut self.header_timeout,
778                decoder,
779                offset + 24,
780                _depth
781            )?;
782            fidl::decode!(
783                i64,
784                fidl::encoding::DefaultFuchsiaResourceDialect,
785                &mut self.body_timeout,
786                decoder,
787                offset + 32,
788                _depth
789            )?;
790            fidl::decode!(
791                u32,
792                fidl::encoding::DefaultFuchsiaResourceDialect,
793                &mut self.resumption_attempt_limit,
794                decoder,
795                offset + 40,
796                _depth
797            )?;
798            Ok(())
799        }
800    }
801}