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