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 ClientControlHandle {
491    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
492        self.inner.shutdown_with_epitaph(status.into())
493    }
494}
495
496impl fidl::endpoints::ControlHandle for ClientControlHandle {
497    fn shutdown(&self) {
498        self.inner.shutdown()
499    }
500
501    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
502        self.inner.shutdown_with_epitaph(status)
503    }
504
505    fn is_closed(&self) -> bool {
506        self.inner.channel().is_closed()
507    }
508    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
509        self.inner.channel().on_closed()
510    }
511
512    #[cfg(target_os = "fuchsia")]
513    fn signal_peer(
514        &self,
515        clear_mask: zx::Signals,
516        set_mask: zx::Signals,
517    ) -> Result<(), zx_status::Status> {
518        use fidl::Peered;
519        self.inner.channel().signal_peer(clear_mask, set_mask)
520    }
521}
522
523impl ClientControlHandle {}
524
525#[must_use = "FIDL methods require a response to be sent"]
526#[derive(Debug)]
527pub struct ClientDownloadBlobResponder {
528    control_handle: std::mem::ManuallyDrop<ClientControlHandle>,
529    tx_id: u32,
530}
531
532/// Set the the channel to be shutdown (see [`ClientControlHandle::shutdown`])
533/// if the responder is dropped without sending a response, so that the client
534/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
535impl std::ops::Drop for ClientDownloadBlobResponder {
536    fn drop(&mut self) {
537        self.control_handle.shutdown();
538        // Safety: drops once, never accessed again
539        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
540    }
541}
542
543impl fidl::endpoints::Responder for ClientDownloadBlobResponder {
544    type ControlHandle = ClientControlHandle;
545
546    fn control_handle(&self) -> &ClientControlHandle {
547        &self.control_handle
548    }
549
550    fn drop_without_shutdown(mut self) {
551        // Safety: drops once, never accessed again due to mem::forget
552        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
553        // Prevent Drop from running (which would shut down the channel)
554        std::mem::forget(self);
555    }
556}
557
558impl ClientDownloadBlobResponder {
559    /// Sends a response to the FIDL transaction.
560    ///
561    /// Sets the channel to shutdown if an error occurs.
562    pub fn send(self, mut result: Result<u64, ClientDownloadBlobError>) -> Result<(), fidl::Error> {
563        let _result = self.send_raw(result);
564        if _result.is_err() {
565            self.control_handle.shutdown();
566        }
567        self.drop_without_shutdown();
568        _result
569    }
570
571    /// Similar to "send" but does not shutdown the channel if an error occurs.
572    pub fn send_no_shutdown_on_err(
573        self,
574        mut result: Result<u64, ClientDownloadBlobError>,
575    ) -> Result<(), fidl::Error> {
576        let _result = self.send_raw(result);
577        self.drop_without_shutdown();
578        _result
579    }
580
581    fn send_raw(
582        &self,
583        mut result: Result<u64, ClientDownloadBlobError>,
584    ) -> Result<(), fidl::Error> {
585        self.control_handle.inner.send::<fidl::encoding::ResultType<
586            ClientDownloadBlobResponse,
587            ClientDownloadBlobError,
588        >>(
589            result.map(|size| (size,)),
590            self.tx_id,
591            0x829250010b00abb,
592            fidl::encoding::DynamicFlags::empty(),
593        )
594    }
595}
596
597mod internal {
598    use super::*;
599
600    impl fidl::encoding::ResourceTypeMarker for ClientDownloadBlobRequest {
601        type Borrowed<'a> = &'a mut Self;
602        fn take_or_borrow<'a>(
603            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
604        ) -> Self::Borrowed<'a> {
605            value
606        }
607    }
608
609    unsafe impl fidl::encoding::TypeMarker for ClientDownloadBlobRequest {
610        type Owned = Self;
611
612        #[inline(always)]
613        fn inline_align(_context: fidl::encoding::Context) -> usize {
614            8
615        }
616
617        #[inline(always)]
618        fn inline_size(_context: fidl::encoding::Context) -> usize {
619            48
620        }
621    }
622
623    unsafe impl
624        fidl::encoding::Encode<
625            ClientDownloadBlobRequest,
626            fidl::encoding::DefaultFuchsiaResourceDialect,
627        > for &mut ClientDownloadBlobRequest
628    {
629        #[inline]
630        unsafe fn encode(
631            self,
632            encoder: &mut fidl::encoding::Encoder<
633                '_,
634                fidl::encoding::DefaultFuchsiaResourceDialect,
635            >,
636            offset: usize,
637            _depth: fidl::encoding::Depth,
638        ) -> fidl::Result<()> {
639            encoder.debug_check_bounds::<ClientDownloadBlobRequest>(offset);
640            // Delegate to tuple encoding.
641            fidl::encoding::Encode::<ClientDownloadBlobRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
642                (
643                    <fidl::encoding::BoundedString<4096> as fidl::encoding::ValueTypeMarker>::borrow(&self.url),
644                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_fxfs::BlobWriterMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.destination),
645                    <i64 as fidl::encoding::ValueTypeMarker>::borrow(&self.header_timeout),
646                    <i64 as fidl::encoding::ValueTypeMarker>::borrow(&self.body_timeout),
647                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.resumption_attempt_limit),
648                ),
649                encoder, offset, _depth
650            )
651        }
652    }
653    unsafe impl<
654        T0: fidl::encoding::Encode<
655                fidl::encoding::BoundedString<4096>,
656                fidl::encoding::DefaultFuchsiaResourceDialect,
657            >,
658        T1: fidl::encoding::Encode<
659                fidl::encoding::Endpoint<
660                    fidl::endpoints::ClientEnd<fidl_fuchsia_fxfs::BlobWriterMarker>,
661                >,
662                fidl::encoding::DefaultFuchsiaResourceDialect,
663            >,
664        T2: fidl::encoding::Encode<i64, fidl::encoding::DefaultFuchsiaResourceDialect>,
665        T3: fidl::encoding::Encode<i64, fidl::encoding::DefaultFuchsiaResourceDialect>,
666        T4: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
667    >
668        fidl::encoding::Encode<
669            ClientDownloadBlobRequest,
670            fidl::encoding::DefaultFuchsiaResourceDialect,
671        > for (T0, T1, T2, T3, T4)
672    {
673        #[inline]
674        unsafe fn encode(
675            self,
676            encoder: &mut fidl::encoding::Encoder<
677                '_,
678                fidl::encoding::DefaultFuchsiaResourceDialect,
679            >,
680            offset: usize,
681            depth: fidl::encoding::Depth,
682        ) -> fidl::Result<()> {
683            encoder.debug_check_bounds::<ClientDownloadBlobRequest>(offset);
684            // Zero out padding regions. There's no need to apply masks
685            // because the unmasked parts will be overwritten by fields.
686            unsafe {
687                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
688                (ptr as *mut u64).write_unaligned(0);
689            }
690            unsafe {
691                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(40);
692                (ptr as *mut u64).write_unaligned(0);
693            }
694            // Write the fields.
695            self.0.encode(encoder, offset + 0, depth)?;
696            self.1.encode(encoder, offset + 16, depth)?;
697            self.2.encode(encoder, offset + 24, depth)?;
698            self.3.encode(encoder, offset + 32, depth)?;
699            self.4.encode(encoder, offset + 40, depth)?;
700            Ok(())
701        }
702    }
703
704    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
705        for ClientDownloadBlobRequest
706    {
707        #[inline(always)]
708        fn new_empty() -> Self {
709            Self {
710                url: fidl::new_empty!(
711                    fidl::encoding::BoundedString<4096>,
712                    fidl::encoding::DefaultFuchsiaResourceDialect
713                ),
714                destination: fidl::new_empty!(
715                    fidl::encoding::Endpoint<
716                        fidl::endpoints::ClientEnd<fidl_fuchsia_fxfs::BlobWriterMarker>,
717                    >,
718                    fidl::encoding::DefaultFuchsiaResourceDialect
719                ),
720                header_timeout: fidl::new_empty!(
721                    i64,
722                    fidl::encoding::DefaultFuchsiaResourceDialect
723                ),
724                body_timeout: fidl::new_empty!(i64, fidl::encoding::DefaultFuchsiaResourceDialect),
725                resumption_attempt_limit: fidl::new_empty!(
726                    u32,
727                    fidl::encoding::DefaultFuchsiaResourceDialect
728                ),
729            }
730        }
731
732        #[inline]
733        unsafe fn decode(
734            &mut self,
735            decoder: &mut fidl::encoding::Decoder<
736                '_,
737                fidl::encoding::DefaultFuchsiaResourceDialect,
738            >,
739            offset: usize,
740            _depth: fidl::encoding::Depth,
741        ) -> fidl::Result<()> {
742            decoder.debug_check_bounds::<Self>(offset);
743            // Verify that padding bytes are zero.
744            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
745            let padval = unsafe { (ptr as *const u64).read_unaligned() };
746            let mask = 0xffffffff00000000u64;
747            let maskedval = padval & mask;
748            if maskedval != 0 {
749                return Err(fidl::Error::NonZeroPadding {
750                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
751                });
752            }
753            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(40) };
754            let padval = unsafe { (ptr as *const u64).read_unaligned() };
755            let mask = 0xffffffff00000000u64;
756            let maskedval = padval & mask;
757            if maskedval != 0 {
758                return Err(fidl::Error::NonZeroPadding {
759                    padding_start: offset + 40 + ((mask as u64).trailing_zeros() / 8) as usize,
760                });
761            }
762            fidl::decode!(
763                fidl::encoding::BoundedString<4096>,
764                fidl::encoding::DefaultFuchsiaResourceDialect,
765                &mut self.url,
766                decoder,
767                offset + 0,
768                _depth
769            )?;
770            fidl::decode!(
771                fidl::encoding::Endpoint<
772                    fidl::endpoints::ClientEnd<fidl_fuchsia_fxfs::BlobWriterMarker>,
773                >,
774                fidl::encoding::DefaultFuchsiaResourceDialect,
775                &mut self.destination,
776                decoder,
777                offset + 16,
778                _depth
779            )?;
780            fidl::decode!(
781                i64,
782                fidl::encoding::DefaultFuchsiaResourceDialect,
783                &mut self.header_timeout,
784                decoder,
785                offset + 24,
786                _depth
787            )?;
788            fidl::decode!(
789                i64,
790                fidl::encoding::DefaultFuchsiaResourceDialect,
791                &mut self.body_timeout,
792                decoder,
793                offset + 32,
794                _depth
795            )?;
796            fidl::decode!(
797                u32,
798                fidl::encoding::DefaultFuchsiaResourceDialect,
799                &mut self.resumption_attempt_limit,
800                decoder,
801                offset + 40,
802                _depth
803            )?;
804            Ok(())
805        }
806    }
807}