fidl_fuchsia_pkg/
fidl_fuchsia_pkg.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__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct FontResolverResolveRequest {
16    pub package_url: String,
17    pub directory_request: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
21    for FontResolverResolveRequest
22{
23}
24
25#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
26pub struct NeededBlobsGetMissingBlobsRequest {
27    pub iterator: fidl::endpoints::ServerEnd<BlobInfoIteratorMarker>,
28}
29
30impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
31    for NeededBlobsGetMissingBlobsRequest
32{
33}
34
35#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
36pub struct NeededBlobsOpenBlobResponse {
37    pub writer: Option<Box<BlobWriter>>,
38}
39
40impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
41    for NeededBlobsOpenBlobResponse
42{
43}
44
45#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
46pub struct NeededBlobsOpenMetaBlobResponse {
47    pub writer: Option<Box<BlobWriter>>,
48}
49
50impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
51    for NeededBlobsOpenMetaBlobResponse
52{
53}
54
55#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
56pub struct PackageCacheBasePackageIndexRequest {
57    pub iterator: fidl::endpoints::ServerEnd<PackageIndexIteratorMarker>,
58}
59
60impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
61    for PackageCacheBasePackageIndexRequest
62{
63}
64
65#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
66pub struct PackageCacheCachePackageIndexRequest {
67    pub iterator: fidl::endpoints::ServerEnd<PackageIndexIteratorMarker>,
68}
69
70impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
71    for PackageCacheCachePackageIndexRequest
72{
73}
74
75#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
76pub struct PackageCacheGetRequest {
77    pub meta_far_blob: BlobInfo,
78    pub gc_protection: GcProtection,
79    pub needed_blobs: fidl::endpoints::ServerEnd<NeededBlobsMarker>,
80    pub dir: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
81}
82
83impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for PackageCacheGetRequest {}
84
85#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
86pub struct PackageCacheGetSubpackageRequest {
87    pub superpackage: BlobId,
88    pub subpackage: PackageUrl,
89    pub dir: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
90}
91
92impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
93    for PackageCacheGetSubpackageRequest
94{
95}
96
97#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
98pub struct PackageResolverResolveRequest {
99    pub package_url: String,
100    pub dir: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
101}
102
103impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
104    for PackageResolverResolveRequest
105{
106}
107
108#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
109pub struct PackageResolverResolveWithContextRequest {
110    pub package_url: String,
111    pub context: ResolutionContext,
112    pub dir: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
113}
114
115impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
116    for PackageResolverResolveWithContextRequest
117{
118}
119
120#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
121pub struct RepositoryManagerListRequest {
122    pub iterator: fidl::endpoints::ServerEnd<RepositoryIteratorMarker>,
123}
124
125impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
126    for RepositoryManagerListRequest
127{
128}
129
130#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
131pub struct RetainedPackagesReplaceRequest {
132    pub iterator: fidl::endpoints::ClientEnd<BlobIdIteratorMarker>,
133}
134
135impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
136    for RetainedPackagesReplaceRequest
137{
138}
139
140/// Used to write a blob to the underlying storage.
141#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
142pub enum BlobWriter {
143    /// To write a blob with `file`:
144    ///   1. If the blob is uncompressed, use `fuchsia.io/File.Resize` to set
145    ///      the blob's uncompressed size.
146    ///   2. Use `fuchsia.io/File.Write` to write the blob's contents from
147    ///      start to finish (seeks are not supported).
148    /// A corrupt blob is indicated by a `Write()` (usually the final write),
149    /// failing with `ZX_ERR_IO_DATA_INTEGRITY`.
150    File(fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>),
151    /// To write a blob with `writer`, follow the instructions on the
152    /// `fuchsia.fxfs.BlobWriter` protocol.
153    Writer(fidl::endpoints::ClientEnd<fidl_fuchsia_fxfs::BlobWriterMarker>),
154}
155
156impl BlobWriter {
157    #[inline]
158    pub fn ordinal(&self) -> u64 {
159        match *self {
160            Self::File(_) => 1,
161            Self::Writer(_) => 2,
162        }
163    }
164}
165
166impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for BlobWriter {}
167
168#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
169pub struct BlobIdIteratorMarker;
170
171impl fidl::endpoints::ProtocolMarker for BlobIdIteratorMarker {
172    type Proxy = BlobIdIteratorProxy;
173    type RequestStream = BlobIdIteratorRequestStream;
174    #[cfg(target_os = "fuchsia")]
175    type SynchronousProxy = BlobIdIteratorSynchronousProxy;
176
177    const DEBUG_NAME: &'static str = "(anonymous) BlobIdIterator";
178}
179
180pub trait BlobIdIteratorProxyInterface: Send + Sync {
181    type NextResponseFut: std::future::Future<Output = Result<Vec<BlobId>, fidl::Error>> + Send;
182    fn r#next(&self) -> Self::NextResponseFut;
183}
184#[derive(Debug)]
185#[cfg(target_os = "fuchsia")]
186pub struct BlobIdIteratorSynchronousProxy {
187    client: fidl::client::sync::Client,
188}
189
190#[cfg(target_os = "fuchsia")]
191impl fidl::endpoints::SynchronousProxy for BlobIdIteratorSynchronousProxy {
192    type Proxy = BlobIdIteratorProxy;
193    type Protocol = BlobIdIteratorMarker;
194
195    fn from_channel(inner: fidl::Channel) -> Self {
196        Self::new(inner)
197    }
198
199    fn into_channel(self) -> fidl::Channel {
200        self.client.into_channel()
201    }
202
203    fn as_channel(&self) -> &fidl::Channel {
204        self.client.as_channel()
205    }
206}
207
208#[cfg(target_os = "fuchsia")]
209impl BlobIdIteratorSynchronousProxy {
210    pub fn new(channel: fidl::Channel) -> Self {
211        let protocol_name = <BlobIdIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
212        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
213    }
214
215    pub fn into_channel(self) -> fidl::Channel {
216        self.client.into_channel()
217    }
218
219    /// Waits until an event arrives and returns it. It is safe for other
220    /// threads to make concurrent requests while waiting for an event.
221    pub fn wait_for_event(
222        &self,
223        deadline: zx::MonotonicInstant,
224    ) -> Result<BlobIdIteratorEvent, fidl::Error> {
225        BlobIdIteratorEvent::decode(self.client.wait_for_event(deadline)?)
226    }
227
228    /// Responds with the next chunk of blob IDs. When the iterator is
229    /// exhausted, responds with an empty vector and closes the connection.
230    ///
231    /// - response `blobs` the next chunk of blob IDs.
232    pub fn r#next(&self, ___deadline: zx::MonotonicInstant) -> Result<Vec<BlobId>, fidl::Error> {
233        let _response =
234            self.client.send_query::<fidl::encoding::EmptyPayload, BlobIdIteratorNextResponse>(
235                (),
236                0x5eb0af0daeb8f537,
237                fidl::encoding::DynamicFlags::empty(),
238                ___deadline,
239            )?;
240        Ok(_response.blobs)
241    }
242}
243
244#[cfg(target_os = "fuchsia")]
245impl From<BlobIdIteratorSynchronousProxy> for zx::Handle {
246    fn from(value: BlobIdIteratorSynchronousProxy) -> Self {
247        value.into_channel().into()
248    }
249}
250
251#[cfg(target_os = "fuchsia")]
252impl From<fidl::Channel> for BlobIdIteratorSynchronousProxy {
253    fn from(value: fidl::Channel) -> Self {
254        Self::new(value)
255    }
256}
257
258#[derive(Debug, Clone)]
259pub struct BlobIdIteratorProxy {
260    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
261}
262
263impl fidl::endpoints::Proxy for BlobIdIteratorProxy {
264    type Protocol = BlobIdIteratorMarker;
265
266    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
267        Self::new(inner)
268    }
269
270    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
271        self.client.into_channel().map_err(|client| Self { client })
272    }
273
274    fn as_channel(&self) -> &::fidl::AsyncChannel {
275        self.client.as_channel()
276    }
277}
278
279impl BlobIdIteratorProxy {
280    /// Create a new Proxy for fuchsia.pkg/BlobIdIterator.
281    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
282        let protocol_name = <BlobIdIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
283        Self { client: fidl::client::Client::new(channel, protocol_name) }
284    }
285
286    /// Get a Stream of events from the remote end of the protocol.
287    ///
288    /// # Panics
289    ///
290    /// Panics if the event stream was already taken.
291    pub fn take_event_stream(&self) -> BlobIdIteratorEventStream {
292        BlobIdIteratorEventStream { event_receiver: self.client.take_event_receiver() }
293    }
294
295    /// Responds with the next chunk of blob IDs. When the iterator is
296    /// exhausted, responds with an empty vector and closes the connection.
297    ///
298    /// - response `blobs` the next chunk of blob IDs.
299    pub fn r#next(
300        &self,
301    ) -> fidl::client::QueryResponseFut<Vec<BlobId>, fidl::encoding::DefaultFuchsiaResourceDialect>
302    {
303        BlobIdIteratorProxyInterface::r#next(self)
304    }
305}
306
307impl BlobIdIteratorProxyInterface for BlobIdIteratorProxy {
308    type NextResponseFut =
309        fidl::client::QueryResponseFut<Vec<BlobId>, fidl::encoding::DefaultFuchsiaResourceDialect>;
310    fn r#next(&self) -> Self::NextResponseFut {
311        fn _decode(
312            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
313        ) -> Result<Vec<BlobId>, fidl::Error> {
314            let _response = fidl::client::decode_transaction_body::<
315                BlobIdIteratorNextResponse,
316                fidl::encoding::DefaultFuchsiaResourceDialect,
317                0x5eb0af0daeb8f537,
318            >(_buf?)?;
319            Ok(_response.blobs)
320        }
321        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<BlobId>>(
322            (),
323            0x5eb0af0daeb8f537,
324            fidl::encoding::DynamicFlags::empty(),
325            _decode,
326        )
327    }
328}
329
330pub struct BlobIdIteratorEventStream {
331    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
332}
333
334impl std::marker::Unpin for BlobIdIteratorEventStream {}
335
336impl futures::stream::FusedStream for BlobIdIteratorEventStream {
337    fn is_terminated(&self) -> bool {
338        self.event_receiver.is_terminated()
339    }
340}
341
342impl futures::Stream for BlobIdIteratorEventStream {
343    type Item = Result<BlobIdIteratorEvent, fidl::Error>;
344
345    fn poll_next(
346        mut self: std::pin::Pin<&mut Self>,
347        cx: &mut std::task::Context<'_>,
348    ) -> std::task::Poll<Option<Self::Item>> {
349        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
350            &mut self.event_receiver,
351            cx
352        )?) {
353            Some(buf) => std::task::Poll::Ready(Some(BlobIdIteratorEvent::decode(buf))),
354            None => std::task::Poll::Ready(None),
355        }
356    }
357}
358
359#[derive(Debug)]
360pub enum BlobIdIteratorEvent {}
361
362impl BlobIdIteratorEvent {
363    /// Decodes a message buffer as a [`BlobIdIteratorEvent`].
364    fn decode(
365        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
366    ) -> Result<BlobIdIteratorEvent, fidl::Error> {
367        let (bytes, _handles) = buf.split_mut();
368        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
369        debug_assert_eq!(tx_header.tx_id, 0);
370        match tx_header.ordinal {
371            _ => Err(fidl::Error::UnknownOrdinal {
372                ordinal: tx_header.ordinal,
373                protocol_name:
374                    <BlobIdIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
375            }),
376        }
377    }
378}
379
380/// A Stream of incoming requests for fuchsia.pkg/BlobIdIterator.
381pub struct BlobIdIteratorRequestStream {
382    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
383    is_terminated: bool,
384}
385
386impl std::marker::Unpin for BlobIdIteratorRequestStream {}
387
388impl futures::stream::FusedStream for BlobIdIteratorRequestStream {
389    fn is_terminated(&self) -> bool {
390        self.is_terminated
391    }
392}
393
394impl fidl::endpoints::RequestStream for BlobIdIteratorRequestStream {
395    type Protocol = BlobIdIteratorMarker;
396    type ControlHandle = BlobIdIteratorControlHandle;
397
398    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
399        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
400    }
401
402    fn control_handle(&self) -> Self::ControlHandle {
403        BlobIdIteratorControlHandle { inner: self.inner.clone() }
404    }
405
406    fn into_inner(
407        self,
408    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
409    {
410        (self.inner, self.is_terminated)
411    }
412
413    fn from_inner(
414        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
415        is_terminated: bool,
416    ) -> Self {
417        Self { inner, is_terminated }
418    }
419}
420
421impl futures::Stream for BlobIdIteratorRequestStream {
422    type Item = Result<BlobIdIteratorRequest, fidl::Error>;
423
424    fn poll_next(
425        mut self: std::pin::Pin<&mut Self>,
426        cx: &mut std::task::Context<'_>,
427    ) -> std::task::Poll<Option<Self::Item>> {
428        let this = &mut *self;
429        if this.inner.check_shutdown(cx) {
430            this.is_terminated = true;
431            return std::task::Poll::Ready(None);
432        }
433        if this.is_terminated {
434            panic!("polled BlobIdIteratorRequestStream after completion");
435        }
436        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
437            |bytes, handles| {
438                match this.inner.channel().read_etc(cx, bytes, handles) {
439                    std::task::Poll::Ready(Ok(())) => {}
440                    std::task::Poll::Pending => return std::task::Poll::Pending,
441                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
442                        this.is_terminated = true;
443                        return std::task::Poll::Ready(None);
444                    }
445                    std::task::Poll::Ready(Err(e)) => {
446                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
447                            e.into(),
448                        ))))
449                    }
450                }
451
452                // A message has been received from the channel
453                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
454
455                std::task::Poll::Ready(Some(match header.ordinal {
456                    0x5eb0af0daeb8f537 => {
457                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
458                        let mut req = fidl::new_empty!(
459                            fidl::encoding::EmptyPayload,
460                            fidl::encoding::DefaultFuchsiaResourceDialect
461                        );
462                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
463                        let control_handle =
464                            BlobIdIteratorControlHandle { inner: this.inner.clone() };
465                        Ok(BlobIdIteratorRequest::Next {
466                            responder: BlobIdIteratorNextResponder {
467                                control_handle: std::mem::ManuallyDrop::new(control_handle),
468                                tx_id: header.tx_id,
469                            },
470                        })
471                    }
472                    _ => Err(fidl::Error::UnknownOrdinal {
473                        ordinal: header.ordinal,
474                        protocol_name:
475                            <BlobIdIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
476                    }),
477                }))
478            },
479        )
480    }
481}
482
483/// A chunked iterator of blob IDs, allowing transfer of more blob IDs that can
484/// fit in a single FIDL message.
485#[derive(Debug)]
486pub enum BlobIdIteratorRequest {
487    /// Responds with the next chunk of blob IDs. When the iterator is
488    /// exhausted, responds with an empty vector and closes the connection.
489    ///
490    /// - response `blobs` the next chunk of blob IDs.
491    Next { responder: BlobIdIteratorNextResponder },
492}
493
494impl BlobIdIteratorRequest {
495    #[allow(irrefutable_let_patterns)]
496    pub fn into_next(self) -> Option<(BlobIdIteratorNextResponder)> {
497        if let BlobIdIteratorRequest::Next { responder } = self {
498            Some((responder))
499        } else {
500            None
501        }
502    }
503
504    /// Name of the method defined in FIDL
505    pub fn method_name(&self) -> &'static str {
506        match *self {
507            BlobIdIteratorRequest::Next { .. } => "next",
508        }
509    }
510}
511
512#[derive(Debug, Clone)]
513pub struct BlobIdIteratorControlHandle {
514    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
515}
516
517impl fidl::endpoints::ControlHandle for BlobIdIteratorControlHandle {
518    fn shutdown(&self) {
519        self.inner.shutdown()
520    }
521    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
522        self.inner.shutdown_with_epitaph(status)
523    }
524
525    fn is_closed(&self) -> bool {
526        self.inner.channel().is_closed()
527    }
528    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
529        self.inner.channel().on_closed()
530    }
531
532    #[cfg(target_os = "fuchsia")]
533    fn signal_peer(
534        &self,
535        clear_mask: zx::Signals,
536        set_mask: zx::Signals,
537    ) -> Result<(), zx_status::Status> {
538        use fidl::Peered;
539        self.inner.channel().signal_peer(clear_mask, set_mask)
540    }
541}
542
543impl BlobIdIteratorControlHandle {}
544
545#[must_use = "FIDL methods require a response to be sent"]
546#[derive(Debug)]
547pub struct BlobIdIteratorNextResponder {
548    control_handle: std::mem::ManuallyDrop<BlobIdIteratorControlHandle>,
549    tx_id: u32,
550}
551
552/// Set the the channel to be shutdown (see [`BlobIdIteratorControlHandle::shutdown`])
553/// if the responder is dropped without sending a response, so that the client
554/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
555impl std::ops::Drop for BlobIdIteratorNextResponder {
556    fn drop(&mut self) {
557        self.control_handle.shutdown();
558        // Safety: drops once, never accessed again
559        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
560    }
561}
562
563impl fidl::endpoints::Responder for BlobIdIteratorNextResponder {
564    type ControlHandle = BlobIdIteratorControlHandle;
565
566    fn control_handle(&self) -> &BlobIdIteratorControlHandle {
567        &self.control_handle
568    }
569
570    fn drop_without_shutdown(mut self) {
571        // Safety: drops once, never accessed again due to mem::forget
572        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
573        // Prevent Drop from running (which would shut down the channel)
574        std::mem::forget(self);
575    }
576}
577
578impl BlobIdIteratorNextResponder {
579    /// Sends a response to the FIDL transaction.
580    ///
581    /// Sets the channel to shutdown if an error occurs.
582    pub fn send(self, mut blobs: &[BlobId]) -> Result<(), fidl::Error> {
583        let _result = self.send_raw(blobs);
584        if _result.is_err() {
585            self.control_handle.shutdown();
586        }
587        self.drop_without_shutdown();
588        _result
589    }
590
591    /// Similar to "send" but does not shutdown the channel if an error occurs.
592    pub fn send_no_shutdown_on_err(self, mut blobs: &[BlobId]) -> Result<(), fidl::Error> {
593        let _result = self.send_raw(blobs);
594        self.drop_without_shutdown();
595        _result
596    }
597
598    fn send_raw(&self, mut blobs: &[BlobId]) -> Result<(), fidl::Error> {
599        self.control_handle.inner.send::<BlobIdIteratorNextResponse>(
600            (blobs,),
601            self.tx_id,
602            0x5eb0af0daeb8f537,
603            fidl::encoding::DynamicFlags::empty(),
604        )
605    }
606}
607
608#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
609pub struct BlobInfoIteratorMarker;
610
611impl fidl::endpoints::ProtocolMarker for BlobInfoIteratorMarker {
612    type Proxy = BlobInfoIteratorProxy;
613    type RequestStream = BlobInfoIteratorRequestStream;
614    #[cfg(target_os = "fuchsia")]
615    type SynchronousProxy = BlobInfoIteratorSynchronousProxy;
616
617    const DEBUG_NAME: &'static str = "(anonymous) BlobInfoIterator";
618}
619
620pub trait BlobInfoIteratorProxyInterface: Send + Sync {
621    type NextResponseFut: std::future::Future<Output = Result<Vec<BlobInfo>, fidl::Error>> + Send;
622    fn r#next(&self) -> Self::NextResponseFut;
623}
624#[derive(Debug)]
625#[cfg(target_os = "fuchsia")]
626pub struct BlobInfoIteratorSynchronousProxy {
627    client: fidl::client::sync::Client,
628}
629
630#[cfg(target_os = "fuchsia")]
631impl fidl::endpoints::SynchronousProxy for BlobInfoIteratorSynchronousProxy {
632    type Proxy = BlobInfoIteratorProxy;
633    type Protocol = BlobInfoIteratorMarker;
634
635    fn from_channel(inner: fidl::Channel) -> Self {
636        Self::new(inner)
637    }
638
639    fn into_channel(self) -> fidl::Channel {
640        self.client.into_channel()
641    }
642
643    fn as_channel(&self) -> &fidl::Channel {
644        self.client.as_channel()
645    }
646}
647
648#[cfg(target_os = "fuchsia")]
649impl BlobInfoIteratorSynchronousProxy {
650    pub fn new(channel: fidl::Channel) -> Self {
651        let protocol_name = <BlobInfoIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
652        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
653    }
654
655    pub fn into_channel(self) -> fidl::Channel {
656        self.client.into_channel()
657    }
658
659    /// Waits until an event arrives and returns it. It is safe for other
660    /// threads to make concurrent requests while waiting for an event.
661    pub fn wait_for_event(
662        &self,
663        deadline: zx::MonotonicInstant,
664    ) -> Result<BlobInfoIteratorEvent, fidl::Error> {
665        BlobInfoIteratorEvent::decode(self.client.wait_for_event(deadline)?)
666    }
667
668    /// Responds with the next chunk of [`BlobInfo`]s. When the iterator is
669    /// exhausted, responds with an empty vector and closes the connection.
670    ///
671    /// - response `blobs` the next chunk of [`BlobInfo`]s.
672    pub fn r#next(&self, ___deadline: zx::MonotonicInstant) -> Result<Vec<BlobInfo>, fidl::Error> {
673        let _response =
674            self.client.send_query::<fidl::encoding::EmptyPayload, BlobInfoIteratorNextResponse>(
675                (),
676                0x2b889489a59b6970,
677                fidl::encoding::DynamicFlags::empty(),
678                ___deadline,
679            )?;
680        Ok(_response.blobs)
681    }
682}
683
684#[cfg(target_os = "fuchsia")]
685impl From<BlobInfoIteratorSynchronousProxy> for zx::Handle {
686    fn from(value: BlobInfoIteratorSynchronousProxy) -> Self {
687        value.into_channel().into()
688    }
689}
690
691#[cfg(target_os = "fuchsia")]
692impl From<fidl::Channel> for BlobInfoIteratorSynchronousProxy {
693    fn from(value: fidl::Channel) -> Self {
694        Self::new(value)
695    }
696}
697
698#[derive(Debug, Clone)]
699pub struct BlobInfoIteratorProxy {
700    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
701}
702
703impl fidl::endpoints::Proxy for BlobInfoIteratorProxy {
704    type Protocol = BlobInfoIteratorMarker;
705
706    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
707        Self::new(inner)
708    }
709
710    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
711        self.client.into_channel().map_err(|client| Self { client })
712    }
713
714    fn as_channel(&self) -> &::fidl::AsyncChannel {
715        self.client.as_channel()
716    }
717}
718
719impl BlobInfoIteratorProxy {
720    /// Create a new Proxy for fuchsia.pkg/BlobInfoIterator.
721    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
722        let protocol_name = <BlobInfoIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
723        Self { client: fidl::client::Client::new(channel, protocol_name) }
724    }
725
726    /// Get a Stream of events from the remote end of the protocol.
727    ///
728    /// # Panics
729    ///
730    /// Panics if the event stream was already taken.
731    pub fn take_event_stream(&self) -> BlobInfoIteratorEventStream {
732        BlobInfoIteratorEventStream { event_receiver: self.client.take_event_receiver() }
733    }
734
735    /// Responds with the next chunk of [`BlobInfo`]s. When the iterator is
736    /// exhausted, responds with an empty vector and closes the connection.
737    ///
738    /// - response `blobs` the next chunk of [`BlobInfo`]s.
739    pub fn r#next(
740        &self,
741    ) -> fidl::client::QueryResponseFut<Vec<BlobInfo>, fidl::encoding::DefaultFuchsiaResourceDialect>
742    {
743        BlobInfoIteratorProxyInterface::r#next(self)
744    }
745}
746
747impl BlobInfoIteratorProxyInterface for BlobInfoIteratorProxy {
748    type NextResponseFut = fidl::client::QueryResponseFut<
749        Vec<BlobInfo>,
750        fidl::encoding::DefaultFuchsiaResourceDialect,
751    >;
752    fn r#next(&self) -> Self::NextResponseFut {
753        fn _decode(
754            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
755        ) -> Result<Vec<BlobInfo>, fidl::Error> {
756            let _response = fidl::client::decode_transaction_body::<
757                BlobInfoIteratorNextResponse,
758                fidl::encoding::DefaultFuchsiaResourceDialect,
759                0x2b889489a59b6970,
760            >(_buf?)?;
761            Ok(_response.blobs)
762        }
763        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<BlobInfo>>(
764            (),
765            0x2b889489a59b6970,
766            fidl::encoding::DynamicFlags::empty(),
767            _decode,
768        )
769    }
770}
771
772pub struct BlobInfoIteratorEventStream {
773    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
774}
775
776impl std::marker::Unpin for BlobInfoIteratorEventStream {}
777
778impl futures::stream::FusedStream for BlobInfoIteratorEventStream {
779    fn is_terminated(&self) -> bool {
780        self.event_receiver.is_terminated()
781    }
782}
783
784impl futures::Stream for BlobInfoIteratorEventStream {
785    type Item = Result<BlobInfoIteratorEvent, fidl::Error>;
786
787    fn poll_next(
788        mut self: std::pin::Pin<&mut Self>,
789        cx: &mut std::task::Context<'_>,
790    ) -> std::task::Poll<Option<Self::Item>> {
791        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
792            &mut self.event_receiver,
793            cx
794        )?) {
795            Some(buf) => std::task::Poll::Ready(Some(BlobInfoIteratorEvent::decode(buf))),
796            None => std::task::Poll::Ready(None),
797        }
798    }
799}
800
801#[derive(Debug)]
802pub enum BlobInfoIteratorEvent {}
803
804impl BlobInfoIteratorEvent {
805    /// Decodes a message buffer as a [`BlobInfoIteratorEvent`].
806    fn decode(
807        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
808    ) -> Result<BlobInfoIteratorEvent, fidl::Error> {
809        let (bytes, _handles) = buf.split_mut();
810        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
811        debug_assert_eq!(tx_header.tx_id, 0);
812        match tx_header.ordinal {
813            _ => Err(fidl::Error::UnknownOrdinal {
814                ordinal: tx_header.ordinal,
815                protocol_name:
816                    <BlobInfoIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
817            }),
818        }
819    }
820}
821
822/// A Stream of incoming requests for fuchsia.pkg/BlobInfoIterator.
823pub struct BlobInfoIteratorRequestStream {
824    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
825    is_terminated: bool,
826}
827
828impl std::marker::Unpin for BlobInfoIteratorRequestStream {}
829
830impl futures::stream::FusedStream for BlobInfoIteratorRequestStream {
831    fn is_terminated(&self) -> bool {
832        self.is_terminated
833    }
834}
835
836impl fidl::endpoints::RequestStream for BlobInfoIteratorRequestStream {
837    type Protocol = BlobInfoIteratorMarker;
838    type ControlHandle = BlobInfoIteratorControlHandle;
839
840    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
841        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
842    }
843
844    fn control_handle(&self) -> Self::ControlHandle {
845        BlobInfoIteratorControlHandle { inner: self.inner.clone() }
846    }
847
848    fn into_inner(
849        self,
850    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
851    {
852        (self.inner, self.is_terminated)
853    }
854
855    fn from_inner(
856        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
857        is_terminated: bool,
858    ) -> Self {
859        Self { inner, is_terminated }
860    }
861}
862
863impl futures::Stream for BlobInfoIteratorRequestStream {
864    type Item = Result<BlobInfoIteratorRequest, fidl::Error>;
865
866    fn poll_next(
867        mut self: std::pin::Pin<&mut Self>,
868        cx: &mut std::task::Context<'_>,
869    ) -> std::task::Poll<Option<Self::Item>> {
870        let this = &mut *self;
871        if this.inner.check_shutdown(cx) {
872            this.is_terminated = true;
873            return std::task::Poll::Ready(None);
874        }
875        if this.is_terminated {
876            panic!("polled BlobInfoIteratorRequestStream after completion");
877        }
878        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
879            |bytes, handles| {
880                match this.inner.channel().read_etc(cx, bytes, handles) {
881                    std::task::Poll::Ready(Ok(())) => {}
882                    std::task::Poll::Pending => return std::task::Poll::Pending,
883                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
884                        this.is_terminated = true;
885                        return std::task::Poll::Ready(None);
886                    }
887                    std::task::Poll::Ready(Err(e)) => {
888                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
889                            e.into(),
890                        ))))
891                    }
892                }
893
894                // A message has been received from the channel
895                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
896
897                std::task::Poll::Ready(Some(match header.ordinal {
898                    0x2b889489a59b6970 => {
899                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
900                        let mut req = fidl::new_empty!(
901                            fidl::encoding::EmptyPayload,
902                            fidl::encoding::DefaultFuchsiaResourceDialect
903                        );
904                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
905                        let control_handle =
906                            BlobInfoIteratorControlHandle { inner: this.inner.clone() };
907                        Ok(BlobInfoIteratorRequest::Next {
908                            responder: BlobInfoIteratorNextResponder {
909                                control_handle: std::mem::ManuallyDrop::new(control_handle),
910                                tx_id: header.tx_id,
911                            },
912                        })
913                    }
914                    _ => Err(fidl::Error::UnknownOrdinal {
915                        ordinal: header.ordinal,
916                        protocol_name:
917                            <BlobInfoIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
918                    }),
919                }))
920            },
921        )
922    }
923}
924
925/// A chunked iterator of [`BlobInfo`], allowing transfer of more [`BlobInfo`]s
926/// that can fit in a single FIDL message.
927#[derive(Debug)]
928pub enum BlobInfoIteratorRequest {
929    /// Responds with the next chunk of [`BlobInfo`]s. When the iterator is
930    /// exhausted, responds with an empty vector and closes the connection.
931    ///
932    /// - response `blobs` the next chunk of [`BlobInfo`]s.
933    Next { responder: BlobInfoIteratorNextResponder },
934}
935
936impl BlobInfoIteratorRequest {
937    #[allow(irrefutable_let_patterns)]
938    pub fn into_next(self) -> Option<(BlobInfoIteratorNextResponder)> {
939        if let BlobInfoIteratorRequest::Next { responder } = self {
940            Some((responder))
941        } else {
942            None
943        }
944    }
945
946    /// Name of the method defined in FIDL
947    pub fn method_name(&self) -> &'static str {
948        match *self {
949            BlobInfoIteratorRequest::Next { .. } => "next",
950        }
951    }
952}
953
954#[derive(Debug, Clone)]
955pub struct BlobInfoIteratorControlHandle {
956    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
957}
958
959impl fidl::endpoints::ControlHandle for BlobInfoIteratorControlHandle {
960    fn shutdown(&self) {
961        self.inner.shutdown()
962    }
963    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
964        self.inner.shutdown_with_epitaph(status)
965    }
966
967    fn is_closed(&self) -> bool {
968        self.inner.channel().is_closed()
969    }
970    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
971        self.inner.channel().on_closed()
972    }
973
974    #[cfg(target_os = "fuchsia")]
975    fn signal_peer(
976        &self,
977        clear_mask: zx::Signals,
978        set_mask: zx::Signals,
979    ) -> Result<(), zx_status::Status> {
980        use fidl::Peered;
981        self.inner.channel().signal_peer(clear_mask, set_mask)
982    }
983}
984
985impl BlobInfoIteratorControlHandle {}
986
987#[must_use = "FIDL methods require a response to be sent"]
988#[derive(Debug)]
989pub struct BlobInfoIteratorNextResponder {
990    control_handle: std::mem::ManuallyDrop<BlobInfoIteratorControlHandle>,
991    tx_id: u32,
992}
993
994/// Set the the channel to be shutdown (see [`BlobInfoIteratorControlHandle::shutdown`])
995/// if the responder is dropped without sending a response, so that the client
996/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
997impl std::ops::Drop for BlobInfoIteratorNextResponder {
998    fn drop(&mut self) {
999        self.control_handle.shutdown();
1000        // Safety: drops once, never accessed again
1001        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1002    }
1003}
1004
1005impl fidl::endpoints::Responder for BlobInfoIteratorNextResponder {
1006    type ControlHandle = BlobInfoIteratorControlHandle;
1007
1008    fn control_handle(&self) -> &BlobInfoIteratorControlHandle {
1009        &self.control_handle
1010    }
1011
1012    fn drop_without_shutdown(mut self) {
1013        // Safety: drops once, never accessed again due to mem::forget
1014        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1015        // Prevent Drop from running (which would shut down the channel)
1016        std::mem::forget(self);
1017    }
1018}
1019
1020impl BlobInfoIteratorNextResponder {
1021    /// Sends a response to the FIDL transaction.
1022    ///
1023    /// Sets the channel to shutdown if an error occurs.
1024    pub fn send(self, mut blobs: &[BlobInfo]) -> Result<(), fidl::Error> {
1025        let _result = self.send_raw(blobs);
1026        if _result.is_err() {
1027            self.control_handle.shutdown();
1028        }
1029        self.drop_without_shutdown();
1030        _result
1031    }
1032
1033    /// Similar to "send" but does not shutdown the channel if an error occurs.
1034    pub fn send_no_shutdown_on_err(self, mut blobs: &[BlobInfo]) -> Result<(), fidl::Error> {
1035        let _result = self.send_raw(blobs);
1036        self.drop_without_shutdown();
1037        _result
1038    }
1039
1040    fn send_raw(&self, mut blobs: &[BlobInfo]) -> Result<(), fidl::Error> {
1041        self.control_handle.inner.send::<BlobInfoIteratorNextResponse>(
1042            (blobs,),
1043            self.tx_id,
1044            0x2b889489a59b6970,
1045            fidl::encoding::DynamicFlags::empty(),
1046        )
1047    }
1048}
1049
1050#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1051pub struct CupMarker;
1052
1053impl fidl::endpoints::ProtocolMarker for CupMarker {
1054    type Proxy = CupProxy;
1055    type RequestStream = CupRequestStream;
1056    #[cfg(target_os = "fuchsia")]
1057    type SynchronousProxy = CupSynchronousProxy;
1058
1059    const DEBUG_NAME: &'static str = "fuchsia.pkg.Cup";
1060}
1061impl fidl::endpoints::DiscoverableProtocolMarker for CupMarker {}
1062pub type CupWriteResult = Result<(), WriteError>;
1063pub type CupGetInfoResult = Result<(String, String), GetInfoError>;
1064
1065pub trait CupProxyInterface: Send + Sync {
1066    type WriteResponseFut: std::future::Future<Output = Result<CupWriteResult, fidl::Error>> + Send;
1067    fn r#write(&self, url: &PackageUrl, cup: &CupData) -> Self::WriteResponseFut;
1068    type GetInfoResponseFut: std::future::Future<Output = Result<CupGetInfoResult, fidl::Error>>
1069        + Send;
1070    fn r#get_info(&self, url: &PackageUrl) -> Self::GetInfoResponseFut;
1071}
1072#[derive(Debug)]
1073#[cfg(target_os = "fuchsia")]
1074pub struct CupSynchronousProxy {
1075    client: fidl::client::sync::Client,
1076}
1077
1078#[cfg(target_os = "fuchsia")]
1079impl fidl::endpoints::SynchronousProxy for CupSynchronousProxy {
1080    type Proxy = CupProxy;
1081    type Protocol = CupMarker;
1082
1083    fn from_channel(inner: fidl::Channel) -> Self {
1084        Self::new(inner)
1085    }
1086
1087    fn into_channel(self) -> fidl::Channel {
1088        self.client.into_channel()
1089    }
1090
1091    fn as_channel(&self) -> &fidl::Channel {
1092        self.client.as_channel()
1093    }
1094}
1095
1096#[cfg(target_os = "fuchsia")]
1097impl CupSynchronousProxy {
1098    pub fn new(channel: fidl::Channel) -> Self {
1099        let protocol_name = <CupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1100        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1101    }
1102
1103    pub fn into_channel(self) -> fidl::Channel {
1104        self.client.into_channel()
1105    }
1106
1107    /// Waits until an event arrives and returns it. It is safe for other
1108    /// threads to make concurrent requests while waiting for an event.
1109    pub fn wait_for_event(&self, deadline: zx::MonotonicInstant) -> Result<CupEvent, fidl::Error> {
1110        CupEvent::decode(self.client.wait_for_event(deadline)?)
1111    }
1112
1113    /// Resolve the eager package given by the pinned package URL, and write the
1114    /// CUP data to storage.
1115    pub fn r#write(
1116        &self,
1117        mut url: &PackageUrl,
1118        mut cup: &CupData,
1119        ___deadline: zx::MonotonicInstant,
1120    ) -> Result<CupWriteResult, fidl::Error> {
1121        let _response = self.client.send_query::<CupWriteRequest, fidl::encoding::ResultType<
1122            fidl::encoding::EmptyStruct,
1123            WriteError,
1124        >>(
1125            (url, cup),
1126            0x29f30e83bda39c37,
1127            fidl::encoding::DynamicFlags::empty(),
1128            ___deadline,
1129        )?;
1130        Ok(_response.map(|x| x))
1131    }
1132
1133    /// Returns the eager package version and channel of the given package URL.
1134    pub fn r#get_info(
1135        &self,
1136        mut url: &PackageUrl,
1137        ___deadline: zx::MonotonicInstant,
1138    ) -> Result<CupGetInfoResult, fidl::Error> {
1139        let _response = self.client.send_query::<
1140            CupGetInfoRequest,
1141            fidl::encoding::ResultType<CupGetInfoResponse, GetInfoError>,
1142        >(
1143            (url,),
1144            0x5b2cedd887209b9c,
1145            fidl::encoding::DynamicFlags::empty(),
1146            ___deadline,
1147        )?;
1148        Ok(_response.map(|x| (x.version, x.channel)))
1149    }
1150}
1151
1152#[cfg(target_os = "fuchsia")]
1153impl From<CupSynchronousProxy> for zx::Handle {
1154    fn from(value: CupSynchronousProxy) -> Self {
1155        value.into_channel().into()
1156    }
1157}
1158
1159#[cfg(target_os = "fuchsia")]
1160impl From<fidl::Channel> for CupSynchronousProxy {
1161    fn from(value: fidl::Channel) -> Self {
1162        Self::new(value)
1163    }
1164}
1165
1166#[derive(Debug, Clone)]
1167pub struct CupProxy {
1168    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1169}
1170
1171impl fidl::endpoints::Proxy for CupProxy {
1172    type Protocol = CupMarker;
1173
1174    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1175        Self::new(inner)
1176    }
1177
1178    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1179        self.client.into_channel().map_err(|client| Self { client })
1180    }
1181
1182    fn as_channel(&self) -> &::fidl::AsyncChannel {
1183        self.client.as_channel()
1184    }
1185}
1186
1187impl CupProxy {
1188    /// Create a new Proxy for fuchsia.pkg/Cup.
1189    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1190        let protocol_name = <CupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1191        Self { client: fidl::client::Client::new(channel, protocol_name) }
1192    }
1193
1194    /// Get a Stream of events from the remote end of the protocol.
1195    ///
1196    /// # Panics
1197    ///
1198    /// Panics if the event stream was already taken.
1199    pub fn take_event_stream(&self) -> CupEventStream {
1200        CupEventStream { event_receiver: self.client.take_event_receiver() }
1201    }
1202
1203    /// Resolve the eager package given by the pinned package URL, and write the
1204    /// CUP data to storage.
1205    pub fn r#write(
1206        &self,
1207        mut url: &PackageUrl,
1208        mut cup: &CupData,
1209    ) -> fidl::client::QueryResponseFut<CupWriteResult, fidl::encoding::DefaultFuchsiaResourceDialect>
1210    {
1211        CupProxyInterface::r#write(self, url, cup)
1212    }
1213
1214    /// Returns the eager package version and channel of the given package URL.
1215    pub fn r#get_info(
1216        &self,
1217        mut url: &PackageUrl,
1218    ) -> fidl::client::QueryResponseFut<
1219        CupGetInfoResult,
1220        fidl::encoding::DefaultFuchsiaResourceDialect,
1221    > {
1222        CupProxyInterface::r#get_info(self, url)
1223    }
1224}
1225
1226impl CupProxyInterface for CupProxy {
1227    type WriteResponseFut = fidl::client::QueryResponseFut<
1228        CupWriteResult,
1229        fidl::encoding::DefaultFuchsiaResourceDialect,
1230    >;
1231    fn r#write(&self, mut url: &PackageUrl, mut cup: &CupData) -> Self::WriteResponseFut {
1232        fn _decode(
1233            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1234        ) -> Result<CupWriteResult, fidl::Error> {
1235            let _response = fidl::client::decode_transaction_body::<
1236                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, WriteError>,
1237                fidl::encoding::DefaultFuchsiaResourceDialect,
1238                0x29f30e83bda39c37,
1239            >(_buf?)?;
1240            Ok(_response.map(|x| x))
1241        }
1242        self.client.send_query_and_decode::<CupWriteRequest, CupWriteResult>(
1243            (url, cup),
1244            0x29f30e83bda39c37,
1245            fidl::encoding::DynamicFlags::empty(),
1246            _decode,
1247        )
1248    }
1249
1250    type GetInfoResponseFut = fidl::client::QueryResponseFut<
1251        CupGetInfoResult,
1252        fidl::encoding::DefaultFuchsiaResourceDialect,
1253    >;
1254    fn r#get_info(&self, mut url: &PackageUrl) -> Self::GetInfoResponseFut {
1255        fn _decode(
1256            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1257        ) -> Result<CupGetInfoResult, fidl::Error> {
1258            let _response = fidl::client::decode_transaction_body::<
1259                fidl::encoding::ResultType<CupGetInfoResponse, GetInfoError>,
1260                fidl::encoding::DefaultFuchsiaResourceDialect,
1261                0x5b2cedd887209b9c,
1262            >(_buf?)?;
1263            Ok(_response.map(|x| (x.version, x.channel)))
1264        }
1265        self.client.send_query_and_decode::<CupGetInfoRequest, CupGetInfoResult>(
1266            (url,),
1267            0x5b2cedd887209b9c,
1268            fidl::encoding::DynamicFlags::empty(),
1269            _decode,
1270        )
1271    }
1272}
1273
1274pub struct CupEventStream {
1275    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1276}
1277
1278impl std::marker::Unpin for CupEventStream {}
1279
1280impl futures::stream::FusedStream for CupEventStream {
1281    fn is_terminated(&self) -> bool {
1282        self.event_receiver.is_terminated()
1283    }
1284}
1285
1286impl futures::Stream for CupEventStream {
1287    type Item = Result<CupEvent, fidl::Error>;
1288
1289    fn poll_next(
1290        mut self: std::pin::Pin<&mut Self>,
1291        cx: &mut std::task::Context<'_>,
1292    ) -> std::task::Poll<Option<Self::Item>> {
1293        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1294            &mut self.event_receiver,
1295            cx
1296        )?) {
1297            Some(buf) => std::task::Poll::Ready(Some(CupEvent::decode(buf))),
1298            None => std::task::Poll::Ready(None),
1299        }
1300    }
1301}
1302
1303#[derive(Debug)]
1304pub enum CupEvent {}
1305
1306impl CupEvent {
1307    /// Decodes a message buffer as a [`CupEvent`].
1308    fn decode(
1309        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1310    ) -> Result<CupEvent, fidl::Error> {
1311        let (bytes, _handles) = buf.split_mut();
1312        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1313        debug_assert_eq!(tx_header.tx_id, 0);
1314        match tx_header.ordinal {
1315            _ => Err(fidl::Error::UnknownOrdinal {
1316                ordinal: tx_header.ordinal,
1317                protocol_name: <CupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1318            }),
1319        }
1320    }
1321}
1322
1323/// A Stream of incoming requests for fuchsia.pkg/Cup.
1324pub struct CupRequestStream {
1325    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1326    is_terminated: bool,
1327}
1328
1329impl std::marker::Unpin for CupRequestStream {}
1330
1331impl futures::stream::FusedStream for CupRequestStream {
1332    fn is_terminated(&self) -> bool {
1333        self.is_terminated
1334    }
1335}
1336
1337impl fidl::endpoints::RequestStream for CupRequestStream {
1338    type Protocol = CupMarker;
1339    type ControlHandle = CupControlHandle;
1340
1341    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1342        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1343    }
1344
1345    fn control_handle(&self) -> Self::ControlHandle {
1346        CupControlHandle { inner: self.inner.clone() }
1347    }
1348
1349    fn into_inner(
1350        self,
1351    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1352    {
1353        (self.inner, self.is_terminated)
1354    }
1355
1356    fn from_inner(
1357        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1358        is_terminated: bool,
1359    ) -> Self {
1360        Self { inner, is_terminated }
1361    }
1362}
1363
1364impl futures::Stream for CupRequestStream {
1365    type Item = Result<CupRequest, fidl::Error>;
1366
1367    fn poll_next(
1368        mut self: std::pin::Pin<&mut Self>,
1369        cx: &mut std::task::Context<'_>,
1370    ) -> std::task::Poll<Option<Self::Item>> {
1371        let this = &mut *self;
1372        if this.inner.check_shutdown(cx) {
1373            this.is_terminated = true;
1374            return std::task::Poll::Ready(None);
1375        }
1376        if this.is_terminated {
1377            panic!("polled CupRequestStream after completion");
1378        }
1379        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1380            |bytes, handles| {
1381                match this.inner.channel().read_etc(cx, bytes, handles) {
1382                    std::task::Poll::Ready(Ok(())) => {}
1383                    std::task::Poll::Pending => return std::task::Poll::Pending,
1384                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1385                        this.is_terminated = true;
1386                        return std::task::Poll::Ready(None);
1387                    }
1388                    std::task::Poll::Ready(Err(e)) => {
1389                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1390                            e.into(),
1391                        ))))
1392                    }
1393                }
1394
1395                // A message has been received from the channel
1396                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1397
1398                std::task::Poll::Ready(Some(match header.ordinal {
1399                    0x29f30e83bda39c37 => {
1400                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1401                        let mut req = fidl::new_empty!(
1402                            CupWriteRequest,
1403                            fidl::encoding::DefaultFuchsiaResourceDialect
1404                        );
1405                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CupWriteRequest>(&header, _body_bytes, handles, &mut req)?;
1406                        let control_handle = CupControlHandle { inner: this.inner.clone() };
1407                        Ok(CupRequest::Write {
1408                            url: req.url,
1409                            cup: req.cup,
1410
1411                            responder: CupWriteResponder {
1412                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1413                                tx_id: header.tx_id,
1414                            },
1415                        })
1416                    }
1417                    0x5b2cedd887209b9c => {
1418                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1419                        let mut req = fidl::new_empty!(
1420                            CupGetInfoRequest,
1421                            fidl::encoding::DefaultFuchsiaResourceDialect
1422                        );
1423                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CupGetInfoRequest>(&header, _body_bytes, handles, &mut req)?;
1424                        let control_handle = CupControlHandle { inner: this.inner.clone() };
1425                        Ok(CupRequest::GetInfo {
1426                            url: req.url,
1427
1428                            responder: CupGetInfoResponder {
1429                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1430                                tx_id: header.tx_id,
1431                            },
1432                        })
1433                    }
1434                    _ => Err(fidl::Error::UnknownOrdinal {
1435                        ordinal: header.ordinal,
1436                        protocol_name: <CupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1437                    }),
1438                }))
1439            },
1440        )
1441    }
1442}
1443
1444/// This protocol gives access to persisted CUP data for eager packages in
1445/// pkg-resolver.
1446#[derive(Debug)]
1447pub enum CupRequest {
1448    /// Resolve the eager package given by the pinned package URL, and write the
1449    /// CUP data to storage.
1450    Write { url: PackageUrl, cup: CupData, responder: CupWriteResponder },
1451    /// Returns the eager package version and channel of the given package URL.
1452    GetInfo { url: PackageUrl, responder: CupGetInfoResponder },
1453}
1454
1455impl CupRequest {
1456    #[allow(irrefutable_let_patterns)]
1457    pub fn into_write(self) -> Option<(PackageUrl, CupData, CupWriteResponder)> {
1458        if let CupRequest::Write { url, cup, responder } = self {
1459            Some((url, cup, responder))
1460        } else {
1461            None
1462        }
1463    }
1464
1465    #[allow(irrefutable_let_patterns)]
1466    pub fn into_get_info(self) -> Option<(PackageUrl, CupGetInfoResponder)> {
1467        if let CupRequest::GetInfo { url, responder } = self {
1468            Some((url, responder))
1469        } else {
1470            None
1471        }
1472    }
1473
1474    /// Name of the method defined in FIDL
1475    pub fn method_name(&self) -> &'static str {
1476        match *self {
1477            CupRequest::Write { .. } => "write",
1478            CupRequest::GetInfo { .. } => "get_info",
1479        }
1480    }
1481}
1482
1483#[derive(Debug, Clone)]
1484pub struct CupControlHandle {
1485    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1486}
1487
1488impl fidl::endpoints::ControlHandle for CupControlHandle {
1489    fn shutdown(&self) {
1490        self.inner.shutdown()
1491    }
1492    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1493        self.inner.shutdown_with_epitaph(status)
1494    }
1495
1496    fn is_closed(&self) -> bool {
1497        self.inner.channel().is_closed()
1498    }
1499    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1500        self.inner.channel().on_closed()
1501    }
1502
1503    #[cfg(target_os = "fuchsia")]
1504    fn signal_peer(
1505        &self,
1506        clear_mask: zx::Signals,
1507        set_mask: zx::Signals,
1508    ) -> Result<(), zx_status::Status> {
1509        use fidl::Peered;
1510        self.inner.channel().signal_peer(clear_mask, set_mask)
1511    }
1512}
1513
1514impl CupControlHandle {}
1515
1516#[must_use = "FIDL methods require a response to be sent"]
1517#[derive(Debug)]
1518pub struct CupWriteResponder {
1519    control_handle: std::mem::ManuallyDrop<CupControlHandle>,
1520    tx_id: u32,
1521}
1522
1523/// Set the the channel to be shutdown (see [`CupControlHandle::shutdown`])
1524/// if the responder is dropped without sending a response, so that the client
1525/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1526impl std::ops::Drop for CupWriteResponder {
1527    fn drop(&mut self) {
1528        self.control_handle.shutdown();
1529        // Safety: drops once, never accessed again
1530        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1531    }
1532}
1533
1534impl fidl::endpoints::Responder for CupWriteResponder {
1535    type ControlHandle = CupControlHandle;
1536
1537    fn control_handle(&self) -> &CupControlHandle {
1538        &self.control_handle
1539    }
1540
1541    fn drop_without_shutdown(mut self) {
1542        // Safety: drops once, never accessed again due to mem::forget
1543        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1544        // Prevent Drop from running (which would shut down the channel)
1545        std::mem::forget(self);
1546    }
1547}
1548
1549impl CupWriteResponder {
1550    /// Sends a response to the FIDL transaction.
1551    ///
1552    /// Sets the channel to shutdown if an error occurs.
1553    pub fn send(self, mut result: Result<(), WriteError>) -> Result<(), fidl::Error> {
1554        let _result = self.send_raw(result);
1555        if _result.is_err() {
1556            self.control_handle.shutdown();
1557        }
1558        self.drop_without_shutdown();
1559        _result
1560    }
1561
1562    /// Similar to "send" but does not shutdown the channel if an error occurs.
1563    pub fn send_no_shutdown_on_err(
1564        self,
1565        mut result: Result<(), WriteError>,
1566    ) -> Result<(), fidl::Error> {
1567        let _result = self.send_raw(result);
1568        self.drop_without_shutdown();
1569        _result
1570    }
1571
1572    fn send_raw(&self, mut result: Result<(), WriteError>) -> Result<(), fidl::Error> {
1573        self.control_handle
1574            .inner
1575            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, WriteError>>(
1576                result,
1577                self.tx_id,
1578                0x29f30e83bda39c37,
1579                fidl::encoding::DynamicFlags::empty(),
1580            )
1581    }
1582}
1583
1584#[must_use = "FIDL methods require a response to be sent"]
1585#[derive(Debug)]
1586pub struct CupGetInfoResponder {
1587    control_handle: std::mem::ManuallyDrop<CupControlHandle>,
1588    tx_id: u32,
1589}
1590
1591/// Set the the channel to be shutdown (see [`CupControlHandle::shutdown`])
1592/// if the responder is dropped without sending a response, so that the client
1593/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1594impl std::ops::Drop for CupGetInfoResponder {
1595    fn drop(&mut self) {
1596        self.control_handle.shutdown();
1597        // Safety: drops once, never accessed again
1598        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1599    }
1600}
1601
1602impl fidl::endpoints::Responder for CupGetInfoResponder {
1603    type ControlHandle = CupControlHandle;
1604
1605    fn control_handle(&self) -> &CupControlHandle {
1606        &self.control_handle
1607    }
1608
1609    fn drop_without_shutdown(mut self) {
1610        // Safety: drops once, never accessed again due to mem::forget
1611        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1612        // Prevent Drop from running (which would shut down the channel)
1613        std::mem::forget(self);
1614    }
1615}
1616
1617impl CupGetInfoResponder {
1618    /// Sends a response to the FIDL transaction.
1619    ///
1620    /// Sets the channel to shutdown if an error occurs.
1621    pub fn send(self, mut result: Result<(&str, &str), GetInfoError>) -> Result<(), fidl::Error> {
1622        let _result = self.send_raw(result);
1623        if _result.is_err() {
1624            self.control_handle.shutdown();
1625        }
1626        self.drop_without_shutdown();
1627        _result
1628    }
1629
1630    /// Similar to "send" but does not shutdown the channel if an error occurs.
1631    pub fn send_no_shutdown_on_err(
1632        self,
1633        mut result: Result<(&str, &str), GetInfoError>,
1634    ) -> Result<(), fidl::Error> {
1635        let _result = self.send_raw(result);
1636        self.drop_without_shutdown();
1637        _result
1638    }
1639
1640    fn send_raw(&self, mut result: Result<(&str, &str), GetInfoError>) -> Result<(), fidl::Error> {
1641        self.control_handle
1642            .inner
1643            .send::<fidl::encoding::ResultType<CupGetInfoResponse, GetInfoError>>(
1644                result,
1645                self.tx_id,
1646                0x5b2cedd887209b9c,
1647                fidl::encoding::DynamicFlags::empty(),
1648            )
1649    }
1650}
1651
1652#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1653pub struct FontResolverMarker;
1654
1655impl fidl::endpoints::ProtocolMarker for FontResolverMarker {
1656    type Proxy = FontResolverProxy;
1657    type RequestStream = FontResolverRequestStream;
1658    #[cfg(target_os = "fuchsia")]
1659    type SynchronousProxy = FontResolverSynchronousProxy;
1660
1661    const DEBUG_NAME: &'static str = "fuchsia.pkg.FontResolver";
1662}
1663impl fidl::endpoints::DiscoverableProtocolMarker for FontResolverMarker {}
1664pub type FontResolverResolveResult = Result<(), i32>;
1665
1666pub trait FontResolverProxyInterface: Send + Sync {
1667    type ResolveResponseFut: std::future::Future<Output = Result<FontResolverResolveResult, fidl::Error>>
1668        + Send;
1669    fn r#resolve(
1670        &self,
1671        package_url: &str,
1672        directory_request: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1673    ) -> Self::ResolveResponseFut;
1674}
1675#[derive(Debug)]
1676#[cfg(target_os = "fuchsia")]
1677pub struct FontResolverSynchronousProxy {
1678    client: fidl::client::sync::Client,
1679}
1680
1681#[cfg(target_os = "fuchsia")]
1682impl fidl::endpoints::SynchronousProxy for FontResolverSynchronousProxy {
1683    type Proxy = FontResolverProxy;
1684    type Protocol = FontResolverMarker;
1685
1686    fn from_channel(inner: fidl::Channel) -> Self {
1687        Self::new(inner)
1688    }
1689
1690    fn into_channel(self) -> fidl::Channel {
1691        self.client.into_channel()
1692    }
1693
1694    fn as_channel(&self) -> &fidl::Channel {
1695        self.client.as_channel()
1696    }
1697}
1698
1699#[cfg(target_os = "fuchsia")]
1700impl FontResolverSynchronousProxy {
1701    pub fn new(channel: fidl::Channel) -> Self {
1702        let protocol_name = <FontResolverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1703        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1704    }
1705
1706    pub fn into_channel(self) -> fidl::Channel {
1707        self.client.into_channel()
1708    }
1709
1710    /// Waits until an event arrives and returns it. It is safe for other
1711    /// threads to make concurrent requests while waiting for an event.
1712    pub fn wait_for_event(
1713        &self,
1714        deadline: zx::MonotonicInstant,
1715    ) -> Result<FontResolverEvent, fidl::Error> {
1716        FontResolverEvent::decode(self.client.wait_for_event(deadline)?)
1717    }
1718
1719    /// Populates or updates the cache of a font package, fetching it if it is not present on the
1720    /// local system.
1721    ///
1722    /// + request `package_url` the package URL of a font package.
1723    /// + request `directory_request` a request for a directory that will be resolved when the
1724    ///   package has been successfully cached. The directory should contain a single file,
1725    ///   corresponding to the asset filename. The client should retain the directory handle
1726    ///   for as long as needed to prevent the package from being evicted from cache.
1727    /// * error a zx_status value indicating failure. One of the following:
1728    ///     * `ZX_ERR_ACCESS_DENIED` if the resolver does not have permission to fetch a
1729    ///       package blob.
1730    ///     * `ZX_ERR_IO` if there is some other unspecified error during I/O.
1731    ///     * `ZX_ERR_NOT_FOUND` if the font package or a package blob does not exist, or is
1732    ///       not known to be a font package.
1733    ///     * `ZX_ERR_NO_SPACE` if there is no space available to store the package.
1734    ///     * `ZX_ERR_UNAVAILABLE` if the resolver is currently unable to fetch a package blob.
1735    pub fn r#resolve(
1736        &self,
1737        mut package_url: &str,
1738        mut directory_request: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1739        ___deadline: zx::MonotonicInstant,
1740    ) -> Result<FontResolverResolveResult, fidl::Error> {
1741        let _response = self.client.send_query::<
1742            FontResolverResolveRequest,
1743            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1744        >(
1745            (package_url, directory_request,),
1746            0x159f60cc5ba432da,
1747            fidl::encoding::DynamicFlags::empty(),
1748            ___deadline,
1749        )?;
1750        Ok(_response.map(|x| x))
1751    }
1752}
1753
1754#[cfg(target_os = "fuchsia")]
1755impl From<FontResolverSynchronousProxy> for zx::Handle {
1756    fn from(value: FontResolverSynchronousProxy) -> Self {
1757        value.into_channel().into()
1758    }
1759}
1760
1761#[cfg(target_os = "fuchsia")]
1762impl From<fidl::Channel> for FontResolverSynchronousProxy {
1763    fn from(value: fidl::Channel) -> Self {
1764        Self::new(value)
1765    }
1766}
1767
1768#[derive(Debug, Clone)]
1769pub struct FontResolverProxy {
1770    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1771}
1772
1773impl fidl::endpoints::Proxy for FontResolverProxy {
1774    type Protocol = FontResolverMarker;
1775
1776    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1777        Self::new(inner)
1778    }
1779
1780    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1781        self.client.into_channel().map_err(|client| Self { client })
1782    }
1783
1784    fn as_channel(&self) -> &::fidl::AsyncChannel {
1785        self.client.as_channel()
1786    }
1787}
1788
1789impl FontResolverProxy {
1790    /// Create a new Proxy for fuchsia.pkg/FontResolver.
1791    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1792        let protocol_name = <FontResolverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1793        Self { client: fidl::client::Client::new(channel, protocol_name) }
1794    }
1795
1796    /// Get a Stream of events from the remote end of the protocol.
1797    ///
1798    /// # Panics
1799    ///
1800    /// Panics if the event stream was already taken.
1801    pub fn take_event_stream(&self) -> FontResolverEventStream {
1802        FontResolverEventStream { event_receiver: self.client.take_event_receiver() }
1803    }
1804
1805    /// Populates or updates the cache of a font package, fetching it if it is not present on the
1806    /// local system.
1807    ///
1808    /// + request `package_url` the package URL of a font package.
1809    /// + request `directory_request` a request for a directory that will be resolved when the
1810    ///   package has been successfully cached. The directory should contain a single file,
1811    ///   corresponding to the asset filename. The client should retain the directory handle
1812    ///   for as long as needed to prevent the package from being evicted from cache.
1813    /// * error a zx_status value indicating failure. One of the following:
1814    ///     * `ZX_ERR_ACCESS_DENIED` if the resolver does not have permission to fetch a
1815    ///       package blob.
1816    ///     * `ZX_ERR_IO` if there is some other unspecified error during I/O.
1817    ///     * `ZX_ERR_NOT_FOUND` if the font package or a package blob does not exist, or is
1818    ///       not known to be a font package.
1819    ///     * `ZX_ERR_NO_SPACE` if there is no space available to store the package.
1820    ///     * `ZX_ERR_UNAVAILABLE` if the resolver is currently unable to fetch a package blob.
1821    pub fn r#resolve(
1822        &self,
1823        mut package_url: &str,
1824        mut directory_request: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1825    ) -> fidl::client::QueryResponseFut<
1826        FontResolverResolveResult,
1827        fidl::encoding::DefaultFuchsiaResourceDialect,
1828    > {
1829        FontResolverProxyInterface::r#resolve(self, package_url, directory_request)
1830    }
1831}
1832
1833impl FontResolverProxyInterface for FontResolverProxy {
1834    type ResolveResponseFut = fidl::client::QueryResponseFut<
1835        FontResolverResolveResult,
1836        fidl::encoding::DefaultFuchsiaResourceDialect,
1837    >;
1838    fn r#resolve(
1839        &self,
1840        mut package_url: &str,
1841        mut directory_request: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1842    ) -> Self::ResolveResponseFut {
1843        fn _decode(
1844            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1845        ) -> Result<FontResolverResolveResult, fidl::Error> {
1846            let _response = fidl::client::decode_transaction_body::<
1847                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1848                fidl::encoding::DefaultFuchsiaResourceDialect,
1849                0x159f60cc5ba432da,
1850            >(_buf?)?;
1851            Ok(_response.map(|x| x))
1852        }
1853        self.client.send_query_and_decode::<FontResolverResolveRequest, FontResolverResolveResult>(
1854            (package_url, directory_request),
1855            0x159f60cc5ba432da,
1856            fidl::encoding::DynamicFlags::empty(),
1857            _decode,
1858        )
1859    }
1860}
1861
1862pub struct FontResolverEventStream {
1863    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1864}
1865
1866impl std::marker::Unpin for FontResolverEventStream {}
1867
1868impl futures::stream::FusedStream for FontResolverEventStream {
1869    fn is_terminated(&self) -> bool {
1870        self.event_receiver.is_terminated()
1871    }
1872}
1873
1874impl futures::Stream for FontResolverEventStream {
1875    type Item = Result<FontResolverEvent, fidl::Error>;
1876
1877    fn poll_next(
1878        mut self: std::pin::Pin<&mut Self>,
1879        cx: &mut std::task::Context<'_>,
1880    ) -> std::task::Poll<Option<Self::Item>> {
1881        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1882            &mut self.event_receiver,
1883            cx
1884        )?) {
1885            Some(buf) => std::task::Poll::Ready(Some(FontResolverEvent::decode(buf))),
1886            None => std::task::Poll::Ready(None),
1887        }
1888    }
1889}
1890
1891#[derive(Debug)]
1892pub enum FontResolverEvent {}
1893
1894impl FontResolverEvent {
1895    /// Decodes a message buffer as a [`FontResolverEvent`].
1896    fn decode(
1897        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1898    ) -> Result<FontResolverEvent, fidl::Error> {
1899        let (bytes, _handles) = buf.split_mut();
1900        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1901        debug_assert_eq!(tx_header.tx_id, 0);
1902        match tx_header.ordinal {
1903            _ => Err(fidl::Error::UnknownOrdinal {
1904                ordinal: tx_header.ordinal,
1905                protocol_name: <FontResolverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1906            }),
1907        }
1908    }
1909}
1910
1911/// A Stream of incoming requests for fuchsia.pkg/FontResolver.
1912pub struct FontResolverRequestStream {
1913    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1914    is_terminated: bool,
1915}
1916
1917impl std::marker::Unpin for FontResolverRequestStream {}
1918
1919impl futures::stream::FusedStream for FontResolverRequestStream {
1920    fn is_terminated(&self) -> bool {
1921        self.is_terminated
1922    }
1923}
1924
1925impl fidl::endpoints::RequestStream for FontResolverRequestStream {
1926    type Protocol = FontResolverMarker;
1927    type ControlHandle = FontResolverControlHandle;
1928
1929    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1930        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1931    }
1932
1933    fn control_handle(&self) -> Self::ControlHandle {
1934        FontResolverControlHandle { inner: self.inner.clone() }
1935    }
1936
1937    fn into_inner(
1938        self,
1939    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1940    {
1941        (self.inner, self.is_terminated)
1942    }
1943
1944    fn from_inner(
1945        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1946        is_terminated: bool,
1947    ) -> Self {
1948        Self { inner, is_terminated }
1949    }
1950}
1951
1952impl futures::Stream for FontResolverRequestStream {
1953    type Item = Result<FontResolverRequest, fidl::Error>;
1954
1955    fn poll_next(
1956        mut self: std::pin::Pin<&mut Self>,
1957        cx: &mut std::task::Context<'_>,
1958    ) -> std::task::Poll<Option<Self::Item>> {
1959        let this = &mut *self;
1960        if this.inner.check_shutdown(cx) {
1961            this.is_terminated = true;
1962            return std::task::Poll::Ready(None);
1963        }
1964        if this.is_terminated {
1965            panic!("polled FontResolverRequestStream after completion");
1966        }
1967        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1968            |bytes, handles| {
1969                match this.inner.channel().read_etc(cx, bytes, handles) {
1970                    std::task::Poll::Ready(Ok(())) => {}
1971                    std::task::Poll::Pending => return std::task::Poll::Pending,
1972                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1973                        this.is_terminated = true;
1974                        return std::task::Poll::Ready(None);
1975                    }
1976                    std::task::Poll::Ready(Err(e)) => {
1977                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1978                            e.into(),
1979                        ))))
1980                    }
1981                }
1982
1983                // A message has been received from the channel
1984                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1985
1986                std::task::Poll::Ready(Some(match header.ordinal {
1987                    0x159f60cc5ba432da => {
1988                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1989                        let mut req = fidl::new_empty!(
1990                            FontResolverResolveRequest,
1991                            fidl::encoding::DefaultFuchsiaResourceDialect
1992                        );
1993                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FontResolverResolveRequest>(&header, _body_bytes, handles, &mut req)?;
1994                        let control_handle =
1995                            FontResolverControlHandle { inner: this.inner.clone() };
1996                        Ok(FontResolverRequest::Resolve {
1997                            package_url: req.package_url,
1998                            directory_request: req.directory_request,
1999
2000                            responder: FontResolverResolveResponder {
2001                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2002                                tx_id: header.tx_id,
2003                            },
2004                        })
2005                    }
2006                    _ => Err(fidl::Error::UnknownOrdinal {
2007                        ordinal: header.ordinal,
2008                        protocol_name:
2009                            <FontResolverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2010                    }),
2011                }))
2012            },
2013        )
2014    }
2015}
2016
2017/// This resolves font packages from a registry.
2018///
2019/// This is intended to be implemented by package resolver components, and used
2020/// exclusively by fuchsia.fonts.Provider.
2021///
2022/// DEPRECATED. This is an interim solution, and will be revisited when Component Framework v2
2023/// becomes available and allows non-component packages and easier directory routing.
2024#[derive(Debug)]
2025pub enum FontResolverRequest {
2026    /// Populates or updates the cache of a font package, fetching it if it is not present on the
2027    /// local system.
2028    ///
2029    /// + request `package_url` the package URL of a font package.
2030    /// + request `directory_request` a request for a directory that will be resolved when the
2031    ///   package has been successfully cached. The directory should contain a single file,
2032    ///   corresponding to the asset filename. The client should retain the directory handle
2033    ///   for as long as needed to prevent the package from being evicted from cache.
2034    /// * error a zx_status value indicating failure. One of the following:
2035    ///     * `ZX_ERR_ACCESS_DENIED` if the resolver does not have permission to fetch a
2036    ///       package blob.
2037    ///     * `ZX_ERR_IO` if there is some other unspecified error during I/O.
2038    ///     * `ZX_ERR_NOT_FOUND` if the font package or a package blob does not exist, or is
2039    ///       not known to be a font package.
2040    ///     * `ZX_ERR_NO_SPACE` if there is no space available to store the package.
2041    ///     * `ZX_ERR_UNAVAILABLE` if the resolver is currently unable to fetch a package blob.
2042    Resolve {
2043        package_url: String,
2044        directory_request: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
2045        responder: FontResolverResolveResponder,
2046    },
2047}
2048
2049impl FontResolverRequest {
2050    #[allow(irrefutable_let_patterns)]
2051    pub fn into_resolve(
2052        self,
2053    ) -> Option<(
2054        String,
2055        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
2056        FontResolverResolveResponder,
2057    )> {
2058        if let FontResolverRequest::Resolve { package_url, directory_request, responder } = self {
2059            Some((package_url, directory_request, responder))
2060        } else {
2061            None
2062        }
2063    }
2064
2065    /// Name of the method defined in FIDL
2066    pub fn method_name(&self) -> &'static str {
2067        match *self {
2068            FontResolverRequest::Resolve { .. } => "resolve",
2069        }
2070    }
2071}
2072
2073#[derive(Debug, Clone)]
2074pub struct FontResolverControlHandle {
2075    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2076}
2077
2078impl fidl::endpoints::ControlHandle for FontResolverControlHandle {
2079    fn shutdown(&self) {
2080        self.inner.shutdown()
2081    }
2082    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2083        self.inner.shutdown_with_epitaph(status)
2084    }
2085
2086    fn is_closed(&self) -> bool {
2087        self.inner.channel().is_closed()
2088    }
2089    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2090        self.inner.channel().on_closed()
2091    }
2092
2093    #[cfg(target_os = "fuchsia")]
2094    fn signal_peer(
2095        &self,
2096        clear_mask: zx::Signals,
2097        set_mask: zx::Signals,
2098    ) -> Result<(), zx_status::Status> {
2099        use fidl::Peered;
2100        self.inner.channel().signal_peer(clear_mask, set_mask)
2101    }
2102}
2103
2104impl FontResolverControlHandle {}
2105
2106#[must_use = "FIDL methods require a response to be sent"]
2107#[derive(Debug)]
2108pub struct FontResolverResolveResponder {
2109    control_handle: std::mem::ManuallyDrop<FontResolverControlHandle>,
2110    tx_id: u32,
2111}
2112
2113/// Set the the channel to be shutdown (see [`FontResolverControlHandle::shutdown`])
2114/// if the responder is dropped without sending a response, so that the client
2115/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2116impl std::ops::Drop for FontResolverResolveResponder {
2117    fn drop(&mut self) {
2118        self.control_handle.shutdown();
2119        // Safety: drops once, never accessed again
2120        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2121    }
2122}
2123
2124impl fidl::endpoints::Responder for FontResolverResolveResponder {
2125    type ControlHandle = FontResolverControlHandle;
2126
2127    fn control_handle(&self) -> &FontResolverControlHandle {
2128        &self.control_handle
2129    }
2130
2131    fn drop_without_shutdown(mut self) {
2132        // Safety: drops once, never accessed again due to mem::forget
2133        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2134        // Prevent Drop from running (which would shut down the channel)
2135        std::mem::forget(self);
2136    }
2137}
2138
2139impl FontResolverResolveResponder {
2140    /// Sends a response to the FIDL transaction.
2141    ///
2142    /// Sets the channel to shutdown if an error occurs.
2143    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2144        let _result = self.send_raw(result);
2145        if _result.is_err() {
2146            self.control_handle.shutdown();
2147        }
2148        self.drop_without_shutdown();
2149        _result
2150    }
2151
2152    /// Similar to "send" but does not shutdown the channel if an error occurs.
2153    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2154        let _result = self.send_raw(result);
2155        self.drop_without_shutdown();
2156        _result
2157    }
2158
2159    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2160        self.control_handle
2161            .inner
2162            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2163                result,
2164                self.tx_id,
2165                0x159f60cc5ba432da,
2166                fidl::encoding::DynamicFlags::empty(),
2167            )
2168    }
2169}
2170
2171#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2172pub struct NeededBlobsMarker;
2173
2174impl fidl::endpoints::ProtocolMarker for NeededBlobsMarker {
2175    type Proxy = NeededBlobsProxy;
2176    type RequestStream = NeededBlobsRequestStream;
2177    #[cfg(target_os = "fuchsia")]
2178    type SynchronousProxy = NeededBlobsSynchronousProxy;
2179
2180    const DEBUG_NAME: &'static str = "(anonymous) NeededBlobs";
2181}
2182pub type NeededBlobsOpenMetaBlobResult = Result<Option<Box<BlobWriter>>, OpenBlobError>;
2183pub type NeededBlobsOpenBlobResult = Result<Option<Box<BlobWriter>>, OpenBlobError>;
2184pub type NeededBlobsBlobWrittenResult = Result<(), BlobWrittenError>;
2185
2186pub trait NeededBlobsProxyInterface: Send + Sync {
2187    type OpenMetaBlobResponseFut: std::future::Future<Output = Result<NeededBlobsOpenMetaBlobResult, fidl::Error>>
2188        + Send;
2189    fn r#open_meta_blob(&self) -> Self::OpenMetaBlobResponseFut;
2190    fn r#get_missing_blobs(
2191        &self,
2192        iterator: fidl::endpoints::ServerEnd<BlobInfoIteratorMarker>,
2193    ) -> Result<(), fidl::Error>;
2194    type OpenBlobResponseFut: std::future::Future<Output = Result<NeededBlobsOpenBlobResult, fidl::Error>>
2195        + Send;
2196    fn r#open_blob(&self, blob_id: &BlobId) -> Self::OpenBlobResponseFut;
2197    type BlobWrittenResponseFut: std::future::Future<Output = Result<NeededBlobsBlobWrittenResult, fidl::Error>>
2198        + Send;
2199    fn r#blob_written(&self, blob_id: &BlobId) -> Self::BlobWrittenResponseFut;
2200    type AbortResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
2201    fn r#abort(&self) -> Self::AbortResponseFut;
2202}
2203#[derive(Debug)]
2204#[cfg(target_os = "fuchsia")]
2205pub struct NeededBlobsSynchronousProxy {
2206    client: fidl::client::sync::Client,
2207}
2208
2209#[cfg(target_os = "fuchsia")]
2210impl fidl::endpoints::SynchronousProxy for NeededBlobsSynchronousProxy {
2211    type Proxy = NeededBlobsProxy;
2212    type Protocol = NeededBlobsMarker;
2213
2214    fn from_channel(inner: fidl::Channel) -> Self {
2215        Self::new(inner)
2216    }
2217
2218    fn into_channel(self) -> fidl::Channel {
2219        self.client.into_channel()
2220    }
2221
2222    fn as_channel(&self) -> &fidl::Channel {
2223        self.client.as_channel()
2224    }
2225}
2226
2227#[cfg(target_os = "fuchsia")]
2228impl NeededBlobsSynchronousProxy {
2229    pub fn new(channel: fidl::Channel) -> Self {
2230        let protocol_name = <NeededBlobsMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2231        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
2232    }
2233
2234    pub fn into_channel(self) -> fidl::Channel {
2235        self.client.into_channel()
2236    }
2237
2238    /// Waits until an event arrives and returns it. It is safe for other
2239    /// threads to make concurrent requests while waiting for an event.
2240    pub fn wait_for_event(
2241        &self,
2242        deadline: zx::MonotonicInstant,
2243    ) -> Result<NeededBlobsEvent, fidl::Error> {
2244        NeededBlobsEvent::decode(self.client.wait_for_event(deadline)?)
2245    }
2246
2247    /// Opens the package's metadata blob for writing. `GetMissingBlobs()`
2248    /// should not be called until writing the meta blob or this request
2249    /// responds with `false`.
2250    ///
2251    /// If the package was already cached, server will close the channel with a
2252    /// `ZX_OK` epitaph.
2253    ///
2254    /// - response `writer` is used to write the blob. If `writer` is absent,
2255    ///   the blob is already cached and so does not need to be written.
2256    /// * error an OpenBlobError indicating failure. Clients may retry this
2257    ///   request, though the server end may abort this cache operation on
2258    ///   errors it considers to be fatal.
2259    pub fn r#open_meta_blob(
2260        &self,
2261        ___deadline: zx::MonotonicInstant,
2262    ) -> Result<NeededBlobsOpenMetaBlobResult, fidl::Error> {
2263        let _response =
2264            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::ResultType<
2265                NeededBlobsOpenMetaBlobResponse,
2266                OpenBlobError,
2267            >>(
2268                (),
2269                0x42f385a58180f5fb,
2270                fidl::encoding::DynamicFlags::empty(),
2271                ___deadline,
2272            )?;
2273        Ok(_response.map(|x| x.writer))
2274    }
2275
2276    /// Returns an iterator of blobs that are not present on the system that
2277    /// must be written using the `OpenBlob` request before the package will be
2278    /// fully cached.
2279    ///
2280    /// Client should call `OpenMetaBlob`, and write it if needed, before
2281    /// calling `GetMissingBlobs`.
2282    ///
2283    /// A client should make this request no more than once per `NeededBlobs`
2284    /// connection. Once all blobs yielded by this iterator are written, the
2285    /// package open request will complete.
2286    ///
2287    /// New items may be added to the obtained `BlobInfoIterator` as the client
2288    /// calls `OpenBlob`, so, to guaranatee termination of the iterator, clients
2289    /// should call `OpenBlob` concurrently with reading the iterator.
2290    ///
2291    /// + request `iterator` a request for an iterator of [`BlobInfo`] of blobs
2292    ///   that the client should try to write.
2293    pub fn r#get_missing_blobs(
2294        &self,
2295        mut iterator: fidl::endpoints::ServerEnd<BlobInfoIteratorMarker>,
2296    ) -> Result<(), fidl::Error> {
2297        self.client.send::<NeededBlobsGetMissingBlobsRequest>(
2298            (iterator,),
2299            0x44eaf14fd56e7ae1,
2300            fidl::encoding::DynamicFlags::empty(),
2301        )
2302    }
2303
2304    /// Opens a blob for writing.
2305    ///
2306    /// + request `blob_id` the blob id describing this blob.
2307    /// - response `writer` is used to write the blob. If `writer` is absent,
2308    ///   the blob is already cached and so does not need to be written.
2309    /// * error an OpenBlobError indicating failure. Clients may retry this
2310    ///   request, though the server end may abort this cache operation on
2311    ///   errors it considers to be fatal.
2312    pub fn r#open_blob(
2313        &self,
2314        mut blob_id: &BlobId,
2315        ___deadline: zx::MonotonicInstant,
2316    ) -> Result<NeededBlobsOpenBlobResult, fidl::Error> {
2317        let _response = self.client.send_query::<
2318            NeededBlobsOpenBlobRequest,
2319            fidl::encoding::ResultType<NeededBlobsOpenBlobResponse, OpenBlobError>,
2320        >(
2321            (blob_id,),
2322            0x67cd4c4cd10ea9e0,
2323            fidl::encoding::DynamicFlags::empty(),
2324            ___deadline,
2325        )?;
2326        Ok(_response.map(|x| x.writer))
2327    }
2328
2329    /// Indicates that a blob opened by `Open[Meta]Blob` has been successfully
2330    /// written.
2331    ///
2332    /// A client should call this once the blob has been fully written using
2333    /// the `writer` returned by `Open[Meta]Blob`.
2334    ///
2335    /// + request `blob_id` the blob id describing this blob.
2336    /// * error a BlobWrittenError indicating failure. Clients may retry the
2337    ///   `Open[Meta]Blob` request that prompted this call, though the server
2338    ///   end may abort this cache operation on errors it considers to be fatal.
2339    pub fn r#blob_written(
2340        &self,
2341        mut blob_id: &BlobId,
2342        ___deadline: zx::MonotonicInstant,
2343    ) -> Result<NeededBlobsBlobWrittenResult, fidl::Error> {
2344        let _response = self.client.send_query::<
2345            NeededBlobsBlobWrittenRequest,
2346            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, BlobWrittenError>,
2347        >(
2348            (blob_id,),
2349            0x222f80ec77433f44,
2350            fidl::encoding::DynamicFlags::empty(),
2351            ___deadline,
2352        )?;
2353        Ok(_response.map(|x| x))
2354    }
2355
2356    /// Aborts this caching operation for the package.
2357    ///
2358    /// Any open blobs and any missing blobs iterator will be closed. Any `dir`
2359    /// provided to the associated [`PackageCache.Get`] request will also be
2360    /// closed. Once this request is acknowledged, this channel will be closed.
2361    ///
2362    /// Note, dropping this NeededBlobs channel without writing all needed blobs
2363    /// will also abort the package cache operation. However, this API provides
2364    /// the ability to wait for the operation to be torn down.
2365    pub fn r#abort(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
2366        let _response =
2367            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
2368                (),
2369                0x6fda8d5ebea74cbb,
2370                fidl::encoding::DynamicFlags::empty(),
2371                ___deadline,
2372            )?;
2373        Ok(_response)
2374    }
2375}
2376
2377#[cfg(target_os = "fuchsia")]
2378impl From<NeededBlobsSynchronousProxy> for zx::Handle {
2379    fn from(value: NeededBlobsSynchronousProxy) -> Self {
2380        value.into_channel().into()
2381    }
2382}
2383
2384#[cfg(target_os = "fuchsia")]
2385impl From<fidl::Channel> for NeededBlobsSynchronousProxy {
2386    fn from(value: fidl::Channel) -> Self {
2387        Self::new(value)
2388    }
2389}
2390
2391#[derive(Debug, Clone)]
2392pub struct NeededBlobsProxy {
2393    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2394}
2395
2396impl fidl::endpoints::Proxy for NeededBlobsProxy {
2397    type Protocol = NeededBlobsMarker;
2398
2399    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2400        Self::new(inner)
2401    }
2402
2403    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2404        self.client.into_channel().map_err(|client| Self { client })
2405    }
2406
2407    fn as_channel(&self) -> &::fidl::AsyncChannel {
2408        self.client.as_channel()
2409    }
2410}
2411
2412impl NeededBlobsProxy {
2413    /// Create a new Proxy for fuchsia.pkg/NeededBlobs.
2414    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2415        let protocol_name = <NeededBlobsMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2416        Self { client: fidl::client::Client::new(channel, protocol_name) }
2417    }
2418
2419    /// Get a Stream of events from the remote end of the protocol.
2420    ///
2421    /// # Panics
2422    ///
2423    /// Panics if the event stream was already taken.
2424    pub fn take_event_stream(&self) -> NeededBlobsEventStream {
2425        NeededBlobsEventStream { event_receiver: self.client.take_event_receiver() }
2426    }
2427
2428    /// Opens the package's metadata blob for writing. `GetMissingBlobs()`
2429    /// should not be called until writing the meta blob or this request
2430    /// responds with `false`.
2431    ///
2432    /// If the package was already cached, server will close the channel with a
2433    /// `ZX_OK` epitaph.
2434    ///
2435    /// - response `writer` is used to write the blob. If `writer` is absent,
2436    ///   the blob is already cached and so does not need to be written.
2437    /// * error an OpenBlobError indicating failure. Clients may retry this
2438    ///   request, though the server end may abort this cache operation on
2439    ///   errors it considers to be fatal.
2440    pub fn r#open_meta_blob(
2441        &self,
2442    ) -> fidl::client::QueryResponseFut<
2443        NeededBlobsOpenMetaBlobResult,
2444        fidl::encoding::DefaultFuchsiaResourceDialect,
2445    > {
2446        NeededBlobsProxyInterface::r#open_meta_blob(self)
2447    }
2448
2449    /// Returns an iterator of blobs that are not present on the system that
2450    /// must be written using the `OpenBlob` request before the package will be
2451    /// fully cached.
2452    ///
2453    /// Client should call `OpenMetaBlob`, and write it if needed, before
2454    /// calling `GetMissingBlobs`.
2455    ///
2456    /// A client should make this request no more than once per `NeededBlobs`
2457    /// connection. Once all blobs yielded by this iterator are written, the
2458    /// package open request will complete.
2459    ///
2460    /// New items may be added to the obtained `BlobInfoIterator` as the client
2461    /// calls `OpenBlob`, so, to guaranatee termination of the iterator, clients
2462    /// should call `OpenBlob` concurrently with reading the iterator.
2463    ///
2464    /// + request `iterator` a request for an iterator of [`BlobInfo`] of blobs
2465    ///   that the client should try to write.
2466    pub fn r#get_missing_blobs(
2467        &self,
2468        mut iterator: fidl::endpoints::ServerEnd<BlobInfoIteratorMarker>,
2469    ) -> Result<(), fidl::Error> {
2470        NeededBlobsProxyInterface::r#get_missing_blobs(self, iterator)
2471    }
2472
2473    /// Opens a blob for writing.
2474    ///
2475    /// + request `blob_id` the blob id describing this blob.
2476    /// - response `writer` is used to write the blob. If `writer` is absent,
2477    ///   the blob is already cached and so does not need to be written.
2478    /// * error an OpenBlobError indicating failure. Clients may retry this
2479    ///   request, though the server end may abort this cache operation on
2480    ///   errors it considers to be fatal.
2481    pub fn r#open_blob(
2482        &self,
2483        mut blob_id: &BlobId,
2484    ) -> fidl::client::QueryResponseFut<
2485        NeededBlobsOpenBlobResult,
2486        fidl::encoding::DefaultFuchsiaResourceDialect,
2487    > {
2488        NeededBlobsProxyInterface::r#open_blob(self, blob_id)
2489    }
2490
2491    /// Indicates that a blob opened by `Open[Meta]Blob` has been successfully
2492    /// written.
2493    ///
2494    /// A client should call this once the blob has been fully written using
2495    /// the `writer` returned by `Open[Meta]Blob`.
2496    ///
2497    /// + request `blob_id` the blob id describing this blob.
2498    /// * error a BlobWrittenError indicating failure. Clients may retry the
2499    ///   `Open[Meta]Blob` request that prompted this call, though the server
2500    ///   end may abort this cache operation on errors it considers to be fatal.
2501    pub fn r#blob_written(
2502        &self,
2503        mut blob_id: &BlobId,
2504    ) -> fidl::client::QueryResponseFut<
2505        NeededBlobsBlobWrittenResult,
2506        fidl::encoding::DefaultFuchsiaResourceDialect,
2507    > {
2508        NeededBlobsProxyInterface::r#blob_written(self, blob_id)
2509    }
2510
2511    /// Aborts this caching operation for the package.
2512    ///
2513    /// Any open blobs and any missing blobs iterator will be closed. Any `dir`
2514    /// provided to the associated [`PackageCache.Get`] request will also be
2515    /// closed. Once this request is acknowledged, this channel will be closed.
2516    ///
2517    /// Note, dropping this NeededBlobs channel without writing all needed blobs
2518    /// will also abort the package cache operation. However, this API provides
2519    /// the ability to wait for the operation to be torn down.
2520    pub fn r#abort(
2521        &self,
2522    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
2523        NeededBlobsProxyInterface::r#abort(self)
2524    }
2525}
2526
2527impl NeededBlobsProxyInterface for NeededBlobsProxy {
2528    type OpenMetaBlobResponseFut = fidl::client::QueryResponseFut<
2529        NeededBlobsOpenMetaBlobResult,
2530        fidl::encoding::DefaultFuchsiaResourceDialect,
2531    >;
2532    fn r#open_meta_blob(&self) -> Self::OpenMetaBlobResponseFut {
2533        fn _decode(
2534            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2535        ) -> Result<NeededBlobsOpenMetaBlobResult, fidl::Error> {
2536            let _response = fidl::client::decode_transaction_body::<
2537                fidl::encoding::ResultType<NeededBlobsOpenMetaBlobResponse, OpenBlobError>,
2538                fidl::encoding::DefaultFuchsiaResourceDialect,
2539                0x42f385a58180f5fb,
2540            >(_buf?)?;
2541            Ok(_response.map(|x| x.writer))
2542        }
2543        self.client
2544            .send_query_and_decode::<fidl::encoding::EmptyPayload, NeededBlobsOpenMetaBlobResult>(
2545                (),
2546                0x42f385a58180f5fb,
2547                fidl::encoding::DynamicFlags::empty(),
2548                _decode,
2549            )
2550    }
2551
2552    fn r#get_missing_blobs(
2553        &self,
2554        mut iterator: fidl::endpoints::ServerEnd<BlobInfoIteratorMarker>,
2555    ) -> Result<(), fidl::Error> {
2556        self.client.send::<NeededBlobsGetMissingBlobsRequest>(
2557            (iterator,),
2558            0x44eaf14fd56e7ae1,
2559            fidl::encoding::DynamicFlags::empty(),
2560        )
2561    }
2562
2563    type OpenBlobResponseFut = fidl::client::QueryResponseFut<
2564        NeededBlobsOpenBlobResult,
2565        fidl::encoding::DefaultFuchsiaResourceDialect,
2566    >;
2567    fn r#open_blob(&self, mut blob_id: &BlobId) -> Self::OpenBlobResponseFut {
2568        fn _decode(
2569            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2570        ) -> Result<NeededBlobsOpenBlobResult, fidl::Error> {
2571            let _response = fidl::client::decode_transaction_body::<
2572                fidl::encoding::ResultType<NeededBlobsOpenBlobResponse, OpenBlobError>,
2573                fidl::encoding::DefaultFuchsiaResourceDialect,
2574                0x67cd4c4cd10ea9e0,
2575            >(_buf?)?;
2576            Ok(_response.map(|x| x.writer))
2577        }
2578        self.client.send_query_and_decode::<NeededBlobsOpenBlobRequest, NeededBlobsOpenBlobResult>(
2579            (blob_id,),
2580            0x67cd4c4cd10ea9e0,
2581            fidl::encoding::DynamicFlags::empty(),
2582            _decode,
2583        )
2584    }
2585
2586    type BlobWrittenResponseFut = fidl::client::QueryResponseFut<
2587        NeededBlobsBlobWrittenResult,
2588        fidl::encoding::DefaultFuchsiaResourceDialect,
2589    >;
2590    fn r#blob_written(&self, mut blob_id: &BlobId) -> Self::BlobWrittenResponseFut {
2591        fn _decode(
2592            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2593        ) -> Result<NeededBlobsBlobWrittenResult, fidl::Error> {
2594            let _response = fidl::client::decode_transaction_body::<
2595                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, BlobWrittenError>,
2596                fidl::encoding::DefaultFuchsiaResourceDialect,
2597                0x222f80ec77433f44,
2598            >(_buf?)?;
2599            Ok(_response.map(|x| x))
2600        }
2601        self.client
2602            .send_query_and_decode::<NeededBlobsBlobWrittenRequest, NeededBlobsBlobWrittenResult>(
2603                (blob_id,),
2604                0x222f80ec77433f44,
2605                fidl::encoding::DynamicFlags::empty(),
2606                _decode,
2607            )
2608    }
2609
2610    type AbortResponseFut =
2611        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
2612    fn r#abort(&self) -> Self::AbortResponseFut {
2613        fn _decode(
2614            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2615        ) -> Result<(), fidl::Error> {
2616            let _response = fidl::client::decode_transaction_body::<
2617                fidl::encoding::EmptyPayload,
2618                fidl::encoding::DefaultFuchsiaResourceDialect,
2619                0x6fda8d5ebea74cbb,
2620            >(_buf?)?;
2621            Ok(_response)
2622        }
2623        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
2624            (),
2625            0x6fda8d5ebea74cbb,
2626            fidl::encoding::DynamicFlags::empty(),
2627            _decode,
2628        )
2629    }
2630}
2631
2632pub struct NeededBlobsEventStream {
2633    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2634}
2635
2636impl std::marker::Unpin for NeededBlobsEventStream {}
2637
2638impl futures::stream::FusedStream for NeededBlobsEventStream {
2639    fn is_terminated(&self) -> bool {
2640        self.event_receiver.is_terminated()
2641    }
2642}
2643
2644impl futures::Stream for NeededBlobsEventStream {
2645    type Item = Result<NeededBlobsEvent, fidl::Error>;
2646
2647    fn poll_next(
2648        mut self: std::pin::Pin<&mut Self>,
2649        cx: &mut std::task::Context<'_>,
2650    ) -> std::task::Poll<Option<Self::Item>> {
2651        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2652            &mut self.event_receiver,
2653            cx
2654        )?) {
2655            Some(buf) => std::task::Poll::Ready(Some(NeededBlobsEvent::decode(buf))),
2656            None => std::task::Poll::Ready(None),
2657        }
2658    }
2659}
2660
2661#[derive(Debug)]
2662pub enum NeededBlobsEvent {}
2663
2664impl NeededBlobsEvent {
2665    /// Decodes a message buffer as a [`NeededBlobsEvent`].
2666    fn decode(
2667        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2668    ) -> Result<NeededBlobsEvent, fidl::Error> {
2669        let (bytes, _handles) = buf.split_mut();
2670        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2671        debug_assert_eq!(tx_header.tx_id, 0);
2672        match tx_header.ordinal {
2673            _ => Err(fidl::Error::UnknownOrdinal {
2674                ordinal: tx_header.ordinal,
2675                protocol_name: <NeededBlobsMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2676            }),
2677        }
2678    }
2679}
2680
2681/// A Stream of incoming requests for fuchsia.pkg/NeededBlobs.
2682pub struct NeededBlobsRequestStream {
2683    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2684    is_terminated: bool,
2685}
2686
2687impl std::marker::Unpin for NeededBlobsRequestStream {}
2688
2689impl futures::stream::FusedStream for NeededBlobsRequestStream {
2690    fn is_terminated(&self) -> bool {
2691        self.is_terminated
2692    }
2693}
2694
2695impl fidl::endpoints::RequestStream for NeededBlobsRequestStream {
2696    type Protocol = NeededBlobsMarker;
2697    type ControlHandle = NeededBlobsControlHandle;
2698
2699    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2700        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2701    }
2702
2703    fn control_handle(&self) -> Self::ControlHandle {
2704        NeededBlobsControlHandle { inner: self.inner.clone() }
2705    }
2706
2707    fn into_inner(
2708        self,
2709    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2710    {
2711        (self.inner, self.is_terminated)
2712    }
2713
2714    fn from_inner(
2715        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2716        is_terminated: bool,
2717    ) -> Self {
2718        Self { inner, is_terminated }
2719    }
2720}
2721
2722impl futures::Stream for NeededBlobsRequestStream {
2723    type Item = Result<NeededBlobsRequest, fidl::Error>;
2724
2725    fn poll_next(
2726        mut self: std::pin::Pin<&mut Self>,
2727        cx: &mut std::task::Context<'_>,
2728    ) -> std::task::Poll<Option<Self::Item>> {
2729        let this = &mut *self;
2730        if this.inner.check_shutdown(cx) {
2731            this.is_terminated = true;
2732            return std::task::Poll::Ready(None);
2733        }
2734        if this.is_terminated {
2735            panic!("polled NeededBlobsRequestStream after completion");
2736        }
2737        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2738            |bytes, handles| {
2739                match this.inner.channel().read_etc(cx, bytes, handles) {
2740                    std::task::Poll::Ready(Ok(())) => {}
2741                    std::task::Poll::Pending => return std::task::Poll::Pending,
2742                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2743                        this.is_terminated = true;
2744                        return std::task::Poll::Ready(None);
2745                    }
2746                    std::task::Poll::Ready(Err(e)) => {
2747                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2748                            e.into(),
2749                        ))))
2750                    }
2751                }
2752
2753                // A message has been received from the channel
2754                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2755
2756                std::task::Poll::Ready(Some(match header.ordinal {
2757                    0x42f385a58180f5fb => {
2758                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2759                        let mut req = fidl::new_empty!(
2760                            fidl::encoding::EmptyPayload,
2761                            fidl::encoding::DefaultFuchsiaResourceDialect
2762                        );
2763                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2764                        let control_handle = NeededBlobsControlHandle { inner: this.inner.clone() };
2765                        Ok(NeededBlobsRequest::OpenMetaBlob {
2766                            responder: NeededBlobsOpenMetaBlobResponder {
2767                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2768                                tx_id: header.tx_id,
2769                            },
2770                        })
2771                    }
2772                    0x44eaf14fd56e7ae1 => {
2773                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2774                        let mut req = fidl::new_empty!(
2775                            NeededBlobsGetMissingBlobsRequest,
2776                            fidl::encoding::DefaultFuchsiaResourceDialect
2777                        );
2778                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NeededBlobsGetMissingBlobsRequest>(&header, _body_bytes, handles, &mut req)?;
2779                        let control_handle = NeededBlobsControlHandle { inner: this.inner.clone() };
2780                        Ok(NeededBlobsRequest::GetMissingBlobs {
2781                            iterator: req.iterator,
2782
2783                            control_handle,
2784                        })
2785                    }
2786                    0x67cd4c4cd10ea9e0 => {
2787                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2788                        let mut req = fidl::new_empty!(
2789                            NeededBlobsOpenBlobRequest,
2790                            fidl::encoding::DefaultFuchsiaResourceDialect
2791                        );
2792                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NeededBlobsOpenBlobRequest>(&header, _body_bytes, handles, &mut req)?;
2793                        let control_handle = NeededBlobsControlHandle { inner: this.inner.clone() };
2794                        Ok(NeededBlobsRequest::OpenBlob {
2795                            blob_id: req.blob_id,
2796
2797                            responder: NeededBlobsOpenBlobResponder {
2798                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2799                                tx_id: header.tx_id,
2800                            },
2801                        })
2802                    }
2803                    0x222f80ec77433f44 => {
2804                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2805                        let mut req = fidl::new_empty!(
2806                            NeededBlobsBlobWrittenRequest,
2807                            fidl::encoding::DefaultFuchsiaResourceDialect
2808                        );
2809                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NeededBlobsBlobWrittenRequest>(&header, _body_bytes, handles, &mut req)?;
2810                        let control_handle = NeededBlobsControlHandle { inner: this.inner.clone() };
2811                        Ok(NeededBlobsRequest::BlobWritten {
2812                            blob_id: req.blob_id,
2813
2814                            responder: NeededBlobsBlobWrittenResponder {
2815                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2816                                tx_id: header.tx_id,
2817                            },
2818                        })
2819                    }
2820                    0x6fda8d5ebea74cbb => {
2821                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2822                        let mut req = fidl::new_empty!(
2823                            fidl::encoding::EmptyPayload,
2824                            fidl::encoding::DefaultFuchsiaResourceDialect
2825                        );
2826                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2827                        let control_handle = NeededBlobsControlHandle { inner: this.inner.clone() };
2828                        Ok(NeededBlobsRequest::Abort {
2829                            responder: NeededBlobsAbortResponder {
2830                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2831                                tx_id: header.tx_id,
2832                            },
2833                        })
2834                    }
2835                    _ => Err(fidl::Error::UnknownOrdinal {
2836                        ordinal: header.ordinal,
2837                        protocol_name:
2838                            <NeededBlobsMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2839                    }),
2840                }))
2841            },
2842        )
2843    }
2844}
2845
2846/// Represents the transaction for caching a particular package.
2847///
2848/// Server expects client to follow the normal operation sequence defined below.
2849/// Violating the protocol (e.g. calling wrong methods at the wrong time) will result
2850/// in the channel being closed by the package cache with a `ZX_ERR_BAD_STATE` epitaph
2851/// and aborting the package cache operation.
2852/// If a fatal error occurs at any step, server will close the channel, and client
2853/// should not proceed with the sequence.
2854/// Non-fatal errors could be retried, as long as the channel remains open.
2855///
2856/// Normal operation sequence:
2857/// 1. Clients should start by requesting to `OpenMetaBlob()`, and fetch and write
2858/// the metadata blob if needed, calling `BlobWritten()` when done to indicate the
2859/// write is complete.
2860/// 2. `GetMissingBlobs()` should be used to determine which blobs need to be
2861/// fetched and written.
2862/// 3. Each of the missing blobs needs to be written using `OpenBlob()` and
2863/// `BlobWritten()` should be called after each blob is written.
2864///
2865/// Clients are responsible for avoiding concurrent creation of the same blob if the underlying
2866/// blobstore does not support it.
2867/// This manifests as the following constraints (applied per `BlobId`):
2868/// 1. If the `BlobWriter` returned by calls to `Open[Meta]Blob` is the `file` variant, once Clients
2869///    call Resize on a file, they must close *all* file connections obtained from `Open[Meta]Blob`
2870///    before calling `Open[Meta]Blob` again.
2871/// 2. If the `BlobWriter` returned by calls to `Open[Meta]Blob` is the `writer` variant, Clients
2872///    must not write all the bytes to more than one of the `writer`s.
2873/// This applies per `BlobId` to all `BlobWriter`s returned by all calls to `Open[Meta]Blob` across
2874/// all `NeededBlobs` connections across all `PackageCache` connections.
2875/// Once c++blobfs support is removed and fxblob is changed to support duplicate concurrent creation
2876/// requests (https://fxbug.dev/335870456#comment9), this requirement can be dropped.
2877///
2878/// Once all needed blobs are written by the client, the package cache will
2879/// complete the pending [`PackageCache.Get`] request and close this channel
2880/// with a `ZX_OK` epitaph.
2881#[derive(Debug)]
2882pub enum NeededBlobsRequest {
2883    /// Opens the package's metadata blob for writing. `GetMissingBlobs()`
2884    /// should not be called until writing the meta blob or this request
2885    /// responds with `false`.
2886    ///
2887    /// If the package was already cached, server will close the channel with a
2888    /// `ZX_OK` epitaph.
2889    ///
2890    /// - response `writer` is used to write the blob. If `writer` is absent,
2891    ///   the blob is already cached and so does not need to be written.
2892    /// * error an OpenBlobError indicating failure. Clients may retry this
2893    ///   request, though the server end may abort this cache operation on
2894    ///   errors it considers to be fatal.
2895    OpenMetaBlob { responder: NeededBlobsOpenMetaBlobResponder },
2896    /// Returns an iterator of blobs that are not present on the system that
2897    /// must be written using the `OpenBlob` request before the package will be
2898    /// fully cached.
2899    ///
2900    /// Client should call `OpenMetaBlob`, and write it if needed, before
2901    /// calling `GetMissingBlobs`.
2902    ///
2903    /// A client should make this request no more than once per `NeededBlobs`
2904    /// connection. Once all blobs yielded by this iterator are written, the
2905    /// package open request will complete.
2906    ///
2907    /// New items may be added to the obtained `BlobInfoIterator` as the client
2908    /// calls `OpenBlob`, so, to guaranatee termination of the iterator, clients
2909    /// should call `OpenBlob` concurrently with reading the iterator.
2910    ///
2911    /// + request `iterator` a request for an iterator of [`BlobInfo`] of blobs
2912    ///   that the client should try to write.
2913    GetMissingBlobs {
2914        iterator: fidl::endpoints::ServerEnd<BlobInfoIteratorMarker>,
2915        control_handle: NeededBlobsControlHandle,
2916    },
2917    /// Opens a blob for writing.
2918    ///
2919    /// + request `blob_id` the blob id describing this blob.
2920    /// - response `writer` is used to write the blob. If `writer` is absent,
2921    ///   the blob is already cached and so does not need to be written.
2922    /// * error an OpenBlobError indicating failure. Clients may retry this
2923    ///   request, though the server end may abort this cache operation on
2924    ///   errors it considers to be fatal.
2925    OpenBlob { blob_id: BlobId, responder: NeededBlobsOpenBlobResponder },
2926    /// Indicates that a blob opened by `Open[Meta]Blob` has been successfully
2927    /// written.
2928    ///
2929    /// A client should call this once the blob has been fully written using
2930    /// the `writer` returned by `Open[Meta]Blob`.
2931    ///
2932    /// + request `blob_id` the blob id describing this blob.
2933    /// * error a BlobWrittenError indicating failure. Clients may retry the
2934    ///   `Open[Meta]Blob` request that prompted this call, though the server
2935    ///   end may abort this cache operation on errors it considers to be fatal.
2936    BlobWritten { blob_id: BlobId, responder: NeededBlobsBlobWrittenResponder },
2937    /// Aborts this caching operation for the package.
2938    ///
2939    /// Any open blobs and any missing blobs iterator will be closed. Any `dir`
2940    /// provided to the associated [`PackageCache.Get`] request will also be
2941    /// closed. Once this request is acknowledged, this channel will be closed.
2942    ///
2943    /// Note, dropping this NeededBlobs channel without writing all needed blobs
2944    /// will also abort the package cache operation. However, this API provides
2945    /// the ability to wait for the operation to be torn down.
2946    Abort { responder: NeededBlobsAbortResponder },
2947}
2948
2949impl NeededBlobsRequest {
2950    #[allow(irrefutable_let_patterns)]
2951    pub fn into_open_meta_blob(self) -> Option<(NeededBlobsOpenMetaBlobResponder)> {
2952        if let NeededBlobsRequest::OpenMetaBlob { responder } = self {
2953            Some((responder))
2954        } else {
2955            None
2956        }
2957    }
2958
2959    #[allow(irrefutable_let_patterns)]
2960    pub fn into_get_missing_blobs(
2961        self,
2962    ) -> Option<(fidl::endpoints::ServerEnd<BlobInfoIteratorMarker>, NeededBlobsControlHandle)>
2963    {
2964        if let NeededBlobsRequest::GetMissingBlobs { iterator, control_handle } = self {
2965            Some((iterator, control_handle))
2966        } else {
2967            None
2968        }
2969    }
2970
2971    #[allow(irrefutable_let_patterns)]
2972    pub fn into_open_blob(self) -> Option<(BlobId, NeededBlobsOpenBlobResponder)> {
2973        if let NeededBlobsRequest::OpenBlob { blob_id, responder } = self {
2974            Some((blob_id, responder))
2975        } else {
2976            None
2977        }
2978    }
2979
2980    #[allow(irrefutable_let_patterns)]
2981    pub fn into_blob_written(self) -> Option<(BlobId, NeededBlobsBlobWrittenResponder)> {
2982        if let NeededBlobsRequest::BlobWritten { blob_id, responder } = self {
2983            Some((blob_id, responder))
2984        } else {
2985            None
2986        }
2987    }
2988
2989    #[allow(irrefutable_let_patterns)]
2990    pub fn into_abort(self) -> Option<(NeededBlobsAbortResponder)> {
2991        if let NeededBlobsRequest::Abort { responder } = self {
2992            Some((responder))
2993        } else {
2994            None
2995        }
2996    }
2997
2998    /// Name of the method defined in FIDL
2999    pub fn method_name(&self) -> &'static str {
3000        match *self {
3001            NeededBlobsRequest::OpenMetaBlob { .. } => "open_meta_blob",
3002            NeededBlobsRequest::GetMissingBlobs { .. } => "get_missing_blobs",
3003            NeededBlobsRequest::OpenBlob { .. } => "open_blob",
3004            NeededBlobsRequest::BlobWritten { .. } => "blob_written",
3005            NeededBlobsRequest::Abort { .. } => "abort",
3006        }
3007    }
3008}
3009
3010#[derive(Debug, Clone)]
3011pub struct NeededBlobsControlHandle {
3012    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3013}
3014
3015impl fidl::endpoints::ControlHandle for NeededBlobsControlHandle {
3016    fn shutdown(&self) {
3017        self.inner.shutdown()
3018    }
3019    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3020        self.inner.shutdown_with_epitaph(status)
3021    }
3022
3023    fn is_closed(&self) -> bool {
3024        self.inner.channel().is_closed()
3025    }
3026    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3027        self.inner.channel().on_closed()
3028    }
3029
3030    #[cfg(target_os = "fuchsia")]
3031    fn signal_peer(
3032        &self,
3033        clear_mask: zx::Signals,
3034        set_mask: zx::Signals,
3035    ) -> Result<(), zx_status::Status> {
3036        use fidl::Peered;
3037        self.inner.channel().signal_peer(clear_mask, set_mask)
3038    }
3039}
3040
3041impl NeededBlobsControlHandle {}
3042
3043#[must_use = "FIDL methods require a response to be sent"]
3044#[derive(Debug)]
3045pub struct NeededBlobsOpenMetaBlobResponder {
3046    control_handle: std::mem::ManuallyDrop<NeededBlobsControlHandle>,
3047    tx_id: u32,
3048}
3049
3050/// Set the the channel to be shutdown (see [`NeededBlobsControlHandle::shutdown`])
3051/// if the responder is dropped without sending a response, so that the client
3052/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3053impl std::ops::Drop for NeededBlobsOpenMetaBlobResponder {
3054    fn drop(&mut self) {
3055        self.control_handle.shutdown();
3056        // Safety: drops once, never accessed again
3057        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3058    }
3059}
3060
3061impl fidl::endpoints::Responder for NeededBlobsOpenMetaBlobResponder {
3062    type ControlHandle = NeededBlobsControlHandle;
3063
3064    fn control_handle(&self) -> &NeededBlobsControlHandle {
3065        &self.control_handle
3066    }
3067
3068    fn drop_without_shutdown(mut self) {
3069        // Safety: drops once, never accessed again due to mem::forget
3070        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3071        // Prevent Drop from running (which would shut down the channel)
3072        std::mem::forget(self);
3073    }
3074}
3075
3076impl NeededBlobsOpenMetaBlobResponder {
3077    /// Sends a response to the FIDL transaction.
3078    ///
3079    /// Sets the channel to shutdown if an error occurs.
3080    pub fn send(
3081        self,
3082        mut result: Result<Option<BlobWriter>, OpenBlobError>,
3083    ) -> Result<(), fidl::Error> {
3084        let _result = self.send_raw(result);
3085        if _result.is_err() {
3086            self.control_handle.shutdown();
3087        }
3088        self.drop_without_shutdown();
3089        _result
3090    }
3091
3092    /// Similar to "send" but does not shutdown the channel if an error occurs.
3093    pub fn send_no_shutdown_on_err(
3094        self,
3095        mut result: Result<Option<BlobWriter>, OpenBlobError>,
3096    ) -> Result<(), fidl::Error> {
3097        let _result = self.send_raw(result);
3098        self.drop_without_shutdown();
3099        _result
3100    }
3101
3102    fn send_raw(
3103        &self,
3104        mut result: Result<Option<BlobWriter>, OpenBlobError>,
3105    ) -> Result<(), fidl::Error> {
3106        self.control_handle.inner.send::<fidl::encoding::ResultType<
3107            NeededBlobsOpenMetaBlobResponse,
3108            OpenBlobError,
3109        >>(
3110            result.as_mut().map_err(|e| *e).map(|writer| (writer.as_mut(),)),
3111            self.tx_id,
3112            0x42f385a58180f5fb,
3113            fidl::encoding::DynamicFlags::empty(),
3114        )
3115    }
3116}
3117
3118#[must_use = "FIDL methods require a response to be sent"]
3119#[derive(Debug)]
3120pub struct NeededBlobsOpenBlobResponder {
3121    control_handle: std::mem::ManuallyDrop<NeededBlobsControlHandle>,
3122    tx_id: u32,
3123}
3124
3125/// Set the the channel to be shutdown (see [`NeededBlobsControlHandle::shutdown`])
3126/// if the responder is dropped without sending a response, so that the client
3127/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3128impl std::ops::Drop for NeededBlobsOpenBlobResponder {
3129    fn drop(&mut self) {
3130        self.control_handle.shutdown();
3131        // Safety: drops once, never accessed again
3132        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3133    }
3134}
3135
3136impl fidl::endpoints::Responder for NeededBlobsOpenBlobResponder {
3137    type ControlHandle = NeededBlobsControlHandle;
3138
3139    fn control_handle(&self) -> &NeededBlobsControlHandle {
3140        &self.control_handle
3141    }
3142
3143    fn drop_without_shutdown(mut self) {
3144        // Safety: drops once, never accessed again due to mem::forget
3145        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3146        // Prevent Drop from running (which would shut down the channel)
3147        std::mem::forget(self);
3148    }
3149}
3150
3151impl NeededBlobsOpenBlobResponder {
3152    /// Sends a response to the FIDL transaction.
3153    ///
3154    /// Sets the channel to shutdown if an error occurs.
3155    pub fn send(
3156        self,
3157        mut result: Result<Option<BlobWriter>, OpenBlobError>,
3158    ) -> Result<(), fidl::Error> {
3159        let _result = self.send_raw(result);
3160        if _result.is_err() {
3161            self.control_handle.shutdown();
3162        }
3163        self.drop_without_shutdown();
3164        _result
3165    }
3166
3167    /// Similar to "send" but does not shutdown the channel if an error occurs.
3168    pub fn send_no_shutdown_on_err(
3169        self,
3170        mut result: Result<Option<BlobWriter>, OpenBlobError>,
3171    ) -> Result<(), fidl::Error> {
3172        let _result = self.send_raw(result);
3173        self.drop_without_shutdown();
3174        _result
3175    }
3176
3177    fn send_raw(
3178        &self,
3179        mut result: Result<Option<BlobWriter>, OpenBlobError>,
3180    ) -> Result<(), fidl::Error> {
3181        self.control_handle.inner.send::<fidl::encoding::ResultType<
3182            NeededBlobsOpenBlobResponse,
3183            OpenBlobError,
3184        >>(
3185            result.as_mut().map_err(|e| *e).map(|writer| (writer.as_mut(),)),
3186            self.tx_id,
3187            0x67cd4c4cd10ea9e0,
3188            fidl::encoding::DynamicFlags::empty(),
3189        )
3190    }
3191}
3192
3193#[must_use = "FIDL methods require a response to be sent"]
3194#[derive(Debug)]
3195pub struct NeededBlobsBlobWrittenResponder {
3196    control_handle: std::mem::ManuallyDrop<NeededBlobsControlHandle>,
3197    tx_id: u32,
3198}
3199
3200/// Set the the channel to be shutdown (see [`NeededBlobsControlHandle::shutdown`])
3201/// if the responder is dropped without sending a response, so that the client
3202/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3203impl std::ops::Drop for NeededBlobsBlobWrittenResponder {
3204    fn drop(&mut self) {
3205        self.control_handle.shutdown();
3206        // Safety: drops once, never accessed again
3207        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3208    }
3209}
3210
3211impl fidl::endpoints::Responder for NeededBlobsBlobWrittenResponder {
3212    type ControlHandle = NeededBlobsControlHandle;
3213
3214    fn control_handle(&self) -> &NeededBlobsControlHandle {
3215        &self.control_handle
3216    }
3217
3218    fn drop_without_shutdown(mut self) {
3219        // Safety: drops once, never accessed again due to mem::forget
3220        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3221        // Prevent Drop from running (which would shut down the channel)
3222        std::mem::forget(self);
3223    }
3224}
3225
3226impl NeededBlobsBlobWrittenResponder {
3227    /// Sends a response to the FIDL transaction.
3228    ///
3229    /// Sets the channel to shutdown if an error occurs.
3230    pub fn send(self, mut result: Result<(), BlobWrittenError>) -> Result<(), fidl::Error> {
3231        let _result = self.send_raw(result);
3232        if _result.is_err() {
3233            self.control_handle.shutdown();
3234        }
3235        self.drop_without_shutdown();
3236        _result
3237    }
3238
3239    /// Similar to "send" but does not shutdown the channel if an error occurs.
3240    pub fn send_no_shutdown_on_err(
3241        self,
3242        mut result: Result<(), BlobWrittenError>,
3243    ) -> Result<(), fidl::Error> {
3244        let _result = self.send_raw(result);
3245        self.drop_without_shutdown();
3246        _result
3247    }
3248
3249    fn send_raw(&self, mut result: Result<(), BlobWrittenError>) -> Result<(), fidl::Error> {
3250        self.control_handle.inner.send::<fidl::encoding::ResultType<
3251            fidl::encoding::EmptyStruct,
3252            BlobWrittenError,
3253        >>(
3254            result,
3255            self.tx_id,
3256            0x222f80ec77433f44,
3257            fidl::encoding::DynamicFlags::empty(),
3258        )
3259    }
3260}
3261
3262#[must_use = "FIDL methods require a response to be sent"]
3263#[derive(Debug)]
3264pub struct NeededBlobsAbortResponder {
3265    control_handle: std::mem::ManuallyDrop<NeededBlobsControlHandle>,
3266    tx_id: u32,
3267}
3268
3269/// Set the the channel to be shutdown (see [`NeededBlobsControlHandle::shutdown`])
3270/// if the responder is dropped without sending a response, so that the client
3271/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3272impl std::ops::Drop for NeededBlobsAbortResponder {
3273    fn drop(&mut self) {
3274        self.control_handle.shutdown();
3275        // Safety: drops once, never accessed again
3276        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3277    }
3278}
3279
3280impl fidl::endpoints::Responder for NeededBlobsAbortResponder {
3281    type ControlHandle = NeededBlobsControlHandle;
3282
3283    fn control_handle(&self) -> &NeededBlobsControlHandle {
3284        &self.control_handle
3285    }
3286
3287    fn drop_without_shutdown(mut self) {
3288        // Safety: drops once, never accessed again due to mem::forget
3289        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3290        // Prevent Drop from running (which would shut down the channel)
3291        std::mem::forget(self);
3292    }
3293}
3294
3295impl NeededBlobsAbortResponder {
3296    /// Sends a response to the FIDL transaction.
3297    ///
3298    /// Sets the channel to shutdown if an error occurs.
3299    pub fn send(self) -> Result<(), fidl::Error> {
3300        let _result = self.send_raw();
3301        if _result.is_err() {
3302            self.control_handle.shutdown();
3303        }
3304        self.drop_without_shutdown();
3305        _result
3306    }
3307
3308    /// Similar to "send" but does not shutdown the channel if an error occurs.
3309    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3310        let _result = self.send_raw();
3311        self.drop_without_shutdown();
3312        _result
3313    }
3314
3315    fn send_raw(&self) -> Result<(), fidl::Error> {
3316        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
3317            (),
3318            self.tx_id,
3319            0x6fda8d5ebea74cbb,
3320            fidl::encoding::DynamicFlags::empty(),
3321        )
3322    }
3323}
3324
3325#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3326pub struct PackageCacheMarker;
3327
3328impl fidl::endpoints::ProtocolMarker for PackageCacheMarker {
3329    type Proxy = PackageCacheProxy;
3330    type RequestStream = PackageCacheRequestStream;
3331    #[cfg(target_os = "fuchsia")]
3332    type SynchronousProxy = PackageCacheSynchronousProxy;
3333
3334    const DEBUG_NAME: &'static str = "fuchsia.pkg.PackageCache";
3335}
3336impl fidl::endpoints::DiscoverableProtocolMarker for PackageCacheMarker {}
3337pub type PackageCacheGetResult = Result<(), i32>;
3338pub type PackageCacheGetSubpackageResult = Result<(), GetSubpackageError>;
3339pub type PackageCacheSyncResult = Result<(), i32>;
3340pub type PackageCacheSetUpgradableUrlsResult = Result<(), SetUpgradableUrlsError>;
3341
3342pub trait PackageCacheProxyInterface: Send + Sync {
3343    type GetResponseFut: std::future::Future<Output = Result<PackageCacheGetResult, fidl::Error>>
3344        + Send;
3345    fn r#get(
3346        &self,
3347        meta_far_blob: &BlobInfo,
3348        gc_protection: GcProtection,
3349        needed_blobs: fidl::endpoints::ServerEnd<NeededBlobsMarker>,
3350        dir: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
3351    ) -> Self::GetResponseFut;
3352    type GetSubpackageResponseFut: std::future::Future<Output = Result<PackageCacheGetSubpackageResult, fidl::Error>>
3353        + Send;
3354    fn r#get_subpackage(
3355        &self,
3356        superpackage: &BlobId,
3357        subpackage: &PackageUrl,
3358        dir: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
3359    ) -> Self::GetSubpackageResponseFut;
3360    fn r#base_package_index(
3361        &self,
3362        iterator: fidl::endpoints::ServerEnd<PackageIndexIteratorMarker>,
3363    ) -> Result<(), fidl::Error>;
3364    fn r#cache_package_index(
3365        &self,
3366        iterator: fidl::endpoints::ServerEnd<PackageIndexIteratorMarker>,
3367    ) -> Result<(), fidl::Error>;
3368    type SyncResponseFut: std::future::Future<Output = Result<PackageCacheSyncResult, fidl::Error>>
3369        + Send;
3370    fn r#sync(&self) -> Self::SyncResponseFut;
3371    type SetUpgradableUrlsResponseFut: std::future::Future<Output = Result<PackageCacheSetUpgradableUrlsResult, fidl::Error>>
3372        + Send;
3373    fn r#set_upgradable_urls(
3374        &self,
3375        pinned_urls: &[PackageUrl],
3376    ) -> Self::SetUpgradableUrlsResponseFut;
3377}
3378#[derive(Debug)]
3379#[cfg(target_os = "fuchsia")]
3380pub struct PackageCacheSynchronousProxy {
3381    client: fidl::client::sync::Client,
3382}
3383
3384#[cfg(target_os = "fuchsia")]
3385impl fidl::endpoints::SynchronousProxy for PackageCacheSynchronousProxy {
3386    type Proxy = PackageCacheProxy;
3387    type Protocol = PackageCacheMarker;
3388
3389    fn from_channel(inner: fidl::Channel) -> Self {
3390        Self::new(inner)
3391    }
3392
3393    fn into_channel(self) -> fidl::Channel {
3394        self.client.into_channel()
3395    }
3396
3397    fn as_channel(&self) -> &fidl::Channel {
3398        self.client.as_channel()
3399    }
3400}
3401
3402#[cfg(target_os = "fuchsia")]
3403impl PackageCacheSynchronousProxy {
3404    pub fn new(channel: fidl::Channel) -> Self {
3405        let protocol_name = <PackageCacheMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3406        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
3407    }
3408
3409    pub fn into_channel(self) -> fidl::Channel {
3410        self.client.into_channel()
3411    }
3412
3413    /// Waits until an event arrives and returns it. It is safe for other
3414    /// threads to make concurrent requests while waiting for an event.
3415    pub fn wait_for_event(
3416        &self,
3417        deadline: zx::MonotonicInstant,
3418    ) -> Result<PackageCacheEvent, fidl::Error> {
3419        PackageCacheEvent::decode(self.client.wait_for_event(deadline)?)
3420    }
3421
3422    /// Gets the package directory if it is present on the local system. If it is not, the
3423    /// `missing_blobs` iterator will provide all the blobs in the package that are missing from
3424    /// the system, and the ability to write those blobs to blobfs. If all the missing blobs are
3425    /// downloaded and written to by the client, the `dir` directory will be resolved. This method
3426    /// will return successfully when the package has been fully resolved, or return an error if
3427    /// the client closes `needed_blobs` or `dir` handle before the package has been resolved.
3428    ///
3429    /// This method does not guarantee the missing blobs have been persisted. In order to guarantee
3430    /// missing blobs are persisted, clients should call ['Sync'].
3431    ///
3432    /// Clients must not make concurrent `Get()` calls for the same `meta_far_blob`, even across
3433    /// different `PackageCache` connections, *unless* the `meta_far_blob` is in base or already
3434    /// active in the dynamic index. Violating this may result in `Get()` errors.
3435    ///
3436    /// + request `meta_far_blob` the blob info for the package's meta.far.
3437    /// + request `needed_blobs` an iterator over all the blobs in the package that
3438    ///   are not present on the system.
3439    /// + request `dir` the channel on which the package directory will be served.
3440    /// * error a zx_status value indicating failure. One of the following:
3441    ///     * `ZX_ERR_UNAVAILABLE` if the client closed `needed_blobs` handles before
3442    ///       all the missing blobs were downloaded to the system.
3443    pub fn r#get(
3444        &self,
3445        mut meta_far_blob: &BlobInfo,
3446        mut gc_protection: GcProtection,
3447        mut needed_blobs: fidl::endpoints::ServerEnd<NeededBlobsMarker>,
3448        mut dir: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
3449        ___deadline: zx::MonotonicInstant,
3450    ) -> Result<PackageCacheGetResult, fidl::Error> {
3451        let _response = self.client.send_query::<
3452            PackageCacheGetRequest,
3453            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
3454        >(
3455            (meta_far_blob, gc_protection, needed_blobs, dir,),
3456            0x15e1963f4bf123b5,
3457            fidl::encoding::DynamicFlags::empty(),
3458            ___deadline,
3459        )?;
3460        Ok(_response.map(|x| x))
3461    }
3462
3463    /// Gets the package directory for a subpackage.
3464    /// The connection to the superpackage's package directory must still be open when this is
3465    /// called.
3466    /// The returned package will be protected by open package tracking.
3467    ///
3468    /// + request `superpackage` the hash of the superpackage's meta.far.
3469    /// + request `subpackage` the relative package URL of the subpackage.
3470    /// + request `dir` the channel on which the package directory will be served.
3471    /// * error a GetSubpackageError value indicating failure.
3472    pub fn r#get_subpackage(
3473        &self,
3474        mut superpackage: &BlobId,
3475        mut subpackage: &PackageUrl,
3476        mut dir: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
3477        ___deadline: zx::MonotonicInstant,
3478    ) -> Result<PackageCacheGetSubpackageResult, fidl::Error> {
3479        let _response =
3480            self.client.send_query::<PackageCacheGetSubpackageRequest, fidl::encoding::ResultType<
3481                fidl::encoding::EmptyStruct,
3482                GetSubpackageError,
3483            >>(
3484                (superpackage, subpackage, dir),
3485                0x29478df87c29ffa3,
3486                fidl::encoding::DynamicFlags::empty(),
3487                ___deadline,
3488            )?;
3489        Ok(_response.map(|x| x))
3490    }
3491
3492    /// Retrieves a chunk iterator to the base package index.
3493    ///
3494    /// + request `iterator` a request for the `PackageIndexIterator` that will return sets of
3495    ///   `PackageIndexEntry` objects until all packages in the base index have been iterated.
3496    pub fn r#base_package_index(
3497        &self,
3498        mut iterator: fidl::endpoints::ServerEnd<PackageIndexIteratorMarker>,
3499    ) -> Result<(), fidl::Error> {
3500        self.client.send::<PackageCacheBasePackageIndexRequest>(
3501            (iterator,),
3502            0x46af9e595f8eced4,
3503            fidl::encoding::DynamicFlags::empty(),
3504        )
3505    }
3506
3507    /// Retrieves a chunk iterator to the cache package index.
3508    ///
3509    /// + request `iterator` a request for the `PackageIndexIterator` that will return sets of
3510    ///   `PackageIndexEntry` objects until all packages in the cache index have been iterated.
3511    pub fn r#cache_package_index(
3512        &self,
3513        mut iterator: fidl::endpoints::ServerEnd<PackageIndexIteratorMarker>,
3514    ) -> Result<(), fidl::Error> {
3515        self.client.send::<PackageCacheCachePackageIndexRequest>(
3516            (iterator,),
3517            0x14a48fdb8f26ed26,
3518            fidl::encoding::DynamicFlags::empty(),
3519        )
3520    }
3521
3522    /// Synchronizes updates to the cached packages to the underlying persistent storage.
3523    ///
3524    /// * error a zx_status value indicating failure. One of the following:
3525    ///     * `ZX_ERR_INTERNAL` if the sync fails.
3526    pub fn r#sync(
3527        &self,
3528        ___deadline: zx::MonotonicInstant,
3529    ) -> Result<PackageCacheSyncResult, fidl::Error> {
3530        let _response = self.client.send_query::<
3531            fidl::encoding::EmptyPayload,
3532            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
3533        >(
3534            (),
3535            0x5c10a84094535a74,
3536            fidl::encoding::DynamicFlags::empty(),
3537            ___deadline,
3538        )?;
3539        Ok(_response.map(|x| x))
3540    }
3541
3542    /// Sets which package URLs correspond to upgradable packages and the hash they should resolve
3543    /// to.
3544    ///
3545    /// If upgradable packages are enabled in pkg-cache, this method must be called once on start up
3546    /// to set the hashes for persisted upgradable packages. All such packages must not be base
3547    /// packages. If none of the upgradable packages are persisted, a call with an empty vector
3548    /// still needs to be made. Package resolution of non base packages and GC (and therefore OTA)
3549    /// will block until this is done.
3550    ///
3551    /// Subsequent calls can be made to set new upgradable packages or change the hashes associated
3552    /// with upgradable packages.
3553    ///
3554    /// The hash most recently associated with an upgradable package URL will be protected from GC.
3555    ///
3556    /// + request `pinned_urls` packages URLs pinned to the new hash.
3557    pub fn r#set_upgradable_urls(
3558        &self,
3559        mut pinned_urls: &[PackageUrl],
3560        ___deadline: zx::MonotonicInstant,
3561    ) -> Result<PackageCacheSetUpgradableUrlsResult, fidl::Error> {
3562        let _response = self.client.send_query::<
3563            PackageCacheSetUpgradableUrlsRequest,
3564            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, SetUpgradableUrlsError>,
3565        >(
3566            (pinned_urls,),
3567            0x2c235f7efdb5e2d1,
3568            fidl::encoding::DynamicFlags::FLEXIBLE,
3569            ___deadline,
3570        )?
3571        .into_result::<PackageCacheMarker>("set_upgradable_urls")?;
3572        Ok(_response.map(|x| x))
3573    }
3574}
3575
3576#[cfg(target_os = "fuchsia")]
3577impl From<PackageCacheSynchronousProxy> for zx::Handle {
3578    fn from(value: PackageCacheSynchronousProxy) -> Self {
3579        value.into_channel().into()
3580    }
3581}
3582
3583#[cfg(target_os = "fuchsia")]
3584impl From<fidl::Channel> for PackageCacheSynchronousProxy {
3585    fn from(value: fidl::Channel) -> Self {
3586        Self::new(value)
3587    }
3588}
3589
3590#[derive(Debug, Clone)]
3591pub struct PackageCacheProxy {
3592    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3593}
3594
3595impl fidl::endpoints::Proxy for PackageCacheProxy {
3596    type Protocol = PackageCacheMarker;
3597
3598    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3599        Self::new(inner)
3600    }
3601
3602    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3603        self.client.into_channel().map_err(|client| Self { client })
3604    }
3605
3606    fn as_channel(&self) -> &::fidl::AsyncChannel {
3607        self.client.as_channel()
3608    }
3609}
3610
3611impl PackageCacheProxy {
3612    /// Create a new Proxy for fuchsia.pkg/PackageCache.
3613    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3614        let protocol_name = <PackageCacheMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3615        Self { client: fidl::client::Client::new(channel, protocol_name) }
3616    }
3617
3618    /// Get a Stream of events from the remote end of the protocol.
3619    ///
3620    /// # Panics
3621    ///
3622    /// Panics if the event stream was already taken.
3623    pub fn take_event_stream(&self) -> PackageCacheEventStream {
3624        PackageCacheEventStream { event_receiver: self.client.take_event_receiver() }
3625    }
3626
3627    /// Gets the package directory if it is present on the local system. If it is not, the
3628    /// `missing_blobs` iterator will provide all the blobs in the package that are missing from
3629    /// the system, and the ability to write those blobs to blobfs. If all the missing blobs are
3630    /// downloaded and written to by the client, the `dir` directory will be resolved. This method
3631    /// will return successfully when the package has been fully resolved, or return an error if
3632    /// the client closes `needed_blobs` or `dir` handle before the package has been resolved.
3633    ///
3634    /// This method does not guarantee the missing blobs have been persisted. In order to guarantee
3635    /// missing blobs are persisted, clients should call ['Sync'].
3636    ///
3637    /// Clients must not make concurrent `Get()` calls for the same `meta_far_blob`, even across
3638    /// different `PackageCache` connections, *unless* the `meta_far_blob` is in base or already
3639    /// active in the dynamic index. Violating this may result in `Get()` errors.
3640    ///
3641    /// + request `meta_far_blob` the blob info for the package's meta.far.
3642    /// + request `needed_blobs` an iterator over all the blobs in the package that
3643    ///   are not present on the system.
3644    /// + request `dir` the channel on which the package directory will be served.
3645    /// * error a zx_status value indicating failure. One of the following:
3646    ///     * `ZX_ERR_UNAVAILABLE` if the client closed `needed_blobs` handles before
3647    ///       all the missing blobs were downloaded to the system.
3648    pub fn r#get(
3649        &self,
3650        mut meta_far_blob: &BlobInfo,
3651        mut gc_protection: GcProtection,
3652        mut needed_blobs: fidl::endpoints::ServerEnd<NeededBlobsMarker>,
3653        mut dir: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
3654    ) -> fidl::client::QueryResponseFut<
3655        PackageCacheGetResult,
3656        fidl::encoding::DefaultFuchsiaResourceDialect,
3657    > {
3658        PackageCacheProxyInterface::r#get(self, meta_far_blob, gc_protection, needed_blobs, dir)
3659    }
3660
3661    /// Gets the package directory for a subpackage.
3662    /// The connection to the superpackage's package directory must still be open when this is
3663    /// called.
3664    /// The returned package will be protected by open package tracking.
3665    ///
3666    /// + request `superpackage` the hash of the superpackage's meta.far.
3667    /// + request `subpackage` the relative package URL of the subpackage.
3668    /// + request `dir` the channel on which the package directory will be served.
3669    /// * error a GetSubpackageError value indicating failure.
3670    pub fn r#get_subpackage(
3671        &self,
3672        mut superpackage: &BlobId,
3673        mut subpackage: &PackageUrl,
3674        mut dir: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
3675    ) -> fidl::client::QueryResponseFut<
3676        PackageCacheGetSubpackageResult,
3677        fidl::encoding::DefaultFuchsiaResourceDialect,
3678    > {
3679        PackageCacheProxyInterface::r#get_subpackage(self, superpackage, subpackage, dir)
3680    }
3681
3682    /// Retrieves a chunk iterator to the base package index.
3683    ///
3684    /// + request `iterator` a request for the `PackageIndexIterator` that will return sets of
3685    ///   `PackageIndexEntry` objects until all packages in the base index have been iterated.
3686    pub fn r#base_package_index(
3687        &self,
3688        mut iterator: fidl::endpoints::ServerEnd<PackageIndexIteratorMarker>,
3689    ) -> Result<(), fidl::Error> {
3690        PackageCacheProxyInterface::r#base_package_index(self, iterator)
3691    }
3692
3693    /// Retrieves a chunk iterator to the cache package index.
3694    ///
3695    /// + request `iterator` a request for the `PackageIndexIterator` that will return sets of
3696    ///   `PackageIndexEntry` objects until all packages in the cache index have been iterated.
3697    pub fn r#cache_package_index(
3698        &self,
3699        mut iterator: fidl::endpoints::ServerEnd<PackageIndexIteratorMarker>,
3700    ) -> Result<(), fidl::Error> {
3701        PackageCacheProxyInterface::r#cache_package_index(self, iterator)
3702    }
3703
3704    /// Synchronizes updates to the cached packages to the underlying persistent storage.
3705    ///
3706    /// * error a zx_status value indicating failure. One of the following:
3707    ///     * `ZX_ERR_INTERNAL` if the sync fails.
3708    pub fn r#sync(
3709        &self,
3710    ) -> fidl::client::QueryResponseFut<
3711        PackageCacheSyncResult,
3712        fidl::encoding::DefaultFuchsiaResourceDialect,
3713    > {
3714        PackageCacheProxyInterface::r#sync(self)
3715    }
3716
3717    /// Sets which package URLs correspond to upgradable packages and the hash they should resolve
3718    /// to.
3719    ///
3720    /// If upgradable packages are enabled in pkg-cache, this method must be called once on start up
3721    /// to set the hashes for persisted upgradable packages. All such packages must not be base
3722    /// packages. If none of the upgradable packages are persisted, a call with an empty vector
3723    /// still needs to be made. Package resolution of non base packages and GC (and therefore OTA)
3724    /// will block until this is done.
3725    ///
3726    /// Subsequent calls can be made to set new upgradable packages or change the hashes associated
3727    /// with upgradable packages.
3728    ///
3729    /// The hash most recently associated with an upgradable package URL will be protected from GC.
3730    ///
3731    /// + request `pinned_urls` packages URLs pinned to the new hash.
3732    pub fn r#set_upgradable_urls(
3733        &self,
3734        mut pinned_urls: &[PackageUrl],
3735    ) -> fidl::client::QueryResponseFut<
3736        PackageCacheSetUpgradableUrlsResult,
3737        fidl::encoding::DefaultFuchsiaResourceDialect,
3738    > {
3739        PackageCacheProxyInterface::r#set_upgradable_urls(self, pinned_urls)
3740    }
3741}
3742
3743impl PackageCacheProxyInterface for PackageCacheProxy {
3744    type GetResponseFut = fidl::client::QueryResponseFut<
3745        PackageCacheGetResult,
3746        fidl::encoding::DefaultFuchsiaResourceDialect,
3747    >;
3748    fn r#get(
3749        &self,
3750        mut meta_far_blob: &BlobInfo,
3751        mut gc_protection: GcProtection,
3752        mut needed_blobs: fidl::endpoints::ServerEnd<NeededBlobsMarker>,
3753        mut dir: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
3754    ) -> Self::GetResponseFut {
3755        fn _decode(
3756            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3757        ) -> Result<PackageCacheGetResult, fidl::Error> {
3758            let _response = fidl::client::decode_transaction_body::<
3759                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
3760                fidl::encoding::DefaultFuchsiaResourceDialect,
3761                0x15e1963f4bf123b5,
3762            >(_buf?)?;
3763            Ok(_response.map(|x| x))
3764        }
3765        self.client.send_query_and_decode::<PackageCacheGetRequest, PackageCacheGetResult>(
3766            (meta_far_blob, gc_protection, needed_blobs, dir),
3767            0x15e1963f4bf123b5,
3768            fidl::encoding::DynamicFlags::empty(),
3769            _decode,
3770        )
3771    }
3772
3773    type GetSubpackageResponseFut = fidl::client::QueryResponseFut<
3774        PackageCacheGetSubpackageResult,
3775        fidl::encoding::DefaultFuchsiaResourceDialect,
3776    >;
3777    fn r#get_subpackage(
3778        &self,
3779        mut superpackage: &BlobId,
3780        mut subpackage: &PackageUrl,
3781        mut dir: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
3782    ) -> Self::GetSubpackageResponseFut {
3783        fn _decode(
3784            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3785        ) -> Result<PackageCacheGetSubpackageResult, fidl::Error> {
3786            let _response = fidl::client::decode_transaction_body::<
3787                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, GetSubpackageError>,
3788                fidl::encoding::DefaultFuchsiaResourceDialect,
3789                0x29478df87c29ffa3,
3790            >(_buf?)?;
3791            Ok(_response.map(|x| x))
3792        }
3793        self.client.send_query_and_decode::<
3794            PackageCacheGetSubpackageRequest,
3795            PackageCacheGetSubpackageResult,
3796        >(
3797            (superpackage, subpackage, dir,),
3798            0x29478df87c29ffa3,
3799            fidl::encoding::DynamicFlags::empty(),
3800            _decode,
3801        )
3802    }
3803
3804    fn r#base_package_index(
3805        &self,
3806        mut iterator: fidl::endpoints::ServerEnd<PackageIndexIteratorMarker>,
3807    ) -> Result<(), fidl::Error> {
3808        self.client.send::<PackageCacheBasePackageIndexRequest>(
3809            (iterator,),
3810            0x46af9e595f8eced4,
3811            fidl::encoding::DynamicFlags::empty(),
3812        )
3813    }
3814
3815    fn r#cache_package_index(
3816        &self,
3817        mut iterator: fidl::endpoints::ServerEnd<PackageIndexIteratorMarker>,
3818    ) -> Result<(), fidl::Error> {
3819        self.client.send::<PackageCacheCachePackageIndexRequest>(
3820            (iterator,),
3821            0x14a48fdb8f26ed26,
3822            fidl::encoding::DynamicFlags::empty(),
3823        )
3824    }
3825
3826    type SyncResponseFut = fidl::client::QueryResponseFut<
3827        PackageCacheSyncResult,
3828        fidl::encoding::DefaultFuchsiaResourceDialect,
3829    >;
3830    fn r#sync(&self) -> Self::SyncResponseFut {
3831        fn _decode(
3832            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3833        ) -> Result<PackageCacheSyncResult, fidl::Error> {
3834            let _response = fidl::client::decode_transaction_body::<
3835                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
3836                fidl::encoding::DefaultFuchsiaResourceDialect,
3837                0x5c10a84094535a74,
3838            >(_buf?)?;
3839            Ok(_response.map(|x| x))
3840        }
3841        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, PackageCacheSyncResult>(
3842            (),
3843            0x5c10a84094535a74,
3844            fidl::encoding::DynamicFlags::empty(),
3845            _decode,
3846        )
3847    }
3848
3849    type SetUpgradableUrlsResponseFut = fidl::client::QueryResponseFut<
3850        PackageCacheSetUpgradableUrlsResult,
3851        fidl::encoding::DefaultFuchsiaResourceDialect,
3852    >;
3853    fn r#set_upgradable_urls(
3854        &self,
3855        mut pinned_urls: &[PackageUrl],
3856    ) -> Self::SetUpgradableUrlsResponseFut {
3857        fn _decode(
3858            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3859        ) -> Result<PackageCacheSetUpgradableUrlsResult, fidl::Error> {
3860            let _response = fidl::client::decode_transaction_body::<
3861                fidl::encoding::FlexibleResultType<
3862                    fidl::encoding::EmptyStruct,
3863                    SetUpgradableUrlsError,
3864                >,
3865                fidl::encoding::DefaultFuchsiaResourceDialect,
3866                0x2c235f7efdb5e2d1,
3867            >(_buf?)?
3868            .into_result::<PackageCacheMarker>("set_upgradable_urls")?;
3869            Ok(_response.map(|x| x))
3870        }
3871        self.client.send_query_and_decode::<
3872            PackageCacheSetUpgradableUrlsRequest,
3873            PackageCacheSetUpgradableUrlsResult,
3874        >(
3875            (pinned_urls,),
3876            0x2c235f7efdb5e2d1,
3877            fidl::encoding::DynamicFlags::FLEXIBLE,
3878            _decode,
3879        )
3880    }
3881}
3882
3883pub struct PackageCacheEventStream {
3884    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3885}
3886
3887impl std::marker::Unpin for PackageCacheEventStream {}
3888
3889impl futures::stream::FusedStream for PackageCacheEventStream {
3890    fn is_terminated(&self) -> bool {
3891        self.event_receiver.is_terminated()
3892    }
3893}
3894
3895impl futures::Stream for PackageCacheEventStream {
3896    type Item = Result<PackageCacheEvent, fidl::Error>;
3897
3898    fn poll_next(
3899        mut self: std::pin::Pin<&mut Self>,
3900        cx: &mut std::task::Context<'_>,
3901    ) -> std::task::Poll<Option<Self::Item>> {
3902        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3903            &mut self.event_receiver,
3904            cx
3905        )?) {
3906            Some(buf) => std::task::Poll::Ready(Some(PackageCacheEvent::decode(buf))),
3907            None => std::task::Poll::Ready(None),
3908        }
3909    }
3910}
3911
3912#[derive(Debug)]
3913pub enum PackageCacheEvent {
3914    #[non_exhaustive]
3915    _UnknownEvent {
3916        /// Ordinal of the event that was sent.
3917        ordinal: u64,
3918    },
3919}
3920
3921impl PackageCacheEvent {
3922    /// Decodes a message buffer as a [`PackageCacheEvent`].
3923    fn decode(
3924        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3925    ) -> Result<PackageCacheEvent, fidl::Error> {
3926        let (bytes, _handles) = buf.split_mut();
3927        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3928        debug_assert_eq!(tx_header.tx_id, 0);
3929        match tx_header.ordinal {
3930            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
3931                Ok(PackageCacheEvent::_UnknownEvent { ordinal: tx_header.ordinal })
3932            }
3933            _ => Err(fidl::Error::UnknownOrdinal {
3934                ordinal: tx_header.ordinal,
3935                protocol_name: <PackageCacheMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3936            }),
3937        }
3938    }
3939}
3940
3941/// A Stream of incoming requests for fuchsia.pkg/PackageCache.
3942pub struct PackageCacheRequestStream {
3943    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3944    is_terminated: bool,
3945}
3946
3947impl std::marker::Unpin for PackageCacheRequestStream {}
3948
3949impl futures::stream::FusedStream for PackageCacheRequestStream {
3950    fn is_terminated(&self) -> bool {
3951        self.is_terminated
3952    }
3953}
3954
3955impl fidl::endpoints::RequestStream for PackageCacheRequestStream {
3956    type Protocol = PackageCacheMarker;
3957    type ControlHandle = PackageCacheControlHandle;
3958
3959    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3960        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3961    }
3962
3963    fn control_handle(&self) -> Self::ControlHandle {
3964        PackageCacheControlHandle { inner: self.inner.clone() }
3965    }
3966
3967    fn into_inner(
3968        self,
3969    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3970    {
3971        (self.inner, self.is_terminated)
3972    }
3973
3974    fn from_inner(
3975        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3976        is_terminated: bool,
3977    ) -> Self {
3978        Self { inner, is_terminated }
3979    }
3980}
3981
3982impl futures::Stream for PackageCacheRequestStream {
3983    type Item = Result<PackageCacheRequest, fidl::Error>;
3984
3985    fn poll_next(
3986        mut self: std::pin::Pin<&mut Self>,
3987        cx: &mut std::task::Context<'_>,
3988    ) -> std::task::Poll<Option<Self::Item>> {
3989        let this = &mut *self;
3990        if this.inner.check_shutdown(cx) {
3991            this.is_terminated = true;
3992            return std::task::Poll::Ready(None);
3993        }
3994        if this.is_terminated {
3995            panic!("polled PackageCacheRequestStream after completion");
3996        }
3997        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3998            |bytes, handles| {
3999                match this.inner.channel().read_etc(cx, bytes, handles) {
4000                    std::task::Poll::Ready(Ok(())) => {}
4001                    std::task::Poll::Pending => return std::task::Poll::Pending,
4002                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4003                        this.is_terminated = true;
4004                        return std::task::Poll::Ready(None);
4005                    }
4006                    std::task::Poll::Ready(Err(e)) => {
4007                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4008                            e.into(),
4009                        ))))
4010                    }
4011                }
4012
4013                // A message has been received from the channel
4014                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4015
4016                std::task::Poll::Ready(Some(match header.ordinal {
4017                    0x15e1963f4bf123b5 => {
4018                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4019                        let mut req = fidl::new_empty!(
4020                            PackageCacheGetRequest,
4021                            fidl::encoding::DefaultFuchsiaResourceDialect
4022                        );
4023                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PackageCacheGetRequest>(&header, _body_bytes, handles, &mut req)?;
4024                        let control_handle =
4025                            PackageCacheControlHandle { inner: this.inner.clone() };
4026                        Ok(PackageCacheRequest::Get {
4027                            meta_far_blob: req.meta_far_blob,
4028                            gc_protection: req.gc_protection,
4029                            needed_blobs: req.needed_blobs,
4030                            dir: req.dir,
4031
4032                            responder: PackageCacheGetResponder {
4033                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4034                                tx_id: header.tx_id,
4035                            },
4036                        })
4037                    }
4038                    0x29478df87c29ffa3 => {
4039                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4040                        let mut req = fidl::new_empty!(
4041                            PackageCacheGetSubpackageRequest,
4042                            fidl::encoding::DefaultFuchsiaResourceDialect
4043                        );
4044                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PackageCacheGetSubpackageRequest>(&header, _body_bytes, handles, &mut req)?;
4045                        let control_handle =
4046                            PackageCacheControlHandle { inner: this.inner.clone() };
4047                        Ok(PackageCacheRequest::GetSubpackage {
4048                            superpackage: req.superpackage,
4049                            subpackage: req.subpackage,
4050                            dir: req.dir,
4051
4052                            responder: PackageCacheGetSubpackageResponder {
4053                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4054                                tx_id: header.tx_id,
4055                            },
4056                        })
4057                    }
4058                    0x46af9e595f8eced4 => {
4059                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4060                        let mut req = fidl::new_empty!(
4061                            PackageCacheBasePackageIndexRequest,
4062                            fidl::encoding::DefaultFuchsiaResourceDialect
4063                        );
4064                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PackageCacheBasePackageIndexRequest>(&header, _body_bytes, handles, &mut req)?;
4065                        let control_handle =
4066                            PackageCacheControlHandle { inner: this.inner.clone() };
4067                        Ok(PackageCacheRequest::BasePackageIndex {
4068                            iterator: req.iterator,
4069
4070                            control_handle,
4071                        })
4072                    }
4073                    0x14a48fdb8f26ed26 => {
4074                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4075                        let mut req = fidl::new_empty!(
4076                            PackageCacheCachePackageIndexRequest,
4077                            fidl::encoding::DefaultFuchsiaResourceDialect
4078                        );
4079                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PackageCacheCachePackageIndexRequest>(&header, _body_bytes, handles, &mut req)?;
4080                        let control_handle =
4081                            PackageCacheControlHandle { inner: this.inner.clone() };
4082                        Ok(PackageCacheRequest::CachePackageIndex {
4083                            iterator: req.iterator,
4084
4085                            control_handle,
4086                        })
4087                    }
4088                    0x5c10a84094535a74 => {
4089                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4090                        let mut req = fidl::new_empty!(
4091                            fidl::encoding::EmptyPayload,
4092                            fidl::encoding::DefaultFuchsiaResourceDialect
4093                        );
4094                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4095                        let control_handle =
4096                            PackageCacheControlHandle { inner: this.inner.clone() };
4097                        Ok(PackageCacheRequest::Sync {
4098                            responder: PackageCacheSyncResponder {
4099                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4100                                tx_id: header.tx_id,
4101                            },
4102                        })
4103                    }
4104                    0x2c235f7efdb5e2d1 => {
4105                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4106                        let mut req = fidl::new_empty!(
4107                            PackageCacheSetUpgradableUrlsRequest,
4108                            fidl::encoding::DefaultFuchsiaResourceDialect
4109                        );
4110                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PackageCacheSetUpgradableUrlsRequest>(&header, _body_bytes, handles, &mut req)?;
4111                        let control_handle =
4112                            PackageCacheControlHandle { inner: this.inner.clone() };
4113                        Ok(PackageCacheRequest::SetUpgradableUrls {
4114                            pinned_urls: req.pinned_urls,
4115
4116                            responder: PackageCacheSetUpgradableUrlsResponder {
4117                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4118                                tx_id: header.tx_id,
4119                            },
4120                        })
4121                    }
4122                    _ if header.tx_id == 0
4123                        && header
4124                            .dynamic_flags()
4125                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
4126                    {
4127                        Ok(PackageCacheRequest::_UnknownMethod {
4128                            ordinal: header.ordinal,
4129                            control_handle: PackageCacheControlHandle { inner: this.inner.clone() },
4130                            method_type: fidl::MethodType::OneWay,
4131                        })
4132                    }
4133                    _ if header
4134                        .dynamic_flags()
4135                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
4136                    {
4137                        this.inner.send_framework_err(
4138                            fidl::encoding::FrameworkErr::UnknownMethod,
4139                            header.tx_id,
4140                            header.ordinal,
4141                            header.dynamic_flags(),
4142                            (bytes, handles),
4143                        )?;
4144                        Ok(PackageCacheRequest::_UnknownMethod {
4145                            ordinal: header.ordinal,
4146                            control_handle: PackageCacheControlHandle { inner: this.inner.clone() },
4147                            method_type: fidl::MethodType::TwoWay,
4148                        })
4149                    }
4150                    _ => Err(fidl::Error::UnknownOrdinal {
4151                        ordinal: header.ordinal,
4152                        protocol_name:
4153                            <PackageCacheMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4154                    }),
4155                }))
4156            },
4157        )
4158    }
4159}
4160
4161/// This manages the system package cache.
4162///
4163/// This is intended to be implemented by the package manager component and used by
4164/// package resolver components.
4165#[derive(Debug)]
4166pub enum PackageCacheRequest {
4167    /// Gets the package directory if it is present on the local system. If it is not, the
4168    /// `missing_blobs` iterator will provide all the blobs in the package that are missing from
4169    /// the system, and the ability to write those blobs to blobfs. If all the missing blobs are
4170    /// downloaded and written to by the client, the `dir` directory will be resolved. This method
4171    /// will return successfully when the package has been fully resolved, or return an error if
4172    /// the client closes `needed_blobs` or `dir` handle before the package has been resolved.
4173    ///
4174    /// This method does not guarantee the missing blobs have been persisted. In order to guarantee
4175    /// missing blobs are persisted, clients should call ['Sync'].
4176    ///
4177    /// Clients must not make concurrent `Get()` calls for the same `meta_far_blob`, even across
4178    /// different `PackageCache` connections, *unless* the `meta_far_blob` is in base or already
4179    /// active in the dynamic index. Violating this may result in `Get()` errors.
4180    ///
4181    /// + request `meta_far_blob` the blob info for the package's meta.far.
4182    /// + request `needed_blobs` an iterator over all the blobs in the package that
4183    ///   are not present on the system.
4184    /// + request `dir` the channel on which the package directory will be served.
4185    /// * error a zx_status value indicating failure. One of the following:
4186    ///     * `ZX_ERR_UNAVAILABLE` if the client closed `needed_blobs` handles before
4187    ///       all the missing blobs were downloaded to the system.
4188    Get {
4189        meta_far_blob: BlobInfo,
4190        gc_protection: GcProtection,
4191        needed_blobs: fidl::endpoints::ServerEnd<NeededBlobsMarker>,
4192        dir: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
4193        responder: PackageCacheGetResponder,
4194    },
4195    /// Gets the package directory for a subpackage.
4196    /// The connection to the superpackage's package directory must still be open when this is
4197    /// called.
4198    /// The returned package will be protected by open package tracking.
4199    ///
4200    /// + request `superpackage` the hash of the superpackage's meta.far.
4201    /// + request `subpackage` the relative package URL of the subpackage.
4202    /// + request `dir` the channel on which the package directory will be served.
4203    /// * error a GetSubpackageError value indicating failure.
4204    GetSubpackage {
4205        superpackage: BlobId,
4206        subpackage: PackageUrl,
4207        dir: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
4208        responder: PackageCacheGetSubpackageResponder,
4209    },
4210    /// Retrieves a chunk iterator to the base package index.
4211    ///
4212    /// + request `iterator` a request for the `PackageIndexIterator` that will return sets of
4213    ///   `PackageIndexEntry` objects until all packages in the base index have been iterated.
4214    BasePackageIndex {
4215        iterator: fidl::endpoints::ServerEnd<PackageIndexIteratorMarker>,
4216        control_handle: PackageCacheControlHandle,
4217    },
4218    /// Retrieves a chunk iterator to the cache package index.
4219    ///
4220    /// + request `iterator` a request for the `PackageIndexIterator` that will return sets of
4221    ///   `PackageIndexEntry` objects until all packages in the cache index have been iterated.
4222    CachePackageIndex {
4223        iterator: fidl::endpoints::ServerEnd<PackageIndexIteratorMarker>,
4224        control_handle: PackageCacheControlHandle,
4225    },
4226    /// Synchronizes updates to the cached packages to the underlying persistent storage.
4227    ///
4228    /// * error a zx_status value indicating failure. One of the following:
4229    ///     * `ZX_ERR_INTERNAL` if the sync fails.
4230    Sync { responder: PackageCacheSyncResponder },
4231    /// Sets which package URLs correspond to upgradable packages and the hash they should resolve
4232    /// to.
4233    ///
4234    /// If upgradable packages are enabled in pkg-cache, this method must be called once on start up
4235    /// to set the hashes for persisted upgradable packages. All such packages must not be base
4236    /// packages. If none of the upgradable packages are persisted, a call with an empty vector
4237    /// still needs to be made. Package resolution of non base packages and GC (and therefore OTA)
4238    /// will block until this is done.
4239    ///
4240    /// Subsequent calls can be made to set new upgradable packages or change the hashes associated
4241    /// with upgradable packages.
4242    ///
4243    /// The hash most recently associated with an upgradable package URL will be protected from GC.
4244    ///
4245    /// + request `pinned_urls` packages URLs pinned to the new hash.
4246    SetUpgradableUrls {
4247        pinned_urls: Vec<PackageUrl>,
4248        responder: PackageCacheSetUpgradableUrlsResponder,
4249    },
4250    /// An interaction was received which does not match any known method.
4251    #[non_exhaustive]
4252    _UnknownMethod {
4253        /// Ordinal of the method that was called.
4254        ordinal: u64,
4255        control_handle: PackageCacheControlHandle,
4256        method_type: fidl::MethodType,
4257    },
4258}
4259
4260impl PackageCacheRequest {
4261    #[allow(irrefutable_let_patterns)]
4262    pub fn into_get(
4263        self,
4264    ) -> Option<(
4265        BlobInfo,
4266        GcProtection,
4267        fidl::endpoints::ServerEnd<NeededBlobsMarker>,
4268        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
4269        PackageCacheGetResponder,
4270    )> {
4271        if let PackageCacheRequest::Get {
4272            meta_far_blob,
4273            gc_protection,
4274            needed_blobs,
4275            dir,
4276            responder,
4277        } = self
4278        {
4279            Some((meta_far_blob, gc_protection, needed_blobs, dir, responder))
4280        } else {
4281            None
4282        }
4283    }
4284
4285    #[allow(irrefutable_let_patterns)]
4286    pub fn into_get_subpackage(
4287        self,
4288    ) -> Option<(
4289        BlobId,
4290        PackageUrl,
4291        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
4292        PackageCacheGetSubpackageResponder,
4293    )> {
4294        if let PackageCacheRequest::GetSubpackage { superpackage, subpackage, dir, responder } =
4295            self
4296        {
4297            Some((superpackage, subpackage, dir, responder))
4298        } else {
4299            None
4300        }
4301    }
4302
4303    #[allow(irrefutable_let_patterns)]
4304    pub fn into_base_package_index(
4305        self,
4306    ) -> Option<(fidl::endpoints::ServerEnd<PackageIndexIteratorMarker>, PackageCacheControlHandle)>
4307    {
4308        if let PackageCacheRequest::BasePackageIndex { iterator, control_handle } = self {
4309            Some((iterator, control_handle))
4310        } else {
4311            None
4312        }
4313    }
4314
4315    #[allow(irrefutable_let_patterns)]
4316    pub fn into_cache_package_index(
4317        self,
4318    ) -> Option<(fidl::endpoints::ServerEnd<PackageIndexIteratorMarker>, PackageCacheControlHandle)>
4319    {
4320        if let PackageCacheRequest::CachePackageIndex { iterator, control_handle } = self {
4321            Some((iterator, control_handle))
4322        } else {
4323            None
4324        }
4325    }
4326
4327    #[allow(irrefutable_let_patterns)]
4328    pub fn into_sync(self) -> Option<(PackageCacheSyncResponder)> {
4329        if let PackageCacheRequest::Sync { responder } = self {
4330            Some((responder))
4331        } else {
4332            None
4333        }
4334    }
4335
4336    #[allow(irrefutable_let_patterns)]
4337    pub fn into_set_upgradable_urls(
4338        self,
4339    ) -> Option<(Vec<PackageUrl>, PackageCacheSetUpgradableUrlsResponder)> {
4340        if let PackageCacheRequest::SetUpgradableUrls { pinned_urls, responder } = self {
4341            Some((pinned_urls, responder))
4342        } else {
4343            None
4344        }
4345    }
4346
4347    /// Name of the method defined in FIDL
4348    pub fn method_name(&self) -> &'static str {
4349        match *self {
4350            PackageCacheRequest::Get { .. } => "get",
4351            PackageCacheRequest::GetSubpackage { .. } => "get_subpackage",
4352            PackageCacheRequest::BasePackageIndex { .. } => "base_package_index",
4353            PackageCacheRequest::CachePackageIndex { .. } => "cache_package_index",
4354            PackageCacheRequest::Sync { .. } => "sync",
4355            PackageCacheRequest::SetUpgradableUrls { .. } => "set_upgradable_urls",
4356            PackageCacheRequest::_UnknownMethod {
4357                method_type: fidl::MethodType::OneWay, ..
4358            } => "unknown one-way method",
4359            PackageCacheRequest::_UnknownMethod {
4360                method_type: fidl::MethodType::TwoWay, ..
4361            } => "unknown two-way method",
4362        }
4363    }
4364}
4365
4366#[derive(Debug, Clone)]
4367pub struct PackageCacheControlHandle {
4368    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4369}
4370
4371impl fidl::endpoints::ControlHandle for PackageCacheControlHandle {
4372    fn shutdown(&self) {
4373        self.inner.shutdown()
4374    }
4375    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4376        self.inner.shutdown_with_epitaph(status)
4377    }
4378
4379    fn is_closed(&self) -> bool {
4380        self.inner.channel().is_closed()
4381    }
4382    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4383        self.inner.channel().on_closed()
4384    }
4385
4386    #[cfg(target_os = "fuchsia")]
4387    fn signal_peer(
4388        &self,
4389        clear_mask: zx::Signals,
4390        set_mask: zx::Signals,
4391    ) -> Result<(), zx_status::Status> {
4392        use fidl::Peered;
4393        self.inner.channel().signal_peer(clear_mask, set_mask)
4394    }
4395}
4396
4397impl PackageCacheControlHandle {}
4398
4399#[must_use = "FIDL methods require a response to be sent"]
4400#[derive(Debug)]
4401pub struct PackageCacheGetResponder {
4402    control_handle: std::mem::ManuallyDrop<PackageCacheControlHandle>,
4403    tx_id: u32,
4404}
4405
4406/// Set the the channel to be shutdown (see [`PackageCacheControlHandle::shutdown`])
4407/// if the responder is dropped without sending a response, so that the client
4408/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4409impl std::ops::Drop for PackageCacheGetResponder {
4410    fn drop(&mut self) {
4411        self.control_handle.shutdown();
4412        // Safety: drops once, never accessed again
4413        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4414    }
4415}
4416
4417impl fidl::endpoints::Responder for PackageCacheGetResponder {
4418    type ControlHandle = PackageCacheControlHandle;
4419
4420    fn control_handle(&self) -> &PackageCacheControlHandle {
4421        &self.control_handle
4422    }
4423
4424    fn drop_without_shutdown(mut self) {
4425        // Safety: drops once, never accessed again due to mem::forget
4426        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4427        // Prevent Drop from running (which would shut down the channel)
4428        std::mem::forget(self);
4429    }
4430}
4431
4432impl PackageCacheGetResponder {
4433    /// Sends a response to the FIDL transaction.
4434    ///
4435    /// Sets the channel to shutdown if an error occurs.
4436    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4437        let _result = self.send_raw(result);
4438        if _result.is_err() {
4439            self.control_handle.shutdown();
4440        }
4441        self.drop_without_shutdown();
4442        _result
4443    }
4444
4445    /// Similar to "send" but does not shutdown the channel if an error occurs.
4446    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4447        let _result = self.send_raw(result);
4448        self.drop_without_shutdown();
4449        _result
4450    }
4451
4452    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4453        self.control_handle
4454            .inner
4455            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
4456                result,
4457                self.tx_id,
4458                0x15e1963f4bf123b5,
4459                fidl::encoding::DynamicFlags::empty(),
4460            )
4461    }
4462}
4463
4464#[must_use = "FIDL methods require a response to be sent"]
4465#[derive(Debug)]
4466pub struct PackageCacheGetSubpackageResponder {
4467    control_handle: std::mem::ManuallyDrop<PackageCacheControlHandle>,
4468    tx_id: u32,
4469}
4470
4471/// Set the the channel to be shutdown (see [`PackageCacheControlHandle::shutdown`])
4472/// if the responder is dropped without sending a response, so that the client
4473/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4474impl std::ops::Drop for PackageCacheGetSubpackageResponder {
4475    fn drop(&mut self) {
4476        self.control_handle.shutdown();
4477        // Safety: drops once, never accessed again
4478        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4479    }
4480}
4481
4482impl fidl::endpoints::Responder for PackageCacheGetSubpackageResponder {
4483    type ControlHandle = PackageCacheControlHandle;
4484
4485    fn control_handle(&self) -> &PackageCacheControlHandle {
4486        &self.control_handle
4487    }
4488
4489    fn drop_without_shutdown(mut self) {
4490        // Safety: drops once, never accessed again due to mem::forget
4491        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4492        // Prevent Drop from running (which would shut down the channel)
4493        std::mem::forget(self);
4494    }
4495}
4496
4497impl PackageCacheGetSubpackageResponder {
4498    /// Sends a response to the FIDL transaction.
4499    ///
4500    /// Sets the channel to shutdown if an error occurs.
4501    pub fn send(self, mut result: Result<(), GetSubpackageError>) -> Result<(), fidl::Error> {
4502        let _result = self.send_raw(result);
4503        if _result.is_err() {
4504            self.control_handle.shutdown();
4505        }
4506        self.drop_without_shutdown();
4507        _result
4508    }
4509
4510    /// Similar to "send" but does not shutdown the channel if an error occurs.
4511    pub fn send_no_shutdown_on_err(
4512        self,
4513        mut result: Result<(), GetSubpackageError>,
4514    ) -> Result<(), fidl::Error> {
4515        let _result = self.send_raw(result);
4516        self.drop_without_shutdown();
4517        _result
4518    }
4519
4520    fn send_raw(&self, mut result: Result<(), GetSubpackageError>) -> Result<(), fidl::Error> {
4521        self.control_handle.inner.send::<fidl::encoding::ResultType<
4522            fidl::encoding::EmptyStruct,
4523            GetSubpackageError,
4524        >>(
4525            result,
4526            self.tx_id,
4527            0x29478df87c29ffa3,
4528            fidl::encoding::DynamicFlags::empty(),
4529        )
4530    }
4531}
4532
4533#[must_use = "FIDL methods require a response to be sent"]
4534#[derive(Debug)]
4535pub struct PackageCacheSyncResponder {
4536    control_handle: std::mem::ManuallyDrop<PackageCacheControlHandle>,
4537    tx_id: u32,
4538}
4539
4540/// Set the the channel to be shutdown (see [`PackageCacheControlHandle::shutdown`])
4541/// if the responder is dropped without sending a response, so that the client
4542/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4543impl std::ops::Drop for PackageCacheSyncResponder {
4544    fn drop(&mut self) {
4545        self.control_handle.shutdown();
4546        // Safety: drops once, never accessed again
4547        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4548    }
4549}
4550
4551impl fidl::endpoints::Responder for PackageCacheSyncResponder {
4552    type ControlHandle = PackageCacheControlHandle;
4553
4554    fn control_handle(&self) -> &PackageCacheControlHandle {
4555        &self.control_handle
4556    }
4557
4558    fn drop_without_shutdown(mut self) {
4559        // Safety: drops once, never accessed again due to mem::forget
4560        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4561        // Prevent Drop from running (which would shut down the channel)
4562        std::mem::forget(self);
4563    }
4564}
4565
4566impl PackageCacheSyncResponder {
4567    /// Sends a response to the FIDL transaction.
4568    ///
4569    /// Sets the channel to shutdown if an error occurs.
4570    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4571        let _result = self.send_raw(result);
4572        if _result.is_err() {
4573            self.control_handle.shutdown();
4574        }
4575        self.drop_without_shutdown();
4576        _result
4577    }
4578
4579    /// Similar to "send" but does not shutdown the channel if an error occurs.
4580    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4581        let _result = self.send_raw(result);
4582        self.drop_without_shutdown();
4583        _result
4584    }
4585
4586    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4587        self.control_handle
4588            .inner
4589            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
4590                result,
4591                self.tx_id,
4592                0x5c10a84094535a74,
4593                fidl::encoding::DynamicFlags::empty(),
4594            )
4595    }
4596}
4597
4598#[must_use = "FIDL methods require a response to be sent"]
4599#[derive(Debug)]
4600pub struct PackageCacheSetUpgradableUrlsResponder {
4601    control_handle: std::mem::ManuallyDrop<PackageCacheControlHandle>,
4602    tx_id: u32,
4603}
4604
4605/// Set the the channel to be shutdown (see [`PackageCacheControlHandle::shutdown`])
4606/// if the responder is dropped without sending a response, so that the client
4607/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4608impl std::ops::Drop for PackageCacheSetUpgradableUrlsResponder {
4609    fn drop(&mut self) {
4610        self.control_handle.shutdown();
4611        // Safety: drops once, never accessed again
4612        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4613    }
4614}
4615
4616impl fidl::endpoints::Responder for PackageCacheSetUpgradableUrlsResponder {
4617    type ControlHandle = PackageCacheControlHandle;
4618
4619    fn control_handle(&self) -> &PackageCacheControlHandle {
4620        &self.control_handle
4621    }
4622
4623    fn drop_without_shutdown(mut self) {
4624        // Safety: drops once, never accessed again due to mem::forget
4625        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4626        // Prevent Drop from running (which would shut down the channel)
4627        std::mem::forget(self);
4628    }
4629}
4630
4631impl PackageCacheSetUpgradableUrlsResponder {
4632    /// Sends a response to the FIDL transaction.
4633    ///
4634    /// Sets the channel to shutdown if an error occurs.
4635    pub fn send(self, mut result: Result<(), SetUpgradableUrlsError>) -> Result<(), fidl::Error> {
4636        let _result = self.send_raw(result);
4637        if _result.is_err() {
4638            self.control_handle.shutdown();
4639        }
4640        self.drop_without_shutdown();
4641        _result
4642    }
4643
4644    /// Similar to "send" but does not shutdown the channel if an error occurs.
4645    pub fn send_no_shutdown_on_err(
4646        self,
4647        mut result: Result<(), SetUpgradableUrlsError>,
4648    ) -> Result<(), fidl::Error> {
4649        let _result = self.send_raw(result);
4650        self.drop_without_shutdown();
4651        _result
4652    }
4653
4654    fn send_raw(&self, mut result: Result<(), SetUpgradableUrlsError>) -> Result<(), fidl::Error> {
4655        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
4656            fidl::encoding::EmptyStruct,
4657            SetUpgradableUrlsError,
4658        >>(
4659            fidl::encoding::FlexibleResult::new(result),
4660            self.tx_id,
4661            0x2c235f7efdb5e2d1,
4662            fidl::encoding::DynamicFlags::FLEXIBLE,
4663        )
4664    }
4665}
4666
4667#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4668pub struct PackageIndexIteratorMarker;
4669
4670impl fidl::endpoints::ProtocolMarker for PackageIndexIteratorMarker {
4671    type Proxy = PackageIndexIteratorProxy;
4672    type RequestStream = PackageIndexIteratorRequestStream;
4673    #[cfg(target_os = "fuchsia")]
4674    type SynchronousProxy = PackageIndexIteratorSynchronousProxy;
4675
4676    const DEBUG_NAME: &'static str = "(anonymous) PackageIndexIterator";
4677}
4678
4679pub trait PackageIndexIteratorProxyInterface: Send + Sync {
4680    type NextResponseFut: std::future::Future<Output = Result<Vec<PackageIndexEntry>, fidl::Error>>
4681        + Send;
4682    fn r#next(&self) -> Self::NextResponseFut;
4683}
4684#[derive(Debug)]
4685#[cfg(target_os = "fuchsia")]
4686pub struct PackageIndexIteratorSynchronousProxy {
4687    client: fidl::client::sync::Client,
4688}
4689
4690#[cfg(target_os = "fuchsia")]
4691impl fidl::endpoints::SynchronousProxy for PackageIndexIteratorSynchronousProxy {
4692    type Proxy = PackageIndexIteratorProxy;
4693    type Protocol = PackageIndexIteratorMarker;
4694
4695    fn from_channel(inner: fidl::Channel) -> Self {
4696        Self::new(inner)
4697    }
4698
4699    fn into_channel(self) -> fidl::Channel {
4700        self.client.into_channel()
4701    }
4702
4703    fn as_channel(&self) -> &fidl::Channel {
4704        self.client.as_channel()
4705    }
4706}
4707
4708#[cfg(target_os = "fuchsia")]
4709impl PackageIndexIteratorSynchronousProxy {
4710    pub fn new(channel: fidl::Channel) -> Self {
4711        let protocol_name =
4712            <PackageIndexIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4713        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
4714    }
4715
4716    pub fn into_channel(self) -> fidl::Channel {
4717        self.client.into_channel()
4718    }
4719
4720    /// Waits until an event arrives and returns it. It is safe for other
4721    /// threads to make concurrent requests while waiting for an event.
4722    pub fn wait_for_event(
4723        &self,
4724        deadline: zx::MonotonicInstant,
4725    ) -> Result<PackageIndexIteratorEvent, fidl::Error> {
4726        PackageIndexIteratorEvent::decode(self.client.wait_for_event(deadline)?)
4727    }
4728
4729    /// Returns the next chunk of package index entries. When the iterator is exhausted,
4730    /// this returns an empty vector.
4731    ///
4732    /// - response `entries` the next chunk of entries in the package index.
4733    pub fn r#next(
4734        &self,
4735        ___deadline: zx::MonotonicInstant,
4736    ) -> Result<Vec<PackageIndexEntry>, fidl::Error> {
4737        let _response = self
4738            .client
4739            .send_query::<fidl::encoding::EmptyPayload, PackageIndexIteratorNextResponse>(
4740                (),
4741                0x9de6bbc87c314d9,
4742                fidl::encoding::DynamicFlags::empty(),
4743                ___deadline,
4744            )?;
4745        Ok(_response.entries)
4746    }
4747}
4748
4749#[cfg(target_os = "fuchsia")]
4750impl From<PackageIndexIteratorSynchronousProxy> for zx::Handle {
4751    fn from(value: PackageIndexIteratorSynchronousProxy) -> Self {
4752        value.into_channel().into()
4753    }
4754}
4755
4756#[cfg(target_os = "fuchsia")]
4757impl From<fidl::Channel> for PackageIndexIteratorSynchronousProxy {
4758    fn from(value: fidl::Channel) -> Self {
4759        Self::new(value)
4760    }
4761}
4762
4763#[derive(Debug, Clone)]
4764pub struct PackageIndexIteratorProxy {
4765    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4766}
4767
4768impl fidl::endpoints::Proxy for PackageIndexIteratorProxy {
4769    type Protocol = PackageIndexIteratorMarker;
4770
4771    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4772        Self::new(inner)
4773    }
4774
4775    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4776        self.client.into_channel().map_err(|client| Self { client })
4777    }
4778
4779    fn as_channel(&self) -> &::fidl::AsyncChannel {
4780        self.client.as_channel()
4781    }
4782}
4783
4784impl PackageIndexIteratorProxy {
4785    /// Create a new Proxy for fuchsia.pkg/PackageIndexIterator.
4786    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4787        let protocol_name =
4788            <PackageIndexIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4789        Self { client: fidl::client::Client::new(channel, protocol_name) }
4790    }
4791
4792    /// Get a Stream of events from the remote end of the protocol.
4793    ///
4794    /// # Panics
4795    ///
4796    /// Panics if the event stream was already taken.
4797    pub fn take_event_stream(&self) -> PackageIndexIteratorEventStream {
4798        PackageIndexIteratorEventStream { event_receiver: self.client.take_event_receiver() }
4799    }
4800
4801    /// Returns the next chunk of package index entries. When the iterator is exhausted,
4802    /// this returns an empty vector.
4803    ///
4804    /// - response `entries` the next chunk of entries in the package index.
4805    pub fn r#next(
4806        &self,
4807    ) -> fidl::client::QueryResponseFut<
4808        Vec<PackageIndexEntry>,
4809        fidl::encoding::DefaultFuchsiaResourceDialect,
4810    > {
4811        PackageIndexIteratorProxyInterface::r#next(self)
4812    }
4813}
4814
4815impl PackageIndexIteratorProxyInterface for PackageIndexIteratorProxy {
4816    type NextResponseFut = fidl::client::QueryResponseFut<
4817        Vec<PackageIndexEntry>,
4818        fidl::encoding::DefaultFuchsiaResourceDialect,
4819    >;
4820    fn r#next(&self) -> Self::NextResponseFut {
4821        fn _decode(
4822            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4823        ) -> Result<Vec<PackageIndexEntry>, fidl::Error> {
4824            let _response = fidl::client::decode_transaction_body::<
4825                PackageIndexIteratorNextResponse,
4826                fidl::encoding::DefaultFuchsiaResourceDialect,
4827                0x9de6bbc87c314d9,
4828            >(_buf?)?;
4829            Ok(_response.entries)
4830        }
4831        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<PackageIndexEntry>>(
4832            (),
4833            0x9de6bbc87c314d9,
4834            fidl::encoding::DynamicFlags::empty(),
4835            _decode,
4836        )
4837    }
4838}
4839
4840pub struct PackageIndexIteratorEventStream {
4841    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4842}
4843
4844impl std::marker::Unpin for PackageIndexIteratorEventStream {}
4845
4846impl futures::stream::FusedStream for PackageIndexIteratorEventStream {
4847    fn is_terminated(&self) -> bool {
4848        self.event_receiver.is_terminated()
4849    }
4850}
4851
4852impl futures::Stream for PackageIndexIteratorEventStream {
4853    type Item = Result<PackageIndexIteratorEvent, fidl::Error>;
4854
4855    fn poll_next(
4856        mut self: std::pin::Pin<&mut Self>,
4857        cx: &mut std::task::Context<'_>,
4858    ) -> std::task::Poll<Option<Self::Item>> {
4859        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4860            &mut self.event_receiver,
4861            cx
4862        )?) {
4863            Some(buf) => std::task::Poll::Ready(Some(PackageIndexIteratorEvent::decode(buf))),
4864            None => std::task::Poll::Ready(None),
4865        }
4866    }
4867}
4868
4869#[derive(Debug)]
4870pub enum PackageIndexIteratorEvent {}
4871
4872impl PackageIndexIteratorEvent {
4873    /// Decodes a message buffer as a [`PackageIndexIteratorEvent`].
4874    fn decode(
4875        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4876    ) -> Result<PackageIndexIteratorEvent, fidl::Error> {
4877        let (bytes, _handles) = buf.split_mut();
4878        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4879        debug_assert_eq!(tx_header.tx_id, 0);
4880        match tx_header.ordinal {
4881            _ => Err(fidl::Error::UnknownOrdinal {
4882                ordinal: tx_header.ordinal,
4883                protocol_name:
4884                    <PackageIndexIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4885            }),
4886        }
4887    }
4888}
4889
4890/// A Stream of incoming requests for fuchsia.pkg/PackageIndexIterator.
4891pub struct PackageIndexIteratorRequestStream {
4892    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4893    is_terminated: bool,
4894}
4895
4896impl std::marker::Unpin for PackageIndexIteratorRequestStream {}
4897
4898impl futures::stream::FusedStream for PackageIndexIteratorRequestStream {
4899    fn is_terminated(&self) -> bool {
4900        self.is_terminated
4901    }
4902}
4903
4904impl fidl::endpoints::RequestStream for PackageIndexIteratorRequestStream {
4905    type Protocol = PackageIndexIteratorMarker;
4906    type ControlHandle = PackageIndexIteratorControlHandle;
4907
4908    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4909        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4910    }
4911
4912    fn control_handle(&self) -> Self::ControlHandle {
4913        PackageIndexIteratorControlHandle { inner: self.inner.clone() }
4914    }
4915
4916    fn into_inner(
4917        self,
4918    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4919    {
4920        (self.inner, self.is_terminated)
4921    }
4922
4923    fn from_inner(
4924        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4925        is_terminated: bool,
4926    ) -> Self {
4927        Self { inner, is_terminated }
4928    }
4929}
4930
4931impl futures::Stream for PackageIndexIteratorRequestStream {
4932    type Item = Result<PackageIndexIteratorRequest, fidl::Error>;
4933
4934    fn poll_next(
4935        mut self: std::pin::Pin<&mut Self>,
4936        cx: &mut std::task::Context<'_>,
4937    ) -> std::task::Poll<Option<Self::Item>> {
4938        let this = &mut *self;
4939        if this.inner.check_shutdown(cx) {
4940            this.is_terminated = true;
4941            return std::task::Poll::Ready(None);
4942        }
4943        if this.is_terminated {
4944            panic!("polled PackageIndexIteratorRequestStream after completion");
4945        }
4946        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4947            |bytes, handles| {
4948                match this.inner.channel().read_etc(cx, bytes, handles) {
4949                    std::task::Poll::Ready(Ok(())) => {}
4950                    std::task::Poll::Pending => return std::task::Poll::Pending,
4951                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4952                        this.is_terminated = true;
4953                        return std::task::Poll::Ready(None);
4954                    }
4955                    std::task::Poll::Ready(Err(e)) => {
4956                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4957                            e.into(),
4958                        ))))
4959                    }
4960                }
4961
4962                // A message has been received from the channel
4963                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4964
4965                std::task::Poll::Ready(Some(match header.ordinal {
4966                0x9de6bbc87c314d9 => {
4967                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4968                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
4969                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4970                    let control_handle = PackageIndexIteratorControlHandle {
4971                        inner: this.inner.clone(),
4972                    };
4973                    Ok(PackageIndexIteratorRequest::Next {
4974                        responder: PackageIndexIteratorNextResponder {
4975                            control_handle: std::mem::ManuallyDrop::new(control_handle),
4976                            tx_id: header.tx_id,
4977                        },
4978                    })
4979                }
4980                _ => Err(fidl::Error::UnknownOrdinal {
4981                    ordinal: header.ordinal,
4982                    protocol_name: <PackageIndexIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4983                }),
4984            }))
4985            },
4986        )
4987    }
4988}
4989
4990/// A chunk iterator for the package index. This is required because it is possible for the
4991/// package index to be too large to send over in a single request (over 64KiB).
4992#[derive(Debug)]
4993pub enum PackageIndexIteratorRequest {
4994    /// Returns the next chunk of package index entries. When the iterator is exhausted,
4995    /// this returns an empty vector.
4996    ///
4997    /// - response `entries` the next chunk of entries in the package index.
4998    Next { responder: PackageIndexIteratorNextResponder },
4999}
5000
5001impl PackageIndexIteratorRequest {
5002    #[allow(irrefutable_let_patterns)]
5003    pub fn into_next(self) -> Option<(PackageIndexIteratorNextResponder)> {
5004        if let PackageIndexIteratorRequest::Next { responder } = self {
5005            Some((responder))
5006        } else {
5007            None
5008        }
5009    }
5010
5011    /// Name of the method defined in FIDL
5012    pub fn method_name(&self) -> &'static str {
5013        match *self {
5014            PackageIndexIteratorRequest::Next { .. } => "next",
5015        }
5016    }
5017}
5018
5019#[derive(Debug, Clone)]
5020pub struct PackageIndexIteratorControlHandle {
5021    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5022}
5023
5024impl fidl::endpoints::ControlHandle for PackageIndexIteratorControlHandle {
5025    fn shutdown(&self) {
5026        self.inner.shutdown()
5027    }
5028    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5029        self.inner.shutdown_with_epitaph(status)
5030    }
5031
5032    fn is_closed(&self) -> bool {
5033        self.inner.channel().is_closed()
5034    }
5035    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5036        self.inner.channel().on_closed()
5037    }
5038
5039    #[cfg(target_os = "fuchsia")]
5040    fn signal_peer(
5041        &self,
5042        clear_mask: zx::Signals,
5043        set_mask: zx::Signals,
5044    ) -> Result<(), zx_status::Status> {
5045        use fidl::Peered;
5046        self.inner.channel().signal_peer(clear_mask, set_mask)
5047    }
5048}
5049
5050impl PackageIndexIteratorControlHandle {}
5051
5052#[must_use = "FIDL methods require a response to be sent"]
5053#[derive(Debug)]
5054pub struct PackageIndexIteratorNextResponder {
5055    control_handle: std::mem::ManuallyDrop<PackageIndexIteratorControlHandle>,
5056    tx_id: u32,
5057}
5058
5059/// Set the the channel to be shutdown (see [`PackageIndexIteratorControlHandle::shutdown`])
5060/// if the responder is dropped without sending a response, so that the client
5061/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5062impl std::ops::Drop for PackageIndexIteratorNextResponder {
5063    fn drop(&mut self) {
5064        self.control_handle.shutdown();
5065        // Safety: drops once, never accessed again
5066        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5067    }
5068}
5069
5070impl fidl::endpoints::Responder for PackageIndexIteratorNextResponder {
5071    type ControlHandle = PackageIndexIteratorControlHandle;
5072
5073    fn control_handle(&self) -> &PackageIndexIteratorControlHandle {
5074        &self.control_handle
5075    }
5076
5077    fn drop_without_shutdown(mut self) {
5078        // Safety: drops once, never accessed again due to mem::forget
5079        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5080        // Prevent Drop from running (which would shut down the channel)
5081        std::mem::forget(self);
5082    }
5083}
5084
5085impl PackageIndexIteratorNextResponder {
5086    /// Sends a response to the FIDL transaction.
5087    ///
5088    /// Sets the channel to shutdown if an error occurs.
5089    pub fn send(self, mut entries: &[PackageIndexEntry]) -> Result<(), fidl::Error> {
5090        let _result = self.send_raw(entries);
5091        if _result.is_err() {
5092            self.control_handle.shutdown();
5093        }
5094        self.drop_without_shutdown();
5095        _result
5096    }
5097
5098    /// Similar to "send" but does not shutdown the channel if an error occurs.
5099    pub fn send_no_shutdown_on_err(
5100        self,
5101        mut entries: &[PackageIndexEntry],
5102    ) -> Result<(), fidl::Error> {
5103        let _result = self.send_raw(entries);
5104        self.drop_without_shutdown();
5105        _result
5106    }
5107
5108    fn send_raw(&self, mut entries: &[PackageIndexEntry]) -> Result<(), fidl::Error> {
5109        self.control_handle.inner.send::<PackageIndexIteratorNextResponse>(
5110            (entries,),
5111            self.tx_id,
5112            0x9de6bbc87c314d9,
5113            fidl::encoding::DynamicFlags::empty(),
5114        )
5115    }
5116}
5117
5118#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5119pub struct PackageResolverMarker;
5120
5121impl fidl::endpoints::ProtocolMarker for PackageResolverMarker {
5122    type Proxy = PackageResolverProxy;
5123    type RequestStream = PackageResolverRequestStream;
5124    #[cfg(target_os = "fuchsia")]
5125    type SynchronousProxy = PackageResolverSynchronousProxy;
5126
5127    const DEBUG_NAME: &'static str = "fuchsia.pkg.PackageResolver";
5128}
5129impl fidl::endpoints::DiscoverableProtocolMarker for PackageResolverMarker {}
5130pub type PackageResolverResolveResult = Result<ResolutionContext, ResolveError>;
5131pub type PackageResolverResolveWithContextResult = Result<ResolutionContext, ResolveError>;
5132pub type PackageResolverGetHashResult = Result<BlobId, i32>;
5133
5134pub trait PackageResolverProxyInterface: Send + Sync {
5135    type ResolveResponseFut: std::future::Future<Output = Result<PackageResolverResolveResult, fidl::Error>>
5136        + Send;
5137    fn r#resolve(
5138        &self,
5139        package_url: &str,
5140        dir: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
5141    ) -> Self::ResolveResponseFut;
5142    type ResolveWithContextResponseFut: std::future::Future<Output = Result<PackageResolverResolveWithContextResult, fidl::Error>>
5143        + Send;
5144    fn r#resolve_with_context(
5145        &self,
5146        package_url: &str,
5147        context: &ResolutionContext,
5148        dir: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
5149    ) -> Self::ResolveWithContextResponseFut;
5150    type GetHashResponseFut: std::future::Future<Output = Result<PackageResolverGetHashResult, fidl::Error>>
5151        + Send;
5152    fn r#get_hash(&self, package_url: &PackageUrl) -> Self::GetHashResponseFut;
5153}
5154#[derive(Debug)]
5155#[cfg(target_os = "fuchsia")]
5156pub struct PackageResolverSynchronousProxy {
5157    client: fidl::client::sync::Client,
5158}
5159
5160#[cfg(target_os = "fuchsia")]
5161impl fidl::endpoints::SynchronousProxy for PackageResolverSynchronousProxy {
5162    type Proxy = PackageResolverProxy;
5163    type Protocol = PackageResolverMarker;
5164
5165    fn from_channel(inner: fidl::Channel) -> Self {
5166        Self::new(inner)
5167    }
5168
5169    fn into_channel(self) -> fidl::Channel {
5170        self.client.into_channel()
5171    }
5172
5173    fn as_channel(&self) -> &fidl::Channel {
5174        self.client.as_channel()
5175    }
5176}
5177
5178#[cfg(target_os = "fuchsia")]
5179impl PackageResolverSynchronousProxy {
5180    pub fn new(channel: fidl::Channel) -> Self {
5181        let protocol_name = <PackageResolverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5182        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
5183    }
5184
5185    pub fn into_channel(self) -> fidl::Channel {
5186        self.client.into_channel()
5187    }
5188
5189    /// Waits until an event arrives and returns it. It is safe for other
5190    /// threads to make concurrent requests while waiting for an event.
5191    pub fn wait_for_event(
5192        &self,
5193        deadline: zx::MonotonicInstant,
5194    ) -> Result<PackageResolverEvent, fidl::Error> {
5195        PackageResolverEvent::decode(self.client.wait_for_event(deadline)?)
5196    }
5197
5198    /// Populates or updates the cache of a package using an absolute package
5199    /// URL.
5200    ///
5201    /// Ensures that a package, and any transitive subpackages, are on the local
5202    /// filesystem.
5203    ///
5204    /// + request `package_url` the absolute package URL for a package.  The
5205    ///   following link describes the format:
5206    ///   https://fuchsia.dev/fuchsia-src/concepts/packages/package_url.
5207    ///   Resource paths are not allowed.
5208    /// + request `dir` a request for a directory that will be resolved when the
5209    ///   package has been successfully cached.
5210    /// + returns a `resolved_context`, which can be passed to
5211    ///   `ResolveWithContext`, with a relative URL, to resolve a subpackage of
5212    ///   this package.
5213    /// * error indicates failure. See `ResolveError` for values and error
5214    ///   scenarios.
5215    pub fn r#resolve(
5216        &self,
5217        mut package_url: &str,
5218        mut dir: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
5219        ___deadline: zx::MonotonicInstant,
5220    ) -> Result<PackageResolverResolveResult, fidl::Error> {
5221        let _response = self.client.send_query::<
5222            PackageResolverResolveRequest,
5223            fidl::encoding::ResultType<PackageResolverResolveResponse, ResolveError>,
5224        >(
5225            (package_url, dir,),
5226            0x6611263be4052d4f,
5227            fidl::encoding::DynamicFlags::empty(),
5228            ___deadline,
5229        )?;
5230        Ok(_response.map(|x| x.resolved_context))
5231    }
5232
5233    /// Populates or updates the cache of a package using either an absolute or
5234    /// a relative package URL. If relative, the package will be resolved
5235    /// relative to the supplied `context`.
5236    ///
5237    /// Ensures that a package is on the local filesystem.
5238    ///
5239    /// + request `package_url` the absolute or relative package URL for a
5240    ///   package. If absolute, the `context` is ignored, and the behavior is
5241    ///   identical to calling `Resolve()`. A relative `package_url` is a
5242    ///   subpackage name.
5243    /// + request `context` a `ResolutionContext` associated with a previously
5244    ///   resolved package, for resolving subpackages relative to that package.
5245    /// + request `dir` a request for a directory that will be resolved when the
5246    ///   package has been successfully cached.
5247    /// + returns a `resolved_context`, which can be passed to a subsequent call
5248    ///   to `ResolveWithContext`, with a relative URL, to resolve a subpackage
5249    ///   of this package or subpackage.
5250    /// * error indicates failure. See `ResolveError` for values and error
5251    ///   scenarios.
5252    pub fn r#resolve_with_context(
5253        &self,
5254        mut package_url: &str,
5255        mut context: &ResolutionContext,
5256        mut dir: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
5257        ___deadline: zx::MonotonicInstant,
5258    ) -> Result<PackageResolverResolveWithContextResult, fidl::Error> {
5259        let _response =
5260            self.client
5261                .send_query::<PackageResolverResolveWithContextRequest, fidl::encoding::ResultType<
5262                    PackageResolverResolveWithContextResponse,
5263                    ResolveError,
5264                >>(
5265                    (package_url, context, dir),
5266                    0x4c255ae7260298d4,
5267                    fidl::encoding::DynamicFlags::empty(),
5268                    ___deadline,
5269                )?;
5270        Ok(_response.map(|x| x.resolved_context))
5271    }
5272
5273    /// Determines the hash of a package.
5274    ///
5275    /// + request `package_url` the package URL for a package.
5276    /// - response `meta_far_blob_id` the hash of the package.
5277    /// * error a zx_status value indicating failure. One of the following:
5278    ///     * `ZX_ERR_INTERNAL` if the resolver encountered an otherwise unspecified error
5279    ///       while handling the request.
5280    ///     * `ZX_ERR_NOT_FOUND` if the package does not exist in the repository specified by
5281    ///       `package_url`.
5282    ///     * `ZX_ERR_BAD_STATE` if the resolver does not know about the repository specified by
5283    ///       `package_url`.
5284    pub fn r#get_hash(
5285        &self,
5286        mut package_url: &PackageUrl,
5287        ___deadline: zx::MonotonicInstant,
5288    ) -> Result<PackageResolverGetHashResult, fidl::Error> {
5289        let _response = self.client.send_query::<
5290            PackageResolverGetHashRequest,
5291            fidl::encoding::ResultType<PackageResolverGetHashResponse, i32>,
5292        >(
5293            (package_url,),
5294            0x594e8b4db51efd87,
5295            fidl::encoding::DynamicFlags::empty(),
5296            ___deadline,
5297        )?;
5298        Ok(_response.map(|x| x.meta_far_blob_id))
5299    }
5300}
5301
5302#[cfg(target_os = "fuchsia")]
5303impl From<PackageResolverSynchronousProxy> for zx::Handle {
5304    fn from(value: PackageResolverSynchronousProxy) -> Self {
5305        value.into_channel().into()
5306    }
5307}
5308
5309#[cfg(target_os = "fuchsia")]
5310impl From<fidl::Channel> for PackageResolverSynchronousProxy {
5311    fn from(value: fidl::Channel) -> Self {
5312        Self::new(value)
5313    }
5314}
5315
5316#[derive(Debug, Clone)]
5317pub struct PackageResolverProxy {
5318    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5319}
5320
5321impl fidl::endpoints::Proxy for PackageResolverProxy {
5322    type Protocol = PackageResolverMarker;
5323
5324    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5325        Self::new(inner)
5326    }
5327
5328    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5329        self.client.into_channel().map_err(|client| Self { client })
5330    }
5331
5332    fn as_channel(&self) -> &::fidl::AsyncChannel {
5333        self.client.as_channel()
5334    }
5335}
5336
5337impl PackageResolverProxy {
5338    /// Create a new Proxy for fuchsia.pkg/PackageResolver.
5339    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5340        let protocol_name = <PackageResolverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5341        Self { client: fidl::client::Client::new(channel, protocol_name) }
5342    }
5343
5344    /// Get a Stream of events from the remote end of the protocol.
5345    ///
5346    /// # Panics
5347    ///
5348    /// Panics if the event stream was already taken.
5349    pub fn take_event_stream(&self) -> PackageResolverEventStream {
5350        PackageResolverEventStream { event_receiver: self.client.take_event_receiver() }
5351    }
5352
5353    /// Populates or updates the cache of a package using an absolute package
5354    /// URL.
5355    ///
5356    /// Ensures that a package, and any transitive subpackages, are on the local
5357    /// filesystem.
5358    ///
5359    /// + request `package_url` the absolute package URL for a package.  The
5360    ///   following link describes the format:
5361    ///   https://fuchsia.dev/fuchsia-src/concepts/packages/package_url.
5362    ///   Resource paths are not allowed.
5363    /// + request `dir` a request for a directory that will be resolved when the
5364    ///   package has been successfully cached.
5365    /// + returns a `resolved_context`, which can be passed to
5366    ///   `ResolveWithContext`, with a relative URL, to resolve a subpackage of
5367    ///   this package.
5368    /// * error indicates failure. See `ResolveError` for values and error
5369    ///   scenarios.
5370    pub fn r#resolve(
5371        &self,
5372        mut package_url: &str,
5373        mut dir: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
5374    ) -> fidl::client::QueryResponseFut<
5375        PackageResolverResolveResult,
5376        fidl::encoding::DefaultFuchsiaResourceDialect,
5377    > {
5378        PackageResolverProxyInterface::r#resolve(self, package_url, dir)
5379    }
5380
5381    /// Populates or updates the cache of a package using either an absolute or
5382    /// a relative package URL. If relative, the package will be resolved
5383    /// relative to the supplied `context`.
5384    ///
5385    /// Ensures that a package is on the local filesystem.
5386    ///
5387    /// + request `package_url` the absolute or relative package URL for a
5388    ///   package. If absolute, the `context` is ignored, and the behavior is
5389    ///   identical to calling `Resolve()`. A relative `package_url` is a
5390    ///   subpackage name.
5391    /// + request `context` a `ResolutionContext` associated with a previously
5392    ///   resolved package, for resolving subpackages relative to that package.
5393    /// + request `dir` a request for a directory that will be resolved when the
5394    ///   package has been successfully cached.
5395    /// + returns a `resolved_context`, which can be passed to a subsequent call
5396    ///   to `ResolveWithContext`, with a relative URL, to resolve a subpackage
5397    ///   of this package or subpackage.
5398    /// * error indicates failure. See `ResolveError` for values and error
5399    ///   scenarios.
5400    pub fn r#resolve_with_context(
5401        &self,
5402        mut package_url: &str,
5403        mut context: &ResolutionContext,
5404        mut dir: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
5405    ) -> fidl::client::QueryResponseFut<
5406        PackageResolverResolveWithContextResult,
5407        fidl::encoding::DefaultFuchsiaResourceDialect,
5408    > {
5409        PackageResolverProxyInterface::r#resolve_with_context(self, package_url, context, dir)
5410    }
5411
5412    /// Determines the hash of a package.
5413    ///
5414    /// + request `package_url` the package URL for a package.
5415    /// - response `meta_far_blob_id` the hash of the package.
5416    /// * error a zx_status value indicating failure. One of the following:
5417    ///     * `ZX_ERR_INTERNAL` if the resolver encountered an otherwise unspecified error
5418    ///       while handling the request.
5419    ///     * `ZX_ERR_NOT_FOUND` if the package does not exist in the repository specified by
5420    ///       `package_url`.
5421    ///     * `ZX_ERR_BAD_STATE` if the resolver does not know about the repository specified by
5422    ///       `package_url`.
5423    pub fn r#get_hash(
5424        &self,
5425        mut package_url: &PackageUrl,
5426    ) -> fidl::client::QueryResponseFut<
5427        PackageResolverGetHashResult,
5428        fidl::encoding::DefaultFuchsiaResourceDialect,
5429    > {
5430        PackageResolverProxyInterface::r#get_hash(self, package_url)
5431    }
5432}
5433
5434impl PackageResolverProxyInterface for PackageResolverProxy {
5435    type ResolveResponseFut = fidl::client::QueryResponseFut<
5436        PackageResolverResolveResult,
5437        fidl::encoding::DefaultFuchsiaResourceDialect,
5438    >;
5439    fn r#resolve(
5440        &self,
5441        mut package_url: &str,
5442        mut dir: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
5443    ) -> Self::ResolveResponseFut {
5444        fn _decode(
5445            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5446        ) -> Result<PackageResolverResolveResult, fidl::Error> {
5447            let _response = fidl::client::decode_transaction_body::<
5448                fidl::encoding::ResultType<PackageResolverResolveResponse, ResolveError>,
5449                fidl::encoding::DefaultFuchsiaResourceDialect,
5450                0x6611263be4052d4f,
5451            >(_buf?)?;
5452            Ok(_response.map(|x| x.resolved_context))
5453        }
5454        self.client
5455            .send_query_and_decode::<PackageResolverResolveRequest, PackageResolverResolveResult>(
5456                (package_url, dir),
5457                0x6611263be4052d4f,
5458                fidl::encoding::DynamicFlags::empty(),
5459                _decode,
5460            )
5461    }
5462
5463    type ResolveWithContextResponseFut = fidl::client::QueryResponseFut<
5464        PackageResolverResolveWithContextResult,
5465        fidl::encoding::DefaultFuchsiaResourceDialect,
5466    >;
5467    fn r#resolve_with_context(
5468        &self,
5469        mut package_url: &str,
5470        mut context: &ResolutionContext,
5471        mut dir: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
5472    ) -> Self::ResolveWithContextResponseFut {
5473        fn _decode(
5474            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5475        ) -> Result<PackageResolverResolveWithContextResult, fidl::Error> {
5476            let _response = fidl::client::decode_transaction_body::<
5477                fidl::encoding::ResultType<PackageResolverResolveWithContextResponse, ResolveError>,
5478                fidl::encoding::DefaultFuchsiaResourceDialect,
5479                0x4c255ae7260298d4,
5480            >(_buf?)?;
5481            Ok(_response.map(|x| x.resolved_context))
5482        }
5483        self.client.send_query_and_decode::<
5484            PackageResolverResolveWithContextRequest,
5485            PackageResolverResolveWithContextResult,
5486        >(
5487            (package_url, context, dir,),
5488            0x4c255ae7260298d4,
5489            fidl::encoding::DynamicFlags::empty(),
5490            _decode,
5491        )
5492    }
5493
5494    type GetHashResponseFut = fidl::client::QueryResponseFut<
5495        PackageResolverGetHashResult,
5496        fidl::encoding::DefaultFuchsiaResourceDialect,
5497    >;
5498    fn r#get_hash(&self, mut package_url: &PackageUrl) -> Self::GetHashResponseFut {
5499        fn _decode(
5500            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5501        ) -> Result<PackageResolverGetHashResult, fidl::Error> {
5502            let _response = fidl::client::decode_transaction_body::<
5503                fidl::encoding::ResultType<PackageResolverGetHashResponse, i32>,
5504                fidl::encoding::DefaultFuchsiaResourceDialect,
5505                0x594e8b4db51efd87,
5506            >(_buf?)?;
5507            Ok(_response.map(|x| x.meta_far_blob_id))
5508        }
5509        self.client
5510            .send_query_and_decode::<PackageResolverGetHashRequest, PackageResolverGetHashResult>(
5511                (package_url,),
5512                0x594e8b4db51efd87,
5513                fidl::encoding::DynamicFlags::empty(),
5514                _decode,
5515            )
5516    }
5517}
5518
5519pub struct PackageResolverEventStream {
5520    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5521}
5522
5523impl std::marker::Unpin for PackageResolverEventStream {}
5524
5525impl futures::stream::FusedStream for PackageResolverEventStream {
5526    fn is_terminated(&self) -> bool {
5527        self.event_receiver.is_terminated()
5528    }
5529}
5530
5531impl futures::Stream for PackageResolverEventStream {
5532    type Item = Result<PackageResolverEvent, fidl::Error>;
5533
5534    fn poll_next(
5535        mut self: std::pin::Pin<&mut Self>,
5536        cx: &mut std::task::Context<'_>,
5537    ) -> std::task::Poll<Option<Self::Item>> {
5538        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5539            &mut self.event_receiver,
5540            cx
5541        )?) {
5542            Some(buf) => std::task::Poll::Ready(Some(PackageResolverEvent::decode(buf))),
5543            None => std::task::Poll::Ready(None),
5544        }
5545    }
5546}
5547
5548#[derive(Debug)]
5549pub enum PackageResolverEvent {}
5550
5551impl PackageResolverEvent {
5552    /// Decodes a message buffer as a [`PackageResolverEvent`].
5553    fn decode(
5554        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5555    ) -> Result<PackageResolverEvent, fidl::Error> {
5556        let (bytes, _handles) = buf.split_mut();
5557        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5558        debug_assert_eq!(tx_header.tx_id, 0);
5559        match tx_header.ordinal {
5560            _ => Err(fidl::Error::UnknownOrdinal {
5561                ordinal: tx_header.ordinal,
5562                protocol_name:
5563                    <PackageResolverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5564            }),
5565        }
5566    }
5567}
5568
5569/// A Stream of incoming requests for fuchsia.pkg/PackageResolver.
5570pub struct PackageResolverRequestStream {
5571    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5572    is_terminated: bool,
5573}
5574
5575impl std::marker::Unpin for PackageResolverRequestStream {}
5576
5577impl futures::stream::FusedStream for PackageResolverRequestStream {
5578    fn is_terminated(&self) -> bool {
5579        self.is_terminated
5580    }
5581}
5582
5583impl fidl::endpoints::RequestStream for PackageResolverRequestStream {
5584    type Protocol = PackageResolverMarker;
5585    type ControlHandle = PackageResolverControlHandle;
5586
5587    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5588        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5589    }
5590
5591    fn control_handle(&self) -> Self::ControlHandle {
5592        PackageResolverControlHandle { inner: self.inner.clone() }
5593    }
5594
5595    fn into_inner(
5596        self,
5597    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5598    {
5599        (self.inner, self.is_terminated)
5600    }
5601
5602    fn from_inner(
5603        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5604        is_terminated: bool,
5605    ) -> Self {
5606        Self { inner, is_terminated }
5607    }
5608}
5609
5610impl futures::Stream for PackageResolverRequestStream {
5611    type Item = Result<PackageResolverRequest, fidl::Error>;
5612
5613    fn poll_next(
5614        mut self: std::pin::Pin<&mut Self>,
5615        cx: &mut std::task::Context<'_>,
5616    ) -> std::task::Poll<Option<Self::Item>> {
5617        let this = &mut *self;
5618        if this.inner.check_shutdown(cx) {
5619            this.is_terminated = true;
5620            return std::task::Poll::Ready(None);
5621        }
5622        if this.is_terminated {
5623            panic!("polled PackageResolverRequestStream after completion");
5624        }
5625        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5626            |bytes, handles| {
5627                match this.inner.channel().read_etc(cx, bytes, handles) {
5628                    std::task::Poll::Ready(Ok(())) => {}
5629                    std::task::Poll::Pending => return std::task::Poll::Pending,
5630                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5631                        this.is_terminated = true;
5632                        return std::task::Poll::Ready(None);
5633                    }
5634                    std::task::Poll::Ready(Err(e)) => {
5635                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5636                            e.into(),
5637                        ))))
5638                    }
5639                }
5640
5641                // A message has been received from the channel
5642                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5643
5644                std::task::Poll::Ready(Some(match header.ordinal {
5645                    0x6611263be4052d4f => {
5646                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5647                        let mut req = fidl::new_empty!(
5648                            PackageResolverResolveRequest,
5649                            fidl::encoding::DefaultFuchsiaResourceDialect
5650                        );
5651                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PackageResolverResolveRequest>(&header, _body_bytes, handles, &mut req)?;
5652                        let control_handle =
5653                            PackageResolverControlHandle { inner: this.inner.clone() };
5654                        Ok(PackageResolverRequest::Resolve {
5655                            package_url: req.package_url,
5656                            dir: req.dir,
5657
5658                            responder: PackageResolverResolveResponder {
5659                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5660                                tx_id: header.tx_id,
5661                            },
5662                        })
5663                    }
5664                    0x4c255ae7260298d4 => {
5665                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5666                        let mut req = fidl::new_empty!(
5667                            PackageResolverResolveWithContextRequest,
5668                            fidl::encoding::DefaultFuchsiaResourceDialect
5669                        );
5670                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PackageResolverResolveWithContextRequest>(&header, _body_bytes, handles, &mut req)?;
5671                        let control_handle =
5672                            PackageResolverControlHandle { inner: this.inner.clone() };
5673                        Ok(PackageResolverRequest::ResolveWithContext {
5674                            package_url: req.package_url,
5675                            context: req.context,
5676                            dir: req.dir,
5677
5678                            responder: PackageResolverResolveWithContextResponder {
5679                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5680                                tx_id: header.tx_id,
5681                            },
5682                        })
5683                    }
5684                    0x594e8b4db51efd87 => {
5685                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5686                        let mut req = fidl::new_empty!(
5687                            PackageResolverGetHashRequest,
5688                            fidl::encoding::DefaultFuchsiaResourceDialect
5689                        );
5690                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PackageResolverGetHashRequest>(&header, _body_bytes, handles, &mut req)?;
5691                        let control_handle =
5692                            PackageResolverControlHandle { inner: this.inner.clone() };
5693                        Ok(PackageResolverRequest::GetHash {
5694                            package_url: req.package_url,
5695
5696                            responder: PackageResolverGetHashResponder {
5697                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5698                                tx_id: header.tx_id,
5699                            },
5700                        })
5701                    }
5702                    _ => Err(fidl::Error::UnknownOrdinal {
5703                        ordinal: header.ordinal,
5704                        protocol_name:
5705                            <PackageResolverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5706                    }),
5707                }))
5708            },
5709        )
5710    }
5711}
5712
5713/// This resolves packages from a repository.
5714///
5715/// This is intended to be implemented by package resolver components, and used by
5716/// repository administration tools.
5717#[derive(Debug)]
5718pub enum PackageResolverRequest {
5719    /// Populates or updates the cache of a package using an absolute package
5720    /// URL.
5721    ///
5722    /// Ensures that a package, and any transitive subpackages, are on the local
5723    /// filesystem.
5724    ///
5725    /// + request `package_url` the absolute package URL for a package.  The
5726    ///   following link describes the format:
5727    ///   https://fuchsia.dev/fuchsia-src/concepts/packages/package_url.
5728    ///   Resource paths are not allowed.
5729    /// + request `dir` a request for a directory that will be resolved when the
5730    ///   package has been successfully cached.
5731    /// + returns a `resolved_context`, which can be passed to
5732    ///   `ResolveWithContext`, with a relative URL, to resolve a subpackage of
5733    ///   this package.
5734    /// * error indicates failure. See `ResolveError` for values and error
5735    ///   scenarios.
5736    Resolve {
5737        package_url: String,
5738        dir: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
5739        responder: PackageResolverResolveResponder,
5740    },
5741    /// Populates or updates the cache of a package using either an absolute or
5742    /// a relative package URL. If relative, the package will be resolved
5743    /// relative to the supplied `context`.
5744    ///
5745    /// Ensures that a package is on the local filesystem.
5746    ///
5747    /// + request `package_url` the absolute or relative package URL for a
5748    ///   package. If absolute, the `context` is ignored, and the behavior is
5749    ///   identical to calling `Resolve()`. A relative `package_url` is a
5750    ///   subpackage name.
5751    /// + request `context` a `ResolutionContext` associated with a previously
5752    ///   resolved package, for resolving subpackages relative to that package.
5753    /// + request `dir` a request for a directory that will be resolved when the
5754    ///   package has been successfully cached.
5755    /// + returns a `resolved_context`, which can be passed to a subsequent call
5756    ///   to `ResolveWithContext`, with a relative URL, to resolve a subpackage
5757    ///   of this package or subpackage.
5758    /// * error indicates failure. See `ResolveError` for values and error
5759    ///   scenarios.
5760    ResolveWithContext {
5761        package_url: String,
5762        context: ResolutionContext,
5763        dir: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
5764        responder: PackageResolverResolveWithContextResponder,
5765    },
5766    /// Determines the hash of a package.
5767    ///
5768    /// + request `package_url` the package URL for a package.
5769    /// - response `meta_far_blob_id` the hash of the package.
5770    /// * error a zx_status value indicating failure. One of the following:
5771    ///     * `ZX_ERR_INTERNAL` if the resolver encountered an otherwise unspecified error
5772    ///       while handling the request.
5773    ///     * `ZX_ERR_NOT_FOUND` if the package does not exist in the repository specified by
5774    ///       `package_url`.
5775    ///     * `ZX_ERR_BAD_STATE` if the resolver does not know about the repository specified by
5776    ///       `package_url`.
5777    GetHash { package_url: PackageUrl, responder: PackageResolverGetHashResponder },
5778}
5779
5780impl PackageResolverRequest {
5781    #[allow(irrefutable_let_patterns)]
5782    pub fn into_resolve(
5783        self,
5784    ) -> Option<(
5785        String,
5786        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
5787        PackageResolverResolveResponder,
5788    )> {
5789        if let PackageResolverRequest::Resolve { package_url, dir, responder } = self {
5790            Some((package_url, dir, responder))
5791        } else {
5792            None
5793        }
5794    }
5795
5796    #[allow(irrefutable_let_patterns)]
5797    pub fn into_resolve_with_context(
5798        self,
5799    ) -> Option<(
5800        String,
5801        ResolutionContext,
5802        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
5803        PackageResolverResolveWithContextResponder,
5804    )> {
5805        if let PackageResolverRequest::ResolveWithContext { package_url, context, dir, responder } =
5806            self
5807        {
5808            Some((package_url, context, dir, responder))
5809        } else {
5810            None
5811        }
5812    }
5813
5814    #[allow(irrefutable_let_patterns)]
5815    pub fn into_get_hash(self) -> Option<(PackageUrl, PackageResolverGetHashResponder)> {
5816        if let PackageResolverRequest::GetHash { package_url, responder } = self {
5817            Some((package_url, responder))
5818        } else {
5819            None
5820        }
5821    }
5822
5823    /// Name of the method defined in FIDL
5824    pub fn method_name(&self) -> &'static str {
5825        match *self {
5826            PackageResolverRequest::Resolve { .. } => "resolve",
5827            PackageResolverRequest::ResolveWithContext { .. } => "resolve_with_context",
5828            PackageResolverRequest::GetHash { .. } => "get_hash",
5829        }
5830    }
5831}
5832
5833#[derive(Debug, Clone)]
5834pub struct PackageResolverControlHandle {
5835    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5836}
5837
5838impl fidl::endpoints::ControlHandle for PackageResolverControlHandle {
5839    fn shutdown(&self) {
5840        self.inner.shutdown()
5841    }
5842    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5843        self.inner.shutdown_with_epitaph(status)
5844    }
5845
5846    fn is_closed(&self) -> bool {
5847        self.inner.channel().is_closed()
5848    }
5849    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5850        self.inner.channel().on_closed()
5851    }
5852
5853    #[cfg(target_os = "fuchsia")]
5854    fn signal_peer(
5855        &self,
5856        clear_mask: zx::Signals,
5857        set_mask: zx::Signals,
5858    ) -> Result<(), zx_status::Status> {
5859        use fidl::Peered;
5860        self.inner.channel().signal_peer(clear_mask, set_mask)
5861    }
5862}
5863
5864impl PackageResolverControlHandle {}
5865
5866#[must_use = "FIDL methods require a response to be sent"]
5867#[derive(Debug)]
5868pub struct PackageResolverResolveResponder {
5869    control_handle: std::mem::ManuallyDrop<PackageResolverControlHandle>,
5870    tx_id: u32,
5871}
5872
5873/// Set the the channel to be shutdown (see [`PackageResolverControlHandle::shutdown`])
5874/// if the responder is dropped without sending a response, so that the client
5875/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5876impl std::ops::Drop for PackageResolverResolveResponder {
5877    fn drop(&mut self) {
5878        self.control_handle.shutdown();
5879        // Safety: drops once, never accessed again
5880        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5881    }
5882}
5883
5884impl fidl::endpoints::Responder for PackageResolverResolveResponder {
5885    type ControlHandle = PackageResolverControlHandle;
5886
5887    fn control_handle(&self) -> &PackageResolverControlHandle {
5888        &self.control_handle
5889    }
5890
5891    fn drop_without_shutdown(mut self) {
5892        // Safety: drops once, never accessed again due to mem::forget
5893        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5894        // Prevent Drop from running (which would shut down the channel)
5895        std::mem::forget(self);
5896    }
5897}
5898
5899impl PackageResolverResolveResponder {
5900    /// Sends a response to the FIDL transaction.
5901    ///
5902    /// Sets the channel to shutdown if an error occurs.
5903    pub fn send(
5904        self,
5905        mut result: Result<&ResolutionContext, ResolveError>,
5906    ) -> Result<(), fidl::Error> {
5907        let _result = self.send_raw(result);
5908        if _result.is_err() {
5909            self.control_handle.shutdown();
5910        }
5911        self.drop_without_shutdown();
5912        _result
5913    }
5914
5915    /// Similar to "send" but does not shutdown the channel if an error occurs.
5916    pub fn send_no_shutdown_on_err(
5917        self,
5918        mut result: Result<&ResolutionContext, ResolveError>,
5919    ) -> Result<(), fidl::Error> {
5920        let _result = self.send_raw(result);
5921        self.drop_without_shutdown();
5922        _result
5923    }
5924
5925    fn send_raw(
5926        &self,
5927        mut result: Result<&ResolutionContext, ResolveError>,
5928    ) -> Result<(), fidl::Error> {
5929        self.control_handle.inner.send::<fidl::encoding::ResultType<
5930            PackageResolverResolveResponse,
5931            ResolveError,
5932        >>(
5933            result.map(|resolved_context| (resolved_context,)),
5934            self.tx_id,
5935            0x6611263be4052d4f,
5936            fidl::encoding::DynamicFlags::empty(),
5937        )
5938    }
5939}
5940
5941#[must_use = "FIDL methods require a response to be sent"]
5942#[derive(Debug)]
5943pub struct PackageResolverResolveWithContextResponder {
5944    control_handle: std::mem::ManuallyDrop<PackageResolverControlHandle>,
5945    tx_id: u32,
5946}
5947
5948/// Set the the channel to be shutdown (see [`PackageResolverControlHandle::shutdown`])
5949/// if the responder is dropped without sending a response, so that the client
5950/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5951impl std::ops::Drop for PackageResolverResolveWithContextResponder {
5952    fn drop(&mut self) {
5953        self.control_handle.shutdown();
5954        // Safety: drops once, never accessed again
5955        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5956    }
5957}
5958
5959impl fidl::endpoints::Responder for PackageResolverResolveWithContextResponder {
5960    type ControlHandle = PackageResolverControlHandle;
5961
5962    fn control_handle(&self) -> &PackageResolverControlHandle {
5963        &self.control_handle
5964    }
5965
5966    fn drop_without_shutdown(mut self) {
5967        // Safety: drops once, never accessed again due to mem::forget
5968        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5969        // Prevent Drop from running (which would shut down the channel)
5970        std::mem::forget(self);
5971    }
5972}
5973
5974impl PackageResolverResolveWithContextResponder {
5975    /// Sends a response to the FIDL transaction.
5976    ///
5977    /// Sets the channel to shutdown if an error occurs.
5978    pub fn send(
5979        self,
5980        mut result: Result<&ResolutionContext, ResolveError>,
5981    ) -> Result<(), fidl::Error> {
5982        let _result = self.send_raw(result);
5983        if _result.is_err() {
5984            self.control_handle.shutdown();
5985        }
5986        self.drop_without_shutdown();
5987        _result
5988    }
5989
5990    /// Similar to "send" but does not shutdown the channel if an error occurs.
5991    pub fn send_no_shutdown_on_err(
5992        self,
5993        mut result: Result<&ResolutionContext, ResolveError>,
5994    ) -> Result<(), fidl::Error> {
5995        let _result = self.send_raw(result);
5996        self.drop_without_shutdown();
5997        _result
5998    }
5999
6000    fn send_raw(
6001        &self,
6002        mut result: Result<&ResolutionContext, ResolveError>,
6003    ) -> Result<(), fidl::Error> {
6004        self.control_handle.inner.send::<fidl::encoding::ResultType<
6005            PackageResolverResolveWithContextResponse,
6006            ResolveError,
6007        >>(
6008            result.map(|resolved_context| (resolved_context,)),
6009            self.tx_id,
6010            0x4c255ae7260298d4,
6011            fidl::encoding::DynamicFlags::empty(),
6012        )
6013    }
6014}
6015
6016#[must_use = "FIDL methods require a response to be sent"]
6017#[derive(Debug)]
6018pub struct PackageResolverGetHashResponder {
6019    control_handle: std::mem::ManuallyDrop<PackageResolverControlHandle>,
6020    tx_id: u32,
6021}
6022
6023/// Set the the channel to be shutdown (see [`PackageResolverControlHandle::shutdown`])
6024/// if the responder is dropped without sending a response, so that the client
6025/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6026impl std::ops::Drop for PackageResolverGetHashResponder {
6027    fn drop(&mut self) {
6028        self.control_handle.shutdown();
6029        // Safety: drops once, never accessed again
6030        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6031    }
6032}
6033
6034impl fidl::endpoints::Responder for PackageResolverGetHashResponder {
6035    type ControlHandle = PackageResolverControlHandle;
6036
6037    fn control_handle(&self) -> &PackageResolverControlHandle {
6038        &self.control_handle
6039    }
6040
6041    fn drop_without_shutdown(mut self) {
6042        // Safety: drops once, never accessed again due to mem::forget
6043        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6044        // Prevent Drop from running (which would shut down the channel)
6045        std::mem::forget(self);
6046    }
6047}
6048
6049impl PackageResolverGetHashResponder {
6050    /// Sends a response to the FIDL transaction.
6051    ///
6052    /// Sets the channel to shutdown if an error occurs.
6053    pub fn send(self, mut result: Result<&BlobId, i32>) -> Result<(), fidl::Error> {
6054        let _result = self.send_raw(result);
6055        if _result.is_err() {
6056            self.control_handle.shutdown();
6057        }
6058        self.drop_without_shutdown();
6059        _result
6060    }
6061
6062    /// Similar to "send" but does not shutdown the channel if an error occurs.
6063    pub fn send_no_shutdown_on_err(
6064        self,
6065        mut result: Result<&BlobId, i32>,
6066    ) -> Result<(), fidl::Error> {
6067        let _result = self.send_raw(result);
6068        self.drop_without_shutdown();
6069        _result
6070    }
6071
6072    fn send_raw(&self, mut result: Result<&BlobId, i32>) -> Result<(), fidl::Error> {
6073        self.control_handle
6074            .inner
6075            .send::<fidl::encoding::ResultType<PackageResolverGetHashResponse, i32>>(
6076                result.map(|meta_far_blob_id| (meta_far_blob_id,)),
6077                self.tx_id,
6078                0x594e8b4db51efd87,
6079                fidl::encoding::DynamicFlags::empty(),
6080            )
6081    }
6082}
6083
6084#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6085pub struct RepositoryIteratorMarker;
6086
6087impl fidl::endpoints::ProtocolMarker for RepositoryIteratorMarker {
6088    type Proxy = RepositoryIteratorProxy;
6089    type RequestStream = RepositoryIteratorRequestStream;
6090    #[cfg(target_os = "fuchsia")]
6091    type SynchronousProxy = RepositoryIteratorSynchronousProxy;
6092
6093    const DEBUG_NAME: &'static str = "(anonymous) RepositoryIterator";
6094}
6095
6096pub trait RepositoryIteratorProxyInterface: Send + Sync {
6097    type NextResponseFut: std::future::Future<Output = Result<Vec<RepositoryConfig>, fidl::Error>>
6098        + Send;
6099    fn r#next(&self) -> Self::NextResponseFut;
6100}
6101#[derive(Debug)]
6102#[cfg(target_os = "fuchsia")]
6103pub struct RepositoryIteratorSynchronousProxy {
6104    client: fidl::client::sync::Client,
6105}
6106
6107#[cfg(target_os = "fuchsia")]
6108impl fidl::endpoints::SynchronousProxy for RepositoryIteratorSynchronousProxy {
6109    type Proxy = RepositoryIteratorProxy;
6110    type Protocol = RepositoryIteratorMarker;
6111
6112    fn from_channel(inner: fidl::Channel) -> Self {
6113        Self::new(inner)
6114    }
6115
6116    fn into_channel(self) -> fidl::Channel {
6117        self.client.into_channel()
6118    }
6119
6120    fn as_channel(&self) -> &fidl::Channel {
6121        self.client.as_channel()
6122    }
6123}
6124
6125#[cfg(target_os = "fuchsia")]
6126impl RepositoryIteratorSynchronousProxy {
6127    pub fn new(channel: fidl::Channel) -> Self {
6128        let protocol_name =
6129            <RepositoryIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6130        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
6131    }
6132
6133    pub fn into_channel(self) -> fidl::Channel {
6134        self.client.into_channel()
6135    }
6136
6137    /// Waits until an event arrives and returns it. It is safe for other
6138    /// threads to make concurrent requests while waiting for an event.
6139    pub fn wait_for_event(
6140        &self,
6141        deadline: zx::MonotonicInstant,
6142    ) -> Result<RepositoryIteratorEvent, fidl::Error> {
6143        RepositoryIteratorEvent::decode(self.client.wait_for_event(deadline)?)
6144    }
6145
6146    /// Advances the iterator and returns the next batch of repositories.
6147    ///
6148    /// - response `repos` a vector of `RepositoryConfig` repositories.
6149    ///   Will return an empty vector when there are no more repositories.
6150    pub fn r#next(
6151        &self,
6152        ___deadline: zx::MonotonicInstant,
6153    ) -> Result<Vec<RepositoryConfig>, fidl::Error> {
6154        let _response = self
6155            .client
6156            .send_query::<fidl::encoding::EmptyPayload, RepositoryIteratorNextResponse>(
6157                (),
6158                0x5502086bc0cdd25e,
6159                fidl::encoding::DynamicFlags::empty(),
6160                ___deadline,
6161            )?;
6162        Ok(_response.repos)
6163    }
6164}
6165
6166#[cfg(target_os = "fuchsia")]
6167impl From<RepositoryIteratorSynchronousProxy> for zx::Handle {
6168    fn from(value: RepositoryIteratorSynchronousProxy) -> Self {
6169        value.into_channel().into()
6170    }
6171}
6172
6173#[cfg(target_os = "fuchsia")]
6174impl From<fidl::Channel> for RepositoryIteratorSynchronousProxy {
6175    fn from(value: fidl::Channel) -> Self {
6176        Self::new(value)
6177    }
6178}
6179
6180#[derive(Debug, Clone)]
6181pub struct RepositoryIteratorProxy {
6182    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
6183}
6184
6185impl fidl::endpoints::Proxy for RepositoryIteratorProxy {
6186    type Protocol = RepositoryIteratorMarker;
6187
6188    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
6189        Self::new(inner)
6190    }
6191
6192    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
6193        self.client.into_channel().map_err(|client| Self { client })
6194    }
6195
6196    fn as_channel(&self) -> &::fidl::AsyncChannel {
6197        self.client.as_channel()
6198    }
6199}
6200
6201impl RepositoryIteratorProxy {
6202    /// Create a new Proxy for fuchsia.pkg/RepositoryIterator.
6203    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
6204        let protocol_name =
6205            <RepositoryIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6206        Self { client: fidl::client::Client::new(channel, protocol_name) }
6207    }
6208
6209    /// Get a Stream of events from the remote end of the protocol.
6210    ///
6211    /// # Panics
6212    ///
6213    /// Panics if the event stream was already taken.
6214    pub fn take_event_stream(&self) -> RepositoryIteratorEventStream {
6215        RepositoryIteratorEventStream { event_receiver: self.client.take_event_receiver() }
6216    }
6217
6218    /// Advances the iterator and returns the next batch of repositories.
6219    ///
6220    /// - response `repos` a vector of `RepositoryConfig` repositories.
6221    ///   Will return an empty vector when there are no more repositories.
6222    pub fn r#next(
6223        &self,
6224    ) -> fidl::client::QueryResponseFut<
6225        Vec<RepositoryConfig>,
6226        fidl::encoding::DefaultFuchsiaResourceDialect,
6227    > {
6228        RepositoryIteratorProxyInterface::r#next(self)
6229    }
6230}
6231
6232impl RepositoryIteratorProxyInterface for RepositoryIteratorProxy {
6233    type NextResponseFut = fidl::client::QueryResponseFut<
6234        Vec<RepositoryConfig>,
6235        fidl::encoding::DefaultFuchsiaResourceDialect,
6236    >;
6237    fn r#next(&self) -> Self::NextResponseFut {
6238        fn _decode(
6239            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6240        ) -> Result<Vec<RepositoryConfig>, fidl::Error> {
6241            let _response = fidl::client::decode_transaction_body::<
6242                RepositoryIteratorNextResponse,
6243                fidl::encoding::DefaultFuchsiaResourceDialect,
6244                0x5502086bc0cdd25e,
6245            >(_buf?)?;
6246            Ok(_response.repos)
6247        }
6248        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<RepositoryConfig>>(
6249            (),
6250            0x5502086bc0cdd25e,
6251            fidl::encoding::DynamicFlags::empty(),
6252            _decode,
6253        )
6254    }
6255}
6256
6257pub struct RepositoryIteratorEventStream {
6258    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
6259}
6260
6261impl std::marker::Unpin for RepositoryIteratorEventStream {}
6262
6263impl futures::stream::FusedStream for RepositoryIteratorEventStream {
6264    fn is_terminated(&self) -> bool {
6265        self.event_receiver.is_terminated()
6266    }
6267}
6268
6269impl futures::Stream for RepositoryIteratorEventStream {
6270    type Item = Result<RepositoryIteratorEvent, fidl::Error>;
6271
6272    fn poll_next(
6273        mut self: std::pin::Pin<&mut Self>,
6274        cx: &mut std::task::Context<'_>,
6275    ) -> std::task::Poll<Option<Self::Item>> {
6276        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
6277            &mut self.event_receiver,
6278            cx
6279        )?) {
6280            Some(buf) => std::task::Poll::Ready(Some(RepositoryIteratorEvent::decode(buf))),
6281            None => std::task::Poll::Ready(None),
6282        }
6283    }
6284}
6285
6286#[derive(Debug)]
6287pub enum RepositoryIteratorEvent {}
6288
6289impl RepositoryIteratorEvent {
6290    /// Decodes a message buffer as a [`RepositoryIteratorEvent`].
6291    fn decode(
6292        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
6293    ) -> Result<RepositoryIteratorEvent, fidl::Error> {
6294        let (bytes, _handles) = buf.split_mut();
6295        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6296        debug_assert_eq!(tx_header.tx_id, 0);
6297        match tx_header.ordinal {
6298            _ => Err(fidl::Error::UnknownOrdinal {
6299                ordinal: tx_header.ordinal,
6300                protocol_name:
6301                    <RepositoryIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6302            }),
6303        }
6304    }
6305}
6306
6307/// A Stream of incoming requests for fuchsia.pkg/RepositoryIterator.
6308pub struct RepositoryIteratorRequestStream {
6309    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6310    is_terminated: bool,
6311}
6312
6313impl std::marker::Unpin for RepositoryIteratorRequestStream {}
6314
6315impl futures::stream::FusedStream for RepositoryIteratorRequestStream {
6316    fn is_terminated(&self) -> bool {
6317        self.is_terminated
6318    }
6319}
6320
6321impl fidl::endpoints::RequestStream for RepositoryIteratorRequestStream {
6322    type Protocol = RepositoryIteratorMarker;
6323    type ControlHandle = RepositoryIteratorControlHandle;
6324
6325    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
6326        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
6327    }
6328
6329    fn control_handle(&self) -> Self::ControlHandle {
6330        RepositoryIteratorControlHandle { inner: self.inner.clone() }
6331    }
6332
6333    fn into_inner(
6334        self,
6335    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
6336    {
6337        (self.inner, self.is_terminated)
6338    }
6339
6340    fn from_inner(
6341        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6342        is_terminated: bool,
6343    ) -> Self {
6344        Self { inner, is_terminated }
6345    }
6346}
6347
6348impl futures::Stream for RepositoryIteratorRequestStream {
6349    type Item = Result<RepositoryIteratorRequest, fidl::Error>;
6350
6351    fn poll_next(
6352        mut self: std::pin::Pin<&mut Self>,
6353        cx: &mut std::task::Context<'_>,
6354    ) -> std::task::Poll<Option<Self::Item>> {
6355        let this = &mut *self;
6356        if this.inner.check_shutdown(cx) {
6357            this.is_terminated = true;
6358            return std::task::Poll::Ready(None);
6359        }
6360        if this.is_terminated {
6361            panic!("polled RepositoryIteratorRequestStream after completion");
6362        }
6363        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
6364            |bytes, handles| {
6365                match this.inner.channel().read_etc(cx, bytes, handles) {
6366                    std::task::Poll::Ready(Ok(())) => {}
6367                    std::task::Poll::Pending => return std::task::Poll::Pending,
6368                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
6369                        this.is_terminated = true;
6370                        return std::task::Poll::Ready(None);
6371                    }
6372                    std::task::Poll::Ready(Err(e)) => {
6373                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
6374                            e.into(),
6375                        ))))
6376                    }
6377                }
6378
6379                // A message has been received from the channel
6380                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6381
6382                std::task::Poll::Ready(Some(match header.ordinal {
6383                0x5502086bc0cdd25e => {
6384                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6385                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
6386                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6387                    let control_handle = RepositoryIteratorControlHandle {
6388                        inner: this.inner.clone(),
6389                    };
6390                    Ok(RepositoryIteratorRequest::Next {
6391                        responder: RepositoryIteratorNextResponder {
6392                            control_handle: std::mem::ManuallyDrop::new(control_handle),
6393                            tx_id: header.tx_id,
6394                        },
6395                    })
6396                }
6397                _ => Err(fidl::Error::UnknownOrdinal {
6398                    ordinal: header.ordinal,
6399                    protocol_name: <RepositoryIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6400                }),
6401            }))
6402            },
6403        )
6404    }
6405}
6406
6407/// The iterator over all the repositories defined in a `PackageResolver`.
6408#[derive(Debug)]
6409pub enum RepositoryIteratorRequest {
6410    /// Advances the iterator and returns the next batch of repositories.
6411    ///
6412    /// - response `repos` a vector of `RepositoryConfig` repositories.
6413    ///   Will return an empty vector when there are no more repositories.
6414    Next { responder: RepositoryIteratorNextResponder },
6415}
6416
6417impl RepositoryIteratorRequest {
6418    #[allow(irrefutable_let_patterns)]
6419    pub fn into_next(self) -> Option<(RepositoryIteratorNextResponder)> {
6420        if let RepositoryIteratorRequest::Next { responder } = self {
6421            Some((responder))
6422        } else {
6423            None
6424        }
6425    }
6426
6427    /// Name of the method defined in FIDL
6428    pub fn method_name(&self) -> &'static str {
6429        match *self {
6430            RepositoryIteratorRequest::Next { .. } => "next",
6431        }
6432    }
6433}
6434
6435#[derive(Debug, Clone)]
6436pub struct RepositoryIteratorControlHandle {
6437    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6438}
6439
6440impl fidl::endpoints::ControlHandle for RepositoryIteratorControlHandle {
6441    fn shutdown(&self) {
6442        self.inner.shutdown()
6443    }
6444    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
6445        self.inner.shutdown_with_epitaph(status)
6446    }
6447
6448    fn is_closed(&self) -> bool {
6449        self.inner.channel().is_closed()
6450    }
6451    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6452        self.inner.channel().on_closed()
6453    }
6454
6455    #[cfg(target_os = "fuchsia")]
6456    fn signal_peer(
6457        &self,
6458        clear_mask: zx::Signals,
6459        set_mask: zx::Signals,
6460    ) -> Result<(), zx_status::Status> {
6461        use fidl::Peered;
6462        self.inner.channel().signal_peer(clear_mask, set_mask)
6463    }
6464}
6465
6466impl RepositoryIteratorControlHandle {}
6467
6468#[must_use = "FIDL methods require a response to be sent"]
6469#[derive(Debug)]
6470pub struct RepositoryIteratorNextResponder {
6471    control_handle: std::mem::ManuallyDrop<RepositoryIteratorControlHandle>,
6472    tx_id: u32,
6473}
6474
6475/// Set the the channel to be shutdown (see [`RepositoryIteratorControlHandle::shutdown`])
6476/// if the responder is dropped without sending a response, so that the client
6477/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6478impl std::ops::Drop for RepositoryIteratorNextResponder {
6479    fn drop(&mut self) {
6480        self.control_handle.shutdown();
6481        // Safety: drops once, never accessed again
6482        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6483    }
6484}
6485
6486impl fidl::endpoints::Responder for RepositoryIteratorNextResponder {
6487    type ControlHandle = RepositoryIteratorControlHandle;
6488
6489    fn control_handle(&self) -> &RepositoryIteratorControlHandle {
6490        &self.control_handle
6491    }
6492
6493    fn drop_without_shutdown(mut self) {
6494        // Safety: drops once, never accessed again due to mem::forget
6495        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6496        // Prevent Drop from running (which would shut down the channel)
6497        std::mem::forget(self);
6498    }
6499}
6500
6501impl RepositoryIteratorNextResponder {
6502    /// Sends a response to the FIDL transaction.
6503    ///
6504    /// Sets the channel to shutdown if an error occurs.
6505    pub fn send(self, mut repos: &[RepositoryConfig]) -> Result<(), fidl::Error> {
6506        let _result = self.send_raw(repos);
6507        if _result.is_err() {
6508            self.control_handle.shutdown();
6509        }
6510        self.drop_without_shutdown();
6511        _result
6512    }
6513
6514    /// Similar to "send" but does not shutdown the channel if an error occurs.
6515    pub fn send_no_shutdown_on_err(
6516        self,
6517        mut repos: &[RepositoryConfig],
6518    ) -> Result<(), fidl::Error> {
6519        let _result = self.send_raw(repos);
6520        self.drop_without_shutdown();
6521        _result
6522    }
6523
6524    fn send_raw(&self, mut repos: &[RepositoryConfig]) -> Result<(), fidl::Error> {
6525        self.control_handle.inner.send::<RepositoryIteratorNextResponse>(
6526            (repos,),
6527            self.tx_id,
6528            0x5502086bc0cdd25e,
6529            fidl::encoding::DynamicFlags::empty(),
6530        )
6531    }
6532}
6533
6534#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6535pub struct RepositoryManagerMarker;
6536
6537impl fidl::endpoints::ProtocolMarker for RepositoryManagerMarker {
6538    type Proxy = RepositoryManagerProxy;
6539    type RequestStream = RepositoryManagerRequestStream;
6540    #[cfg(target_os = "fuchsia")]
6541    type SynchronousProxy = RepositoryManagerSynchronousProxy;
6542
6543    const DEBUG_NAME: &'static str = "fuchsia.pkg.RepositoryManager";
6544}
6545impl fidl::endpoints::DiscoverableProtocolMarker for RepositoryManagerMarker {}
6546pub type RepositoryManagerAddResult = Result<(), i32>;
6547pub type RepositoryManagerRemoveResult = Result<(), i32>;
6548pub type RepositoryManagerAddMirrorResult = Result<(), i32>;
6549pub type RepositoryManagerRemoveMirrorResult = Result<(), i32>;
6550
6551pub trait RepositoryManagerProxyInterface: Send + Sync {
6552    type AddResponseFut: std::future::Future<Output = Result<RepositoryManagerAddResult, fidl::Error>>
6553        + Send;
6554    fn r#add(&self, repo: &RepositoryConfig) -> Self::AddResponseFut;
6555    type RemoveResponseFut: std::future::Future<Output = Result<RepositoryManagerRemoveResult, fidl::Error>>
6556        + Send;
6557    fn r#remove(&self, repo_url: &str) -> Self::RemoveResponseFut;
6558    type AddMirrorResponseFut: std::future::Future<Output = Result<RepositoryManagerAddMirrorResult, fidl::Error>>
6559        + Send;
6560    fn r#add_mirror(&self, repo_url: &str, mirror: &MirrorConfig) -> Self::AddMirrorResponseFut;
6561    type RemoveMirrorResponseFut: std::future::Future<Output = Result<RepositoryManagerRemoveMirrorResult, fidl::Error>>
6562        + Send;
6563    fn r#remove_mirror(&self, repo_url: &str, mirror_url: &str) -> Self::RemoveMirrorResponseFut;
6564    fn r#list(
6565        &self,
6566        iterator: fidl::endpoints::ServerEnd<RepositoryIteratorMarker>,
6567    ) -> Result<(), fidl::Error>;
6568}
6569#[derive(Debug)]
6570#[cfg(target_os = "fuchsia")]
6571pub struct RepositoryManagerSynchronousProxy {
6572    client: fidl::client::sync::Client,
6573}
6574
6575#[cfg(target_os = "fuchsia")]
6576impl fidl::endpoints::SynchronousProxy for RepositoryManagerSynchronousProxy {
6577    type Proxy = RepositoryManagerProxy;
6578    type Protocol = RepositoryManagerMarker;
6579
6580    fn from_channel(inner: fidl::Channel) -> Self {
6581        Self::new(inner)
6582    }
6583
6584    fn into_channel(self) -> fidl::Channel {
6585        self.client.into_channel()
6586    }
6587
6588    fn as_channel(&self) -> &fidl::Channel {
6589        self.client.as_channel()
6590    }
6591}
6592
6593#[cfg(target_os = "fuchsia")]
6594impl RepositoryManagerSynchronousProxy {
6595    pub fn new(channel: fidl::Channel) -> Self {
6596        let protocol_name =
6597            <RepositoryManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6598        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
6599    }
6600
6601    pub fn into_channel(self) -> fidl::Channel {
6602        self.client.into_channel()
6603    }
6604
6605    /// Waits until an event arrives and returns it. It is safe for other
6606    /// threads to make concurrent requests while waiting for an event.
6607    pub fn wait_for_event(
6608        &self,
6609        deadline: zx::MonotonicInstant,
6610    ) -> Result<RepositoryManagerEvent, fidl::Error> {
6611        RepositoryManagerEvent::decode(self.client.wait_for_event(deadline)?)
6612    }
6613
6614    /// Adds a repository. This will overwrite the repository if it already exists.
6615    ///
6616    /// + request `repo` a repository to add to the resolver.
6617    /// * error a zx_status value indicating failure. One of the following:
6618    ///     * `ZX_ERR_ACCESS_DENIED` if editing repositories is permanently disabled.
6619    ///     * `ZX_ERR_ALREADY_EXISTS` if the repository already exists.
6620    ///     * `ZX_ERR_INVALID_ARGS` if the repository is malformed.
6621    pub fn r#add(
6622        &self,
6623        mut repo: &RepositoryConfig,
6624        ___deadline: zx::MonotonicInstant,
6625    ) -> Result<RepositoryManagerAddResult, fidl::Error> {
6626        let _response = self.client.send_query::<
6627            RepositoryManagerAddRequest,
6628            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
6629        >(
6630            (repo,),
6631            0x7fff4b8c733c7151,
6632            fidl::encoding::DynamicFlags::empty(),
6633            ___deadline,
6634        )?;
6635        Ok(_response.map(|x| x))
6636    }
6637
6638    /// Removes a repository.
6639    ///
6640    /// Removing a repository will prevent future packages from being cached from this repository,
6641    /// but in-flight downloads may not be interrupted.
6642    ///
6643    /// + request `repo_url` the URL of the repository we want to remove.
6644    /// * error a zx_status value indicating failure. One of the following:
6645    ///     * `ZX_ERR_ACCESS_DENIED` if editing repositories is permanently disabled or the
6646    ///       `repo_url` matches a static repository.
6647    ///     * `ZX_ERR_INVALID_ARGS` if the `repo_url` is malformed.
6648    ///     * `ZX_ERR_NOT_FOUND` if the repository does not exist.
6649    pub fn r#remove(
6650        &self,
6651        mut repo_url: &str,
6652        ___deadline: zx::MonotonicInstant,
6653    ) -> Result<RepositoryManagerRemoveResult, fidl::Error> {
6654        let _response = self.client.send_query::<
6655            RepositoryManagerRemoveRequest,
6656            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
6657        >(
6658            (repo_url,),
6659            0x5de23dc0e0dea4ba,
6660            fidl::encoding::DynamicFlags::empty(),
6661            ___deadline,
6662        )?;
6663        Ok(_response.map(|x| x))
6664    }
6665
6666    /// Adds a mirror to a repository. This will overwrite the mirror if it already exists.
6667    ///
6668    /// + request `repo_url` the URL of the repository to add the mirror to.
6669    /// + request `mirror` the mirror config used to add the mirror.
6670    /// * error a zx_status value indicating failure. One of the following:
6671    ///     * `ZX_ERR_ALREADY_EXISTS` if the mirror for this repository already exists.
6672    ///     * `ZX_ERR_INVALID_ARGS` if the `repo_url` or the `mirror` is malformed.
6673    ///     * `ZX_ERR_NOT_FOUND` if the repository does not exist.
6674    pub fn r#add_mirror(
6675        &self,
6676        mut repo_url: &str,
6677        mut mirror: &MirrorConfig,
6678        ___deadline: zx::MonotonicInstant,
6679    ) -> Result<RepositoryManagerAddMirrorResult, fidl::Error> {
6680        let _response = self.client.send_query::<
6681            RepositoryManagerAddMirrorRequest,
6682            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
6683        >(
6684            (repo_url, mirror,),
6685            0x3b7ef213730dd24c,
6686            fidl::encoding::DynamicFlags::empty(),
6687            ___deadline,
6688        )?;
6689        Ok(_response.map(|x| x))
6690    }
6691
6692    /// Removes a mirror from a repository.
6693    ///
6694    /// Removing a mirror will prevent future packages from being cached from that mirror, but
6695    /// in-flight downloads may not be interrupted.
6696    ///
6697    /// + request `repo_url` the URL of the mirror's repository.
6698    /// + request `mirror_url` the URL of the mirror we want to remove.
6699    /// * error a zx_status value indicating failure. One of the following:
6700    ///     * `ZX_ERR_INVALID_ARGS` if the `repo_url` or the `mirror_url` is malformed.
6701    ///     * `ZX_ERR_NOT_FOUND` if the repository or mirror does not exist.
6702    pub fn r#remove_mirror(
6703        &self,
6704        mut repo_url: &str,
6705        mut mirror_url: &str,
6706        ___deadline: zx::MonotonicInstant,
6707    ) -> Result<RepositoryManagerRemoveMirrorResult, fidl::Error> {
6708        let _response = self.client.send_query::<
6709            RepositoryManagerRemoveMirrorRequest,
6710            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
6711        >(
6712            (repo_url, mirror_url,),
6713            0x4682584cc47c23a2,
6714            fidl::encoding::DynamicFlags::empty(),
6715            ___deadline,
6716        )?;
6717        Ok(_response.map(|x| x))
6718    }
6719
6720    /// Returns an iterator over all repositories.
6721    ///
6722    /// + request `iterator` a request for an iterator.
6723    pub fn r#list(
6724        &self,
6725        mut iterator: fidl::endpoints::ServerEnd<RepositoryIteratorMarker>,
6726    ) -> Result<(), fidl::Error> {
6727        self.client.send::<RepositoryManagerListRequest>(
6728            (iterator,),
6729            0x61837314ba6f4afb,
6730            fidl::encoding::DynamicFlags::empty(),
6731        )
6732    }
6733}
6734
6735#[cfg(target_os = "fuchsia")]
6736impl From<RepositoryManagerSynchronousProxy> for zx::Handle {
6737    fn from(value: RepositoryManagerSynchronousProxy) -> Self {
6738        value.into_channel().into()
6739    }
6740}
6741
6742#[cfg(target_os = "fuchsia")]
6743impl From<fidl::Channel> for RepositoryManagerSynchronousProxy {
6744    fn from(value: fidl::Channel) -> Self {
6745        Self::new(value)
6746    }
6747}
6748
6749#[derive(Debug, Clone)]
6750pub struct RepositoryManagerProxy {
6751    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
6752}
6753
6754impl fidl::endpoints::Proxy for RepositoryManagerProxy {
6755    type Protocol = RepositoryManagerMarker;
6756
6757    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
6758        Self::new(inner)
6759    }
6760
6761    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
6762        self.client.into_channel().map_err(|client| Self { client })
6763    }
6764
6765    fn as_channel(&self) -> &::fidl::AsyncChannel {
6766        self.client.as_channel()
6767    }
6768}
6769
6770impl RepositoryManagerProxy {
6771    /// Create a new Proxy for fuchsia.pkg/RepositoryManager.
6772    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
6773        let protocol_name =
6774            <RepositoryManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6775        Self { client: fidl::client::Client::new(channel, protocol_name) }
6776    }
6777
6778    /// Get a Stream of events from the remote end of the protocol.
6779    ///
6780    /// # Panics
6781    ///
6782    /// Panics if the event stream was already taken.
6783    pub fn take_event_stream(&self) -> RepositoryManagerEventStream {
6784        RepositoryManagerEventStream { event_receiver: self.client.take_event_receiver() }
6785    }
6786
6787    /// Adds a repository. This will overwrite the repository if it already exists.
6788    ///
6789    /// + request `repo` a repository to add to the resolver.
6790    /// * error a zx_status value indicating failure. One of the following:
6791    ///     * `ZX_ERR_ACCESS_DENIED` if editing repositories is permanently disabled.
6792    ///     * `ZX_ERR_ALREADY_EXISTS` if the repository already exists.
6793    ///     * `ZX_ERR_INVALID_ARGS` if the repository is malformed.
6794    pub fn r#add(
6795        &self,
6796        mut repo: &RepositoryConfig,
6797    ) -> fidl::client::QueryResponseFut<
6798        RepositoryManagerAddResult,
6799        fidl::encoding::DefaultFuchsiaResourceDialect,
6800    > {
6801        RepositoryManagerProxyInterface::r#add(self, repo)
6802    }
6803
6804    /// Removes a repository.
6805    ///
6806    /// Removing a repository will prevent future packages from being cached from this repository,
6807    /// but in-flight downloads may not be interrupted.
6808    ///
6809    /// + request `repo_url` the URL of the repository we want to remove.
6810    /// * error a zx_status value indicating failure. One of the following:
6811    ///     * `ZX_ERR_ACCESS_DENIED` if editing repositories is permanently disabled or the
6812    ///       `repo_url` matches a static repository.
6813    ///     * `ZX_ERR_INVALID_ARGS` if the `repo_url` is malformed.
6814    ///     * `ZX_ERR_NOT_FOUND` if the repository does not exist.
6815    pub fn r#remove(
6816        &self,
6817        mut repo_url: &str,
6818    ) -> fidl::client::QueryResponseFut<
6819        RepositoryManagerRemoveResult,
6820        fidl::encoding::DefaultFuchsiaResourceDialect,
6821    > {
6822        RepositoryManagerProxyInterface::r#remove(self, repo_url)
6823    }
6824
6825    /// Adds a mirror to a repository. This will overwrite the mirror if it already exists.
6826    ///
6827    /// + request `repo_url` the URL of the repository to add the mirror to.
6828    /// + request `mirror` the mirror config used to add the mirror.
6829    /// * error a zx_status value indicating failure. One of the following:
6830    ///     * `ZX_ERR_ALREADY_EXISTS` if the mirror for this repository already exists.
6831    ///     * `ZX_ERR_INVALID_ARGS` if the `repo_url` or the `mirror` is malformed.
6832    ///     * `ZX_ERR_NOT_FOUND` if the repository does not exist.
6833    pub fn r#add_mirror(
6834        &self,
6835        mut repo_url: &str,
6836        mut mirror: &MirrorConfig,
6837    ) -> fidl::client::QueryResponseFut<
6838        RepositoryManagerAddMirrorResult,
6839        fidl::encoding::DefaultFuchsiaResourceDialect,
6840    > {
6841        RepositoryManagerProxyInterface::r#add_mirror(self, repo_url, mirror)
6842    }
6843
6844    /// Removes a mirror from a repository.
6845    ///
6846    /// Removing a mirror will prevent future packages from being cached from that mirror, but
6847    /// in-flight downloads may not be interrupted.
6848    ///
6849    /// + request `repo_url` the URL of the mirror's repository.
6850    /// + request `mirror_url` the URL of the mirror we want to remove.
6851    /// * error a zx_status value indicating failure. One of the following:
6852    ///     * `ZX_ERR_INVALID_ARGS` if the `repo_url` or the `mirror_url` is malformed.
6853    ///     * `ZX_ERR_NOT_FOUND` if the repository or mirror does not exist.
6854    pub fn r#remove_mirror(
6855        &self,
6856        mut repo_url: &str,
6857        mut mirror_url: &str,
6858    ) -> fidl::client::QueryResponseFut<
6859        RepositoryManagerRemoveMirrorResult,
6860        fidl::encoding::DefaultFuchsiaResourceDialect,
6861    > {
6862        RepositoryManagerProxyInterface::r#remove_mirror(self, repo_url, mirror_url)
6863    }
6864
6865    /// Returns an iterator over all repositories.
6866    ///
6867    /// + request `iterator` a request for an iterator.
6868    pub fn r#list(
6869        &self,
6870        mut iterator: fidl::endpoints::ServerEnd<RepositoryIteratorMarker>,
6871    ) -> Result<(), fidl::Error> {
6872        RepositoryManagerProxyInterface::r#list(self, iterator)
6873    }
6874}
6875
6876impl RepositoryManagerProxyInterface for RepositoryManagerProxy {
6877    type AddResponseFut = fidl::client::QueryResponseFut<
6878        RepositoryManagerAddResult,
6879        fidl::encoding::DefaultFuchsiaResourceDialect,
6880    >;
6881    fn r#add(&self, mut repo: &RepositoryConfig) -> Self::AddResponseFut {
6882        fn _decode(
6883            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6884        ) -> Result<RepositoryManagerAddResult, fidl::Error> {
6885            let _response = fidl::client::decode_transaction_body::<
6886                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
6887                fidl::encoding::DefaultFuchsiaResourceDialect,
6888                0x7fff4b8c733c7151,
6889            >(_buf?)?;
6890            Ok(_response.map(|x| x))
6891        }
6892        self.client
6893            .send_query_and_decode::<RepositoryManagerAddRequest, RepositoryManagerAddResult>(
6894                (repo,),
6895                0x7fff4b8c733c7151,
6896                fidl::encoding::DynamicFlags::empty(),
6897                _decode,
6898            )
6899    }
6900
6901    type RemoveResponseFut = fidl::client::QueryResponseFut<
6902        RepositoryManagerRemoveResult,
6903        fidl::encoding::DefaultFuchsiaResourceDialect,
6904    >;
6905    fn r#remove(&self, mut repo_url: &str) -> Self::RemoveResponseFut {
6906        fn _decode(
6907            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6908        ) -> Result<RepositoryManagerRemoveResult, fidl::Error> {
6909            let _response = fidl::client::decode_transaction_body::<
6910                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
6911                fidl::encoding::DefaultFuchsiaResourceDialect,
6912                0x5de23dc0e0dea4ba,
6913            >(_buf?)?;
6914            Ok(_response.map(|x| x))
6915        }
6916        self.client
6917            .send_query_and_decode::<RepositoryManagerRemoveRequest, RepositoryManagerRemoveResult>(
6918                (repo_url,),
6919                0x5de23dc0e0dea4ba,
6920                fidl::encoding::DynamicFlags::empty(),
6921                _decode,
6922            )
6923    }
6924
6925    type AddMirrorResponseFut = fidl::client::QueryResponseFut<
6926        RepositoryManagerAddMirrorResult,
6927        fidl::encoding::DefaultFuchsiaResourceDialect,
6928    >;
6929    fn r#add_mirror(
6930        &self,
6931        mut repo_url: &str,
6932        mut mirror: &MirrorConfig,
6933    ) -> Self::AddMirrorResponseFut {
6934        fn _decode(
6935            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6936        ) -> Result<RepositoryManagerAddMirrorResult, fidl::Error> {
6937            let _response = fidl::client::decode_transaction_body::<
6938                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
6939                fidl::encoding::DefaultFuchsiaResourceDialect,
6940                0x3b7ef213730dd24c,
6941            >(_buf?)?;
6942            Ok(_response.map(|x| x))
6943        }
6944        self.client.send_query_and_decode::<
6945            RepositoryManagerAddMirrorRequest,
6946            RepositoryManagerAddMirrorResult,
6947        >(
6948            (repo_url, mirror,),
6949            0x3b7ef213730dd24c,
6950            fidl::encoding::DynamicFlags::empty(),
6951            _decode,
6952        )
6953    }
6954
6955    type RemoveMirrorResponseFut = fidl::client::QueryResponseFut<
6956        RepositoryManagerRemoveMirrorResult,
6957        fidl::encoding::DefaultFuchsiaResourceDialect,
6958    >;
6959    fn r#remove_mirror(
6960        &self,
6961        mut repo_url: &str,
6962        mut mirror_url: &str,
6963    ) -> Self::RemoveMirrorResponseFut {
6964        fn _decode(
6965            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6966        ) -> Result<RepositoryManagerRemoveMirrorResult, fidl::Error> {
6967            let _response = fidl::client::decode_transaction_body::<
6968                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
6969                fidl::encoding::DefaultFuchsiaResourceDialect,
6970                0x4682584cc47c23a2,
6971            >(_buf?)?;
6972            Ok(_response.map(|x| x))
6973        }
6974        self.client.send_query_and_decode::<
6975            RepositoryManagerRemoveMirrorRequest,
6976            RepositoryManagerRemoveMirrorResult,
6977        >(
6978            (repo_url, mirror_url,),
6979            0x4682584cc47c23a2,
6980            fidl::encoding::DynamicFlags::empty(),
6981            _decode,
6982        )
6983    }
6984
6985    fn r#list(
6986        &self,
6987        mut iterator: fidl::endpoints::ServerEnd<RepositoryIteratorMarker>,
6988    ) -> Result<(), fidl::Error> {
6989        self.client.send::<RepositoryManagerListRequest>(
6990            (iterator,),
6991            0x61837314ba6f4afb,
6992            fidl::encoding::DynamicFlags::empty(),
6993        )
6994    }
6995}
6996
6997pub struct RepositoryManagerEventStream {
6998    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
6999}
7000
7001impl std::marker::Unpin for RepositoryManagerEventStream {}
7002
7003impl futures::stream::FusedStream for RepositoryManagerEventStream {
7004    fn is_terminated(&self) -> bool {
7005        self.event_receiver.is_terminated()
7006    }
7007}
7008
7009impl futures::Stream for RepositoryManagerEventStream {
7010    type Item = Result<RepositoryManagerEvent, fidl::Error>;
7011
7012    fn poll_next(
7013        mut self: std::pin::Pin<&mut Self>,
7014        cx: &mut std::task::Context<'_>,
7015    ) -> std::task::Poll<Option<Self::Item>> {
7016        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7017            &mut self.event_receiver,
7018            cx
7019        )?) {
7020            Some(buf) => std::task::Poll::Ready(Some(RepositoryManagerEvent::decode(buf))),
7021            None => std::task::Poll::Ready(None),
7022        }
7023    }
7024}
7025
7026#[derive(Debug)]
7027pub enum RepositoryManagerEvent {}
7028
7029impl RepositoryManagerEvent {
7030    /// Decodes a message buffer as a [`RepositoryManagerEvent`].
7031    fn decode(
7032        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7033    ) -> Result<RepositoryManagerEvent, fidl::Error> {
7034        let (bytes, _handles) = buf.split_mut();
7035        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7036        debug_assert_eq!(tx_header.tx_id, 0);
7037        match tx_header.ordinal {
7038            _ => Err(fidl::Error::UnknownOrdinal {
7039                ordinal: tx_header.ordinal,
7040                protocol_name:
7041                    <RepositoryManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7042            }),
7043        }
7044    }
7045}
7046
7047/// A Stream of incoming requests for fuchsia.pkg/RepositoryManager.
7048pub struct RepositoryManagerRequestStream {
7049    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7050    is_terminated: bool,
7051}
7052
7053impl std::marker::Unpin for RepositoryManagerRequestStream {}
7054
7055impl futures::stream::FusedStream for RepositoryManagerRequestStream {
7056    fn is_terminated(&self) -> bool {
7057        self.is_terminated
7058    }
7059}
7060
7061impl fidl::endpoints::RequestStream for RepositoryManagerRequestStream {
7062    type Protocol = RepositoryManagerMarker;
7063    type ControlHandle = RepositoryManagerControlHandle;
7064
7065    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
7066        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7067    }
7068
7069    fn control_handle(&self) -> Self::ControlHandle {
7070        RepositoryManagerControlHandle { inner: self.inner.clone() }
7071    }
7072
7073    fn into_inner(
7074        self,
7075    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
7076    {
7077        (self.inner, self.is_terminated)
7078    }
7079
7080    fn from_inner(
7081        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7082        is_terminated: bool,
7083    ) -> Self {
7084        Self { inner, is_terminated }
7085    }
7086}
7087
7088impl futures::Stream for RepositoryManagerRequestStream {
7089    type Item = Result<RepositoryManagerRequest, fidl::Error>;
7090
7091    fn poll_next(
7092        mut self: std::pin::Pin<&mut Self>,
7093        cx: &mut std::task::Context<'_>,
7094    ) -> std::task::Poll<Option<Self::Item>> {
7095        let this = &mut *self;
7096        if this.inner.check_shutdown(cx) {
7097            this.is_terminated = true;
7098            return std::task::Poll::Ready(None);
7099        }
7100        if this.is_terminated {
7101            panic!("polled RepositoryManagerRequestStream after completion");
7102        }
7103        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
7104            |bytes, handles| {
7105                match this.inner.channel().read_etc(cx, bytes, handles) {
7106                    std::task::Poll::Ready(Ok(())) => {}
7107                    std::task::Poll::Pending => return std::task::Poll::Pending,
7108                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
7109                        this.is_terminated = true;
7110                        return std::task::Poll::Ready(None);
7111                    }
7112                    std::task::Poll::Ready(Err(e)) => {
7113                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7114                            e.into(),
7115                        ))))
7116                    }
7117                }
7118
7119                // A message has been received from the channel
7120                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7121
7122                std::task::Poll::Ready(Some(match header.ordinal {
7123                    0x7fff4b8c733c7151 => {
7124                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7125                        let mut req = fidl::new_empty!(
7126                            RepositoryManagerAddRequest,
7127                            fidl::encoding::DefaultFuchsiaResourceDialect
7128                        );
7129                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RepositoryManagerAddRequest>(&header, _body_bytes, handles, &mut req)?;
7130                        let control_handle =
7131                            RepositoryManagerControlHandle { inner: this.inner.clone() };
7132                        Ok(RepositoryManagerRequest::Add {
7133                            repo: req.repo,
7134
7135                            responder: RepositoryManagerAddResponder {
7136                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7137                                tx_id: header.tx_id,
7138                            },
7139                        })
7140                    }
7141                    0x5de23dc0e0dea4ba => {
7142                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7143                        let mut req = fidl::new_empty!(
7144                            RepositoryManagerRemoveRequest,
7145                            fidl::encoding::DefaultFuchsiaResourceDialect
7146                        );
7147                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RepositoryManagerRemoveRequest>(&header, _body_bytes, handles, &mut req)?;
7148                        let control_handle =
7149                            RepositoryManagerControlHandle { inner: this.inner.clone() };
7150                        Ok(RepositoryManagerRequest::Remove {
7151                            repo_url: req.repo_url,
7152
7153                            responder: RepositoryManagerRemoveResponder {
7154                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7155                                tx_id: header.tx_id,
7156                            },
7157                        })
7158                    }
7159                    0x3b7ef213730dd24c => {
7160                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7161                        let mut req = fidl::new_empty!(
7162                            RepositoryManagerAddMirrorRequest,
7163                            fidl::encoding::DefaultFuchsiaResourceDialect
7164                        );
7165                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RepositoryManagerAddMirrorRequest>(&header, _body_bytes, handles, &mut req)?;
7166                        let control_handle =
7167                            RepositoryManagerControlHandle { inner: this.inner.clone() };
7168                        Ok(RepositoryManagerRequest::AddMirror {
7169                            repo_url: req.repo_url,
7170                            mirror: req.mirror,
7171
7172                            responder: RepositoryManagerAddMirrorResponder {
7173                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7174                                tx_id: header.tx_id,
7175                            },
7176                        })
7177                    }
7178                    0x4682584cc47c23a2 => {
7179                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7180                        let mut req = fidl::new_empty!(
7181                            RepositoryManagerRemoveMirrorRequest,
7182                            fidl::encoding::DefaultFuchsiaResourceDialect
7183                        );
7184                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RepositoryManagerRemoveMirrorRequest>(&header, _body_bytes, handles, &mut req)?;
7185                        let control_handle =
7186                            RepositoryManagerControlHandle { inner: this.inner.clone() };
7187                        Ok(RepositoryManagerRequest::RemoveMirror {
7188                            repo_url: req.repo_url,
7189                            mirror_url: req.mirror_url,
7190
7191                            responder: RepositoryManagerRemoveMirrorResponder {
7192                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7193                                tx_id: header.tx_id,
7194                            },
7195                        })
7196                    }
7197                    0x61837314ba6f4afb => {
7198                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7199                        let mut req = fidl::new_empty!(
7200                            RepositoryManagerListRequest,
7201                            fidl::encoding::DefaultFuchsiaResourceDialect
7202                        );
7203                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RepositoryManagerListRequest>(&header, _body_bytes, handles, &mut req)?;
7204                        let control_handle =
7205                            RepositoryManagerControlHandle { inner: this.inner.clone() };
7206                        Ok(RepositoryManagerRequest::List {
7207                            iterator: req.iterator,
7208
7209                            control_handle,
7210                        })
7211                    }
7212                    _ => Err(fidl::Error::UnknownOrdinal {
7213                        ordinal: header.ordinal,
7214                        protocol_name:
7215                            <RepositoryManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7216                    }),
7217                }))
7218            },
7219        )
7220    }
7221}
7222
7223/// This manages package repositories.
7224///
7225/// This is intended to be implemented by package resolver components, and used by
7226/// repository administration tools.
7227#[derive(Debug)]
7228pub enum RepositoryManagerRequest {
7229    /// Adds a repository. This will overwrite the repository if it already exists.
7230    ///
7231    /// + request `repo` a repository to add to the resolver.
7232    /// * error a zx_status value indicating failure. One of the following:
7233    ///     * `ZX_ERR_ACCESS_DENIED` if editing repositories is permanently disabled.
7234    ///     * `ZX_ERR_ALREADY_EXISTS` if the repository already exists.
7235    ///     * `ZX_ERR_INVALID_ARGS` if the repository is malformed.
7236    Add { repo: RepositoryConfig, responder: RepositoryManagerAddResponder },
7237    /// Removes a repository.
7238    ///
7239    /// Removing a repository will prevent future packages from being cached from this repository,
7240    /// but in-flight downloads may not be interrupted.
7241    ///
7242    /// + request `repo_url` the URL of the repository we want to remove.
7243    /// * error a zx_status value indicating failure. One of the following:
7244    ///     * `ZX_ERR_ACCESS_DENIED` if editing repositories is permanently disabled or the
7245    ///       `repo_url` matches a static repository.
7246    ///     * `ZX_ERR_INVALID_ARGS` if the `repo_url` is malformed.
7247    ///     * `ZX_ERR_NOT_FOUND` if the repository does not exist.
7248    Remove { repo_url: String, responder: RepositoryManagerRemoveResponder },
7249    /// Adds a mirror to a repository. This will overwrite the mirror if it already exists.
7250    ///
7251    /// + request `repo_url` the URL of the repository to add the mirror to.
7252    /// + request `mirror` the mirror config used to add the mirror.
7253    /// * error a zx_status value indicating failure. One of the following:
7254    ///     * `ZX_ERR_ALREADY_EXISTS` if the mirror for this repository already exists.
7255    ///     * `ZX_ERR_INVALID_ARGS` if the `repo_url` or the `mirror` is malformed.
7256    ///     * `ZX_ERR_NOT_FOUND` if the repository does not exist.
7257    AddMirror {
7258        repo_url: String,
7259        mirror: MirrorConfig,
7260        responder: RepositoryManagerAddMirrorResponder,
7261    },
7262    /// Removes a mirror from a repository.
7263    ///
7264    /// Removing a mirror will prevent future packages from being cached from that mirror, but
7265    /// in-flight downloads may not be interrupted.
7266    ///
7267    /// + request `repo_url` the URL of the mirror's repository.
7268    /// + request `mirror_url` the URL of the mirror we want to remove.
7269    /// * error a zx_status value indicating failure. One of the following:
7270    ///     * `ZX_ERR_INVALID_ARGS` if the `repo_url` or the `mirror_url` is malformed.
7271    ///     * `ZX_ERR_NOT_FOUND` if the repository or mirror does not exist.
7272    RemoveMirror {
7273        repo_url: String,
7274        mirror_url: String,
7275        responder: RepositoryManagerRemoveMirrorResponder,
7276    },
7277    /// Returns an iterator over all repositories.
7278    ///
7279    /// + request `iterator` a request for an iterator.
7280    List {
7281        iterator: fidl::endpoints::ServerEnd<RepositoryIteratorMarker>,
7282        control_handle: RepositoryManagerControlHandle,
7283    },
7284}
7285
7286impl RepositoryManagerRequest {
7287    #[allow(irrefutable_let_patterns)]
7288    pub fn into_add(self) -> Option<(RepositoryConfig, RepositoryManagerAddResponder)> {
7289        if let RepositoryManagerRequest::Add { repo, responder } = self {
7290            Some((repo, responder))
7291        } else {
7292            None
7293        }
7294    }
7295
7296    #[allow(irrefutable_let_patterns)]
7297    pub fn into_remove(self) -> Option<(String, RepositoryManagerRemoveResponder)> {
7298        if let RepositoryManagerRequest::Remove { repo_url, responder } = self {
7299            Some((repo_url, responder))
7300        } else {
7301            None
7302        }
7303    }
7304
7305    #[allow(irrefutable_let_patterns)]
7306    pub fn into_add_mirror(
7307        self,
7308    ) -> Option<(String, MirrorConfig, RepositoryManagerAddMirrorResponder)> {
7309        if let RepositoryManagerRequest::AddMirror { repo_url, mirror, responder } = self {
7310            Some((repo_url, mirror, responder))
7311        } else {
7312            None
7313        }
7314    }
7315
7316    #[allow(irrefutable_let_patterns)]
7317    pub fn into_remove_mirror(
7318        self,
7319    ) -> Option<(String, String, RepositoryManagerRemoveMirrorResponder)> {
7320        if let RepositoryManagerRequest::RemoveMirror { repo_url, mirror_url, responder } = self {
7321            Some((repo_url, mirror_url, responder))
7322        } else {
7323            None
7324        }
7325    }
7326
7327    #[allow(irrefutable_let_patterns)]
7328    pub fn into_list(
7329        self,
7330    ) -> Option<(
7331        fidl::endpoints::ServerEnd<RepositoryIteratorMarker>,
7332        RepositoryManagerControlHandle,
7333    )> {
7334        if let RepositoryManagerRequest::List { iterator, control_handle } = self {
7335            Some((iterator, control_handle))
7336        } else {
7337            None
7338        }
7339    }
7340
7341    /// Name of the method defined in FIDL
7342    pub fn method_name(&self) -> &'static str {
7343        match *self {
7344            RepositoryManagerRequest::Add { .. } => "add",
7345            RepositoryManagerRequest::Remove { .. } => "remove",
7346            RepositoryManagerRequest::AddMirror { .. } => "add_mirror",
7347            RepositoryManagerRequest::RemoveMirror { .. } => "remove_mirror",
7348            RepositoryManagerRequest::List { .. } => "list",
7349        }
7350    }
7351}
7352
7353#[derive(Debug, Clone)]
7354pub struct RepositoryManagerControlHandle {
7355    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7356}
7357
7358impl fidl::endpoints::ControlHandle for RepositoryManagerControlHandle {
7359    fn shutdown(&self) {
7360        self.inner.shutdown()
7361    }
7362    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
7363        self.inner.shutdown_with_epitaph(status)
7364    }
7365
7366    fn is_closed(&self) -> bool {
7367        self.inner.channel().is_closed()
7368    }
7369    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
7370        self.inner.channel().on_closed()
7371    }
7372
7373    #[cfg(target_os = "fuchsia")]
7374    fn signal_peer(
7375        &self,
7376        clear_mask: zx::Signals,
7377        set_mask: zx::Signals,
7378    ) -> Result<(), zx_status::Status> {
7379        use fidl::Peered;
7380        self.inner.channel().signal_peer(clear_mask, set_mask)
7381    }
7382}
7383
7384impl RepositoryManagerControlHandle {}
7385
7386#[must_use = "FIDL methods require a response to be sent"]
7387#[derive(Debug)]
7388pub struct RepositoryManagerAddResponder {
7389    control_handle: std::mem::ManuallyDrop<RepositoryManagerControlHandle>,
7390    tx_id: u32,
7391}
7392
7393/// Set the the channel to be shutdown (see [`RepositoryManagerControlHandle::shutdown`])
7394/// if the responder is dropped without sending a response, so that the client
7395/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7396impl std::ops::Drop for RepositoryManagerAddResponder {
7397    fn drop(&mut self) {
7398        self.control_handle.shutdown();
7399        // Safety: drops once, never accessed again
7400        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7401    }
7402}
7403
7404impl fidl::endpoints::Responder for RepositoryManagerAddResponder {
7405    type ControlHandle = RepositoryManagerControlHandle;
7406
7407    fn control_handle(&self) -> &RepositoryManagerControlHandle {
7408        &self.control_handle
7409    }
7410
7411    fn drop_without_shutdown(mut self) {
7412        // Safety: drops once, never accessed again due to mem::forget
7413        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7414        // Prevent Drop from running (which would shut down the channel)
7415        std::mem::forget(self);
7416    }
7417}
7418
7419impl RepositoryManagerAddResponder {
7420    /// Sends a response to the FIDL transaction.
7421    ///
7422    /// Sets the channel to shutdown if an error occurs.
7423    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
7424        let _result = self.send_raw(result);
7425        if _result.is_err() {
7426            self.control_handle.shutdown();
7427        }
7428        self.drop_without_shutdown();
7429        _result
7430    }
7431
7432    /// Similar to "send" but does not shutdown the channel if an error occurs.
7433    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
7434        let _result = self.send_raw(result);
7435        self.drop_without_shutdown();
7436        _result
7437    }
7438
7439    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
7440        self.control_handle
7441            .inner
7442            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
7443                result,
7444                self.tx_id,
7445                0x7fff4b8c733c7151,
7446                fidl::encoding::DynamicFlags::empty(),
7447            )
7448    }
7449}
7450
7451#[must_use = "FIDL methods require a response to be sent"]
7452#[derive(Debug)]
7453pub struct RepositoryManagerRemoveResponder {
7454    control_handle: std::mem::ManuallyDrop<RepositoryManagerControlHandle>,
7455    tx_id: u32,
7456}
7457
7458/// Set the the channel to be shutdown (see [`RepositoryManagerControlHandle::shutdown`])
7459/// if the responder is dropped without sending a response, so that the client
7460/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7461impl std::ops::Drop for RepositoryManagerRemoveResponder {
7462    fn drop(&mut self) {
7463        self.control_handle.shutdown();
7464        // Safety: drops once, never accessed again
7465        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7466    }
7467}
7468
7469impl fidl::endpoints::Responder for RepositoryManagerRemoveResponder {
7470    type ControlHandle = RepositoryManagerControlHandle;
7471
7472    fn control_handle(&self) -> &RepositoryManagerControlHandle {
7473        &self.control_handle
7474    }
7475
7476    fn drop_without_shutdown(mut self) {
7477        // Safety: drops once, never accessed again due to mem::forget
7478        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7479        // Prevent Drop from running (which would shut down the channel)
7480        std::mem::forget(self);
7481    }
7482}
7483
7484impl RepositoryManagerRemoveResponder {
7485    /// Sends a response to the FIDL transaction.
7486    ///
7487    /// Sets the channel to shutdown if an error occurs.
7488    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
7489        let _result = self.send_raw(result);
7490        if _result.is_err() {
7491            self.control_handle.shutdown();
7492        }
7493        self.drop_without_shutdown();
7494        _result
7495    }
7496
7497    /// Similar to "send" but does not shutdown the channel if an error occurs.
7498    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
7499        let _result = self.send_raw(result);
7500        self.drop_without_shutdown();
7501        _result
7502    }
7503
7504    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
7505        self.control_handle
7506            .inner
7507            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
7508                result,
7509                self.tx_id,
7510                0x5de23dc0e0dea4ba,
7511                fidl::encoding::DynamicFlags::empty(),
7512            )
7513    }
7514}
7515
7516#[must_use = "FIDL methods require a response to be sent"]
7517#[derive(Debug)]
7518pub struct RepositoryManagerAddMirrorResponder {
7519    control_handle: std::mem::ManuallyDrop<RepositoryManagerControlHandle>,
7520    tx_id: u32,
7521}
7522
7523/// Set the the channel to be shutdown (see [`RepositoryManagerControlHandle::shutdown`])
7524/// if the responder is dropped without sending a response, so that the client
7525/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7526impl std::ops::Drop for RepositoryManagerAddMirrorResponder {
7527    fn drop(&mut self) {
7528        self.control_handle.shutdown();
7529        // Safety: drops once, never accessed again
7530        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7531    }
7532}
7533
7534impl fidl::endpoints::Responder for RepositoryManagerAddMirrorResponder {
7535    type ControlHandle = RepositoryManagerControlHandle;
7536
7537    fn control_handle(&self) -> &RepositoryManagerControlHandle {
7538        &self.control_handle
7539    }
7540
7541    fn drop_without_shutdown(mut self) {
7542        // Safety: drops once, never accessed again due to mem::forget
7543        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7544        // Prevent Drop from running (which would shut down the channel)
7545        std::mem::forget(self);
7546    }
7547}
7548
7549impl RepositoryManagerAddMirrorResponder {
7550    /// Sends a response to the FIDL transaction.
7551    ///
7552    /// Sets the channel to shutdown if an error occurs.
7553    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
7554        let _result = self.send_raw(result);
7555        if _result.is_err() {
7556            self.control_handle.shutdown();
7557        }
7558        self.drop_without_shutdown();
7559        _result
7560    }
7561
7562    /// Similar to "send" but does not shutdown the channel if an error occurs.
7563    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
7564        let _result = self.send_raw(result);
7565        self.drop_without_shutdown();
7566        _result
7567    }
7568
7569    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
7570        self.control_handle
7571            .inner
7572            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
7573                result,
7574                self.tx_id,
7575                0x3b7ef213730dd24c,
7576                fidl::encoding::DynamicFlags::empty(),
7577            )
7578    }
7579}
7580
7581#[must_use = "FIDL methods require a response to be sent"]
7582#[derive(Debug)]
7583pub struct RepositoryManagerRemoveMirrorResponder {
7584    control_handle: std::mem::ManuallyDrop<RepositoryManagerControlHandle>,
7585    tx_id: u32,
7586}
7587
7588/// Set the the channel to be shutdown (see [`RepositoryManagerControlHandle::shutdown`])
7589/// if the responder is dropped without sending a response, so that the client
7590/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7591impl std::ops::Drop for RepositoryManagerRemoveMirrorResponder {
7592    fn drop(&mut self) {
7593        self.control_handle.shutdown();
7594        // Safety: drops once, never accessed again
7595        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7596    }
7597}
7598
7599impl fidl::endpoints::Responder for RepositoryManagerRemoveMirrorResponder {
7600    type ControlHandle = RepositoryManagerControlHandle;
7601
7602    fn control_handle(&self) -> &RepositoryManagerControlHandle {
7603        &self.control_handle
7604    }
7605
7606    fn drop_without_shutdown(mut self) {
7607        // Safety: drops once, never accessed again due to mem::forget
7608        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7609        // Prevent Drop from running (which would shut down the channel)
7610        std::mem::forget(self);
7611    }
7612}
7613
7614impl RepositoryManagerRemoveMirrorResponder {
7615    /// Sends a response to the FIDL transaction.
7616    ///
7617    /// Sets the channel to shutdown if an error occurs.
7618    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
7619        let _result = self.send_raw(result);
7620        if _result.is_err() {
7621            self.control_handle.shutdown();
7622        }
7623        self.drop_without_shutdown();
7624        _result
7625    }
7626
7627    /// Similar to "send" but does not shutdown the channel if an error occurs.
7628    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
7629        let _result = self.send_raw(result);
7630        self.drop_without_shutdown();
7631        _result
7632    }
7633
7634    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
7635        self.control_handle
7636            .inner
7637            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
7638                result,
7639                self.tx_id,
7640                0x4682584cc47c23a2,
7641                fidl::encoding::DynamicFlags::empty(),
7642            )
7643    }
7644}
7645
7646#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
7647pub struct RetainedPackagesMarker;
7648
7649impl fidl::endpoints::ProtocolMarker for RetainedPackagesMarker {
7650    type Proxy = RetainedPackagesProxy;
7651    type RequestStream = RetainedPackagesRequestStream;
7652    #[cfg(target_os = "fuchsia")]
7653    type SynchronousProxy = RetainedPackagesSynchronousProxy;
7654
7655    const DEBUG_NAME: &'static str = "fuchsia.pkg.RetainedPackages";
7656}
7657impl fidl::endpoints::DiscoverableProtocolMarker for RetainedPackagesMarker {}
7658
7659pub trait RetainedPackagesProxyInterface: Send + Sync {
7660    type ClearResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
7661    fn r#clear(&self) -> Self::ClearResponseFut;
7662    type ReplaceResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
7663    fn r#replace(
7664        &self,
7665        iterator: fidl::endpoints::ClientEnd<BlobIdIteratorMarker>,
7666    ) -> Self::ReplaceResponseFut;
7667}
7668#[derive(Debug)]
7669#[cfg(target_os = "fuchsia")]
7670pub struct RetainedPackagesSynchronousProxy {
7671    client: fidl::client::sync::Client,
7672}
7673
7674#[cfg(target_os = "fuchsia")]
7675impl fidl::endpoints::SynchronousProxy for RetainedPackagesSynchronousProxy {
7676    type Proxy = RetainedPackagesProxy;
7677    type Protocol = RetainedPackagesMarker;
7678
7679    fn from_channel(inner: fidl::Channel) -> Self {
7680        Self::new(inner)
7681    }
7682
7683    fn into_channel(self) -> fidl::Channel {
7684        self.client.into_channel()
7685    }
7686
7687    fn as_channel(&self) -> &fidl::Channel {
7688        self.client.as_channel()
7689    }
7690}
7691
7692#[cfg(target_os = "fuchsia")]
7693impl RetainedPackagesSynchronousProxy {
7694    pub fn new(channel: fidl::Channel) -> Self {
7695        let protocol_name = <RetainedPackagesMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7696        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
7697    }
7698
7699    pub fn into_channel(self) -> fidl::Channel {
7700        self.client.into_channel()
7701    }
7702
7703    /// Waits until an event arrives and returns it. It is safe for other
7704    /// threads to make concurrent requests while waiting for an event.
7705    pub fn wait_for_event(
7706        &self,
7707        deadline: zx::MonotonicInstant,
7708    ) -> Result<RetainedPackagesEvent, fidl::Error> {
7709        RetainedPackagesEvent::decode(self.client.wait_for_event(deadline)?)
7710    }
7711
7712    /// Atomically clear the retained package set, releasing any previously
7713    /// retained packages.
7714    pub fn r#clear(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
7715        let _response =
7716            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
7717                (),
7718                0x7f17476f097961ac,
7719                fidl::encoding::DynamicFlags::empty(),
7720                ___deadline,
7721            )?;
7722        Ok(_response)
7723    }
7724
7725    /// Atomically replace the retained package set with the [package hashes](
7726    /// https://fuchsia.dev/fuchsia-src/concepts/packages/package_url#package-hash)
7727    /// provided by the given iterator.
7728    /// Duplicate IDs provided will be merged and processed as a single one.
7729    ///
7730    /// + request `iterator` an iterator of package blob IDs that should be
7731    ///   retained.
7732    pub fn r#replace(
7733        &self,
7734        mut iterator: fidl::endpoints::ClientEnd<BlobIdIteratorMarker>,
7735        ___deadline: zx::MonotonicInstant,
7736    ) -> Result<(), fidl::Error> {
7737        let _response = self
7738            .client
7739            .send_query::<RetainedPackagesReplaceRequest, fidl::encoding::EmptyPayload>(
7740                (iterator,),
7741                0x5021e479570f3a9f,
7742                fidl::encoding::DynamicFlags::empty(),
7743                ___deadline,
7744            )?;
7745        Ok(_response)
7746    }
7747}
7748
7749#[cfg(target_os = "fuchsia")]
7750impl From<RetainedPackagesSynchronousProxy> for zx::Handle {
7751    fn from(value: RetainedPackagesSynchronousProxy) -> Self {
7752        value.into_channel().into()
7753    }
7754}
7755
7756#[cfg(target_os = "fuchsia")]
7757impl From<fidl::Channel> for RetainedPackagesSynchronousProxy {
7758    fn from(value: fidl::Channel) -> Self {
7759        Self::new(value)
7760    }
7761}
7762
7763#[derive(Debug, Clone)]
7764pub struct RetainedPackagesProxy {
7765    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
7766}
7767
7768impl fidl::endpoints::Proxy for RetainedPackagesProxy {
7769    type Protocol = RetainedPackagesMarker;
7770
7771    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
7772        Self::new(inner)
7773    }
7774
7775    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
7776        self.client.into_channel().map_err(|client| Self { client })
7777    }
7778
7779    fn as_channel(&self) -> &::fidl::AsyncChannel {
7780        self.client.as_channel()
7781    }
7782}
7783
7784impl RetainedPackagesProxy {
7785    /// Create a new Proxy for fuchsia.pkg/RetainedPackages.
7786    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
7787        let protocol_name = <RetainedPackagesMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7788        Self { client: fidl::client::Client::new(channel, protocol_name) }
7789    }
7790
7791    /// Get a Stream of events from the remote end of the protocol.
7792    ///
7793    /// # Panics
7794    ///
7795    /// Panics if the event stream was already taken.
7796    pub fn take_event_stream(&self) -> RetainedPackagesEventStream {
7797        RetainedPackagesEventStream { event_receiver: self.client.take_event_receiver() }
7798    }
7799
7800    /// Atomically clear the retained package set, releasing any previously
7801    /// retained packages.
7802    pub fn r#clear(
7803        &self,
7804    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
7805        RetainedPackagesProxyInterface::r#clear(self)
7806    }
7807
7808    /// Atomically replace the retained package set with the [package hashes](
7809    /// https://fuchsia.dev/fuchsia-src/concepts/packages/package_url#package-hash)
7810    /// provided by the given iterator.
7811    /// Duplicate IDs provided will be merged and processed as a single one.
7812    ///
7813    /// + request `iterator` an iterator of package blob IDs that should be
7814    ///   retained.
7815    pub fn r#replace(
7816        &self,
7817        mut iterator: fidl::endpoints::ClientEnd<BlobIdIteratorMarker>,
7818    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
7819        RetainedPackagesProxyInterface::r#replace(self, iterator)
7820    }
7821}
7822
7823impl RetainedPackagesProxyInterface for RetainedPackagesProxy {
7824    type ClearResponseFut =
7825        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
7826    fn r#clear(&self) -> Self::ClearResponseFut {
7827        fn _decode(
7828            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7829        ) -> Result<(), fidl::Error> {
7830            let _response = fidl::client::decode_transaction_body::<
7831                fidl::encoding::EmptyPayload,
7832                fidl::encoding::DefaultFuchsiaResourceDialect,
7833                0x7f17476f097961ac,
7834            >(_buf?)?;
7835            Ok(_response)
7836        }
7837        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
7838            (),
7839            0x7f17476f097961ac,
7840            fidl::encoding::DynamicFlags::empty(),
7841            _decode,
7842        )
7843    }
7844
7845    type ReplaceResponseFut =
7846        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
7847    fn r#replace(
7848        &self,
7849        mut iterator: fidl::endpoints::ClientEnd<BlobIdIteratorMarker>,
7850    ) -> Self::ReplaceResponseFut {
7851        fn _decode(
7852            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7853        ) -> Result<(), fidl::Error> {
7854            let _response = fidl::client::decode_transaction_body::<
7855                fidl::encoding::EmptyPayload,
7856                fidl::encoding::DefaultFuchsiaResourceDialect,
7857                0x5021e479570f3a9f,
7858            >(_buf?)?;
7859            Ok(_response)
7860        }
7861        self.client.send_query_and_decode::<RetainedPackagesReplaceRequest, ()>(
7862            (iterator,),
7863            0x5021e479570f3a9f,
7864            fidl::encoding::DynamicFlags::empty(),
7865            _decode,
7866        )
7867    }
7868}
7869
7870pub struct RetainedPackagesEventStream {
7871    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
7872}
7873
7874impl std::marker::Unpin for RetainedPackagesEventStream {}
7875
7876impl futures::stream::FusedStream for RetainedPackagesEventStream {
7877    fn is_terminated(&self) -> bool {
7878        self.event_receiver.is_terminated()
7879    }
7880}
7881
7882impl futures::Stream for RetainedPackagesEventStream {
7883    type Item = Result<RetainedPackagesEvent, fidl::Error>;
7884
7885    fn poll_next(
7886        mut self: std::pin::Pin<&mut Self>,
7887        cx: &mut std::task::Context<'_>,
7888    ) -> std::task::Poll<Option<Self::Item>> {
7889        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7890            &mut self.event_receiver,
7891            cx
7892        )?) {
7893            Some(buf) => std::task::Poll::Ready(Some(RetainedPackagesEvent::decode(buf))),
7894            None => std::task::Poll::Ready(None),
7895        }
7896    }
7897}
7898
7899#[derive(Debug)]
7900pub enum RetainedPackagesEvent {}
7901
7902impl RetainedPackagesEvent {
7903    /// Decodes a message buffer as a [`RetainedPackagesEvent`].
7904    fn decode(
7905        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7906    ) -> Result<RetainedPackagesEvent, fidl::Error> {
7907        let (bytes, _handles) = buf.split_mut();
7908        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7909        debug_assert_eq!(tx_header.tx_id, 0);
7910        match tx_header.ordinal {
7911            _ => Err(fidl::Error::UnknownOrdinal {
7912                ordinal: tx_header.ordinal,
7913                protocol_name:
7914                    <RetainedPackagesMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7915            }),
7916        }
7917    }
7918}
7919
7920/// A Stream of incoming requests for fuchsia.pkg/RetainedPackages.
7921pub struct RetainedPackagesRequestStream {
7922    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7923    is_terminated: bool,
7924}
7925
7926impl std::marker::Unpin for RetainedPackagesRequestStream {}
7927
7928impl futures::stream::FusedStream for RetainedPackagesRequestStream {
7929    fn is_terminated(&self) -> bool {
7930        self.is_terminated
7931    }
7932}
7933
7934impl fidl::endpoints::RequestStream for RetainedPackagesRequestStream {
7935    type Protocol = RetainedPackagesMarker;
7936    type ControlHandle = RetainedPackagesControlHandle;
7937
7938    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
7939        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7940    }
7941
7942    fn control_handle(&self) -> Self::ControlHandle {
7943        RetainedPackagesControlHandle { inner: self.inner.clone() }
7944    }
7945
7946    fn into_inner(
7947        self,
7948    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
7949    {
7950        (self.inner, self.is_terminated)
7951    }
7952
7953    fn from_inner(
7954        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7955        is_terminated: bool,
7956    ) -> Self {
7957        Self { inner, is_terminated }
7958    }
7959}
7960
7961impl futures::Stream for RetainedPackagesRequestStream {
7962    type Item = Result<RetainedPackagesRequest, fidl::Error>;
7963
7964    fn poll_next(
7965        mut self: std::pin::Pin<&mut Self>,
7966        cx: &mut std::task::Context<'_>,
7967    ) -> std::task::Poll<Option<Self::Item>> {
7968        let this = &mut *self;
7969        if this.inner.check_shutdown(cx) {
7970            this.is_terminated = true;
7971            return std::task::Poll::Ready(None);
7972        }
7973        if this.is_terminated {
7974            panic!("polled RetainedPackagesRequestStream after completion");
7975        }
7976        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
7977            |bytes, handles| {
7978                match this.inner.channel().read_etc(cx, bytes, handles) {
7979                    std::task::Poll::Ready(Ok(())) => {}
7980                    std::task::Poll::Pending => return std::task::Poll::Pending,
7981                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
7982                        this.is_terminated = true;
7983                        return std::task::Poll::Ready(None);
7984                    }
7985                    std::task::Poll::Ready(Err(e)) => {
7986                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7987                            e.into(),
7988                        ))))
7989                    }
7990                }
7991
7992                // A message has been received from the channel
7993                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7994
7995                std::task::Poll::Ready(Some(match header.ordinal {
7996                    0x7f17476f097961ac => {
7997                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7998                        let mut req = fidl::new_empty!(
7999                            fidl::encoding::EmptyPayload,
8000                            fidl::encoding::DefaultFuchsiaResourceDialect
8001                        );
8002                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
8003                        let control_handle =
8004                            RetainedPackagesControlHandle { inner: this.inner.clone() };
8005                        Ok(RetainedPackagesRequest::Clear {
8006                            responder: RetainedPackagesClearResponder {
8007                                control_handle: std::mem::ManuallyDrop::new(control_handle),
8008                                tx_id: header.tx_id,
8009                            },
8010                        })
8011                    }
8012                    0x5021e479570f3a9f => {
8013                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8014                        let mut req = fidl::new_empty!(
8015                            RetainedPackagesReplaceRequest,
8016                            fidl::encoding::DefaultFuchsiaResourceDialect
8017                        );
8018                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RetainedPackagesReplaceRequest>(&header, _body_bytes, handles, &mut req)?;
8019                        let control_handle =
8020                            RetainedPackagesControlHandle { inner: this.inner.clone() };
8021                        Ok(RetainedPackagesRequest::Replace {
8022                            iterator: req.iterator,
8023
8024                            responder: RetainedPackagesReplaceResponder {
8025                                control_handle: std::mem::ManuallyDrop::new(control_handle),
8026                                tx_id: header.tx_id,
8027                            },
8028                        })
8029                    }
8030                    _ => Err(fidl::Error::UnknownOrdinal {
8031                        ordinal: header.ordinal,
8032                        protocol_name:
8033                            <RetainedPackagesMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
8034                    }),
8035                }))
8036            },
8037        )
8038    }
8039}
8040
8041/// Manages the set of retained packages.
8042///
8043/// Retained packages will not be removed from the package cache, even if they
8044/// aren't fully present. There is only a single set active at once, and the
8045/// provided APIs for configuring the set atomically replace that set. On boot,
8046/// the retained package set is always initialized to the empty set.
8047/// Documentation on [garbage collection](
8048/// https://fuchsia.dev/fuchsia-src/concepts/packages/garbage_collection) contains
8049/// details on various types of package indexes (static, retained, etc) and
8050/// describes when a package will be garbage collected or retained.
8051#[derive(Debug)]
8052pub enum RetainedPackagesRequest {
8053    /// Atomically clear the retained package set, releasing any previously
8054    /// retained packages.
8055    Clear { responder: RetainedPackagesClearResponder },
8056    /// Atomically replace the retained package set with the [package hashes](
8057    /// https://fuchsia.dev/fuchsia-src/concepts/packages/package_url#package-hash)
8058    /// provided by the given iterator.
8059    /// Duplicate IDs provided will be merged and processed as a single one.
8060    ///
8061    /// + request `iterator` an iterator of package blob IDs that should be
8062    ///   retained.
8063    Replace {
8064        iterator: fidl::endpoints::ClientEnd<BlobIdIteratorMarker>,
8065        responder: RetainedPackagesReplaceResponder,
8066    },
8067}
8068
8069impl RetainedPackagesRequest {
8070    #[allow(irrefutable_let_patterns)]
8071    pub fn into_clear(self) -> Option<(RetainedPackagesClearResponder)> {
8072        if let RetainedPackagesRequest::Clear { responder } = self {
8073            Some((responder))
8074        } else {
8075            None
8076        }
8077    }
8078
8079    #[allow(irrefutable_let_patterns)]
8080    pub fn into_replace(
8081        self,
8082    ) -> Option<(fidl::endpoints::ClientEnd<BlobIdIteratorMarker>, RetainedPackagesReplaceResponder)>
8083    {
8084        if let RetainedPackagesRequest::Replace { iterator, responder } = self {
8085            Some((iterator, responder))
8086        } else {
8087            None
8088        }
8089    }
8090
8091    /// Name of the method defined in FIDL
8092    pub fn method_name(&self) -> &'static str {
8093        match *self {
8094            RetainedPackagesRequest::Clear { .. } => "clear",
8095            RetainedPackagesRequest::Replace { .. } => "replace",
8096        }
8097    }
8098}
8099
8100#[derive(Debug, Clone)]
8101pub struct RetainedPackagesControlHandle {
8102    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8103}
8104
8105impl fidl::endpoints::ControlHandle for RetainedPackagesControlHandle {
8106    fn shutdown(&self) {
8107        self.inner.shutdown()
8108    }
8109    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
8110        self.inner.shutdown_with_epitaph(status)
8111    }
8112
8113    fn is_closed(&self) -> bool {
8114        self.inner.channel().is_closed()
8115    }
8116    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
8117        self.inner.channel().on_closed()
8118    }
8119
8120    #[cfg(target_os = "fuchsia")]
8121    fn signal_peer(
8122        &self,
8123        clear_mask: zx::Signals,
8124        set_mask: zx::Signals,
8125    ) -> Result<(), zx_status::Status> {
8126        use fidl::Peered;
8127        self.inner.channel().signal_peer(clear_mask, set_mask)
8128    }
8129}
8130
8131impl RetainedPackagesControlHandle {}
8132
8133#[must_use = "FIDL methods require a response to be sent"]
8134#[derive(Debug)]
8135pub struct RetainedPackagesClearResponder {
8136    control_handle: std::mem::ManuallyDrop<RetainedPackagesControlHandle>,
8137    tx_id: u32,
8138}
8139
8140/// Set the the channel to be shutdown (see [`RetainedPackagesControlHandle::shutdown`])
8141/// if the responder is dropped without sending a response, so that the client
8142/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8143impl std::ops::Drop for RetainedPackagesClearResponder {
8144    fn drop(&mut self) {
8145        self.control_handle.shutdown();
8146        // Safety: drops once, never accessed again
8147        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8148    }
8149}
8150
8151impl fidl::endpoints::Responder for RetainedPackagesClearResponder {
8152    type ControlHandle = RetainedPackagesControlHandle;
8153
8154    fn control_handle(&self) -> &RetainedPackagesControlHandle {
8155        &self.control_handle
8156    }
8157
8158    fn drop_without_shutdown(mut self) {
8159        // Safety: drops once, never accessed again due to mem::forget
8160        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8161        // Prevent Drop from running (which would shut down the channel)
8162        std::mem::forget(self);
8163    }
8164}
8165
8166impl RetainedPackagesClearResponder {
8167    /// Sends a response to the FIDL transaction.
8168    ///
8169    /// Sets the channel to shutdown if an error occurs.
8170    pub fn send(self) -> Result<(), fidl::Error> {
8171        let _result = self.send_raw();
8172        if _result.is_err() {
8173            self.control_handle.shutdown();
8174        }
8175        self.drop_without_shutdown();
8176        _result
8177    }
8178
8179    /// Similar to "send" but does not shutdown the channel if an error occurs.
8180    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
8181        let _result = self.send_raw();
8182        self.drop_without_shutdown();
8183        _result
8184    }
8185
8186    fn send_raw(&self) -> Result<(), fidl::Error> {
8187        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
8188            (),
8189            self.tx_id,
8190            0x7f17476f097961ac,
8191            fidl::encoding::DynamicFlags::empty(),
8192        )
8193    }
8194}
8195
8196#[must_use = "FIDL methods require a response to be sent"]
8197#[derive(Debug)]
8198pub struct RetainedPackagesReplaceResponder {
8199    control_handle: std::mem::ManuallyDrop<RetainedPackagesControlHandle>,
8200    tx_id: u32,
8201}
8202
8203/// Set the the channel to be shutdown (see [`RetainedPackagesControlHandle::shutdown`])
8204/// if the responder is dropped without sending a response, so that the client
8205/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8206impl std::ops::Drop for RetainedPackagesReplaceResponder {
8207    fn drop(&mut self) {
8208        self.control_handle.shutdown();
8209        // Safety: drops once, never accessed again
8210        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8211    }
8212}
8213
8214impl fidl::endpoints::Responder for RetainedPackagesReplaceResponder {
8215    type ControlHandle = RetainedPackagesControlHandle;
8216
8217    fn control_handle(&self) -> &RetainedPackagesControlHandle {
8218        &self.control_handle
8219    }
8220
8221    fn drop_without_shutdown(mut self) {
8222        // Safety: drops once, never accessed again due to mem::forget
8223        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8224        // Prevent Drop from running (which would shut down the channel)
8225        std::mem::forget(self);
8226    }
8227}
8228
8229impl RetainedPackagesReplaceResponder {
8230    /// Sends a response to the FIDL transaction.
8231    ///
8232    /// Sets the channel to shutdown if an error occurs.
8233    pub fn send(self) -> Result<(), fidl::Error> {
8234        let _result = self.send_raw();
8235        if _result.is_err() {
8236            self.control_handle.shutdown();
8237        }
8238        self.drop_without_shutdown();
8239        _result
8240    }
8241
8242    /// Similar to "send" but does not shutdown the channel if an error occurs.
8243    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
8244        let _result = self.send_raw();
8245        self.drop_without_shutdown();
8246        _result
8247    }
8248
8249    fn send_raw(&self) -> Result<(), fidl::Error> {
8250        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
8251            (),
8252            self.tx_id,
8253            0x5021e479570f3a9f,
8254            fidl::encoding::DynamicFlags::empty(),
8255        )
8256    }
8257}
8258
8259mod internal {
8260    use super::*;
8261
8262    impl fidl::encoding::ResourceTypeMarker for FontResolverResolveRequest {
8263        type Borrowed<'a> = &'a mut Self;
8264        fn take_or_borrow<'a>(
8265            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8266        ) -> Self::Borrowed<'a> {
8267            value
8268        }
8269    }
8270
8271    unsafe impl fidl::encoding::TypeMarker for FontResolverResolveRequest {
8272        type Owned = Self;
8273
8274        #[inline(always)]
8275        fn inline_align(_context: fidl::encoding::Context) -> usize {
8276            8
8277        }
8278
8279        #[inline(always)]
8280        fn inline_size(_context: fidl::encoding::Context) -> usize {
8281            24
8282        }
8283    }
8284
8285    unsafe impl
8286        fidl::encoding::Encode<
8287            FontResolverResolveRequest,
8288            fidl::encoding::DefaultFuchsiaResourceDialect,
8289        > for &mut FontResolverResolveRequest
8290    {
8291        #[inline]
8292        unsafe fn encode(
8293            self,
8294            encoder: &mut fidl::encoding::Encoder<
8295                '_,
8296                fidl::encoding::DefaultFuchsiaResourceDialect,
8297            >,
8298            offset: usize,
8299            _depth: fidl::encoding::Depth,
8300        ) -> fidl::Result<()> {
8301            encoder.debug_check_bounds::<FontResolverResolveRequest>(offset);
8302            // Delegate to tuple encoding.
8303            fidl::encoding::Encode::<
8304                FontResolverResolveRequest,
8305                fidl::encoding::DefaultFuchsiaResourceDialect,
8306            >::encode(
8307                (
8308                    <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(
8309                        &self.package_url,
8310                    ),
8311                    <fidl::encoding::Endpoint<
8312                        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
8313                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
8314                        &mut self.directory_request,
8315                    ),
8316                ),
8317                encoder,
8318                offset,
8319                _depth,
8320            )
8321        }
8322    }
8323    unsafe impl<
8324            T0: fidl::encoding::Encode<
8325                fidl::encoding::UnboundedString,
8326                fidl::encoding::DefaultFuchsiaResourceDialect,
8327            >,
8328            T1: fidl::encoding::Encode<
8329                fidl::encoding::Endpoint<
8330                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
8331                >,
8332                fidl::encoding::DefaultFuchsiaResourceDialect,
8333            >,
8334        >
8335        fidl::encoding::Encode<
8336            FontResolverResolveRequest,
8337            fidl::encoding::DefaultFuchsiaResourceDialect,
8338        > for (T0, T1)
8339    {
8340        #[inline]
8341        unsafe fn encode(
8342            self,
8343            encoder: &mut fidl::encoding::Encoder<
8344                '_,
8345                fidl::encoding::DefaultFuchsiaResourceDialect,
8346            >,
8347            offset: usize,
8348            depth: fidl::encoding::Depth,
8349        ) -> fidl::Result<()> {
8350            encoder.debug_check_bounds::<FontResolverResolveRequest>(offset);
8351            // Zero out padding regions. There's no need to apply masks
8352            // because the unmasked parts will be overwritten by fields.
8353            unsafe {
8354                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
8355                (ptr as *mut u64).write_unaligned(0);
8356            }
8357            // Write the fields.
8358            self.0.encode(encoder, offset + 0, depth)?;
8359            self.1.encode(encoder, offset + 16, depth)?;
8360            Ok(())
8361        }
8362    }
8363
8364    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8365        for FontResolverResolveRequest
8366    {
8367        #[inline(always)]
8368        fn new_empty() -> Self {
8369            Self {
8370                package_url: fidl::new_empty!(
8371                    fidl::encoding::UnboundedString,
8372                    fidl::encoding::DefaultFuchsiaResourceDialect
8373                ),
8374                directory_request: fidl::new_empty!(
8375                    fidl::encoding::Endpoint<
8376                        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
8377                    >,
8378                    fidl::encoding::DefaultFuchsiaResourceDialect
8379                ),
8380            }
8381        }
8382
8383        #[inline]
8384        unsafe fn decode(
8385            &mut self,
8386            decoder: &mut fidl::encoding::Decoder<
8387                '_,
8388                fidl::encoding::DefaultFuchsiaResourceDialect,
8389            >,
8390            offset: usize,
8391            _depth: fidl::encoding::Depth,
8392        ) -> fidl::Result<()> {
8393            decoder.debug_check_bounds::<Self>(offset);
8394            // Verify that padding bytes are zero.
8395            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
8396            let padval = unsafe { (ptr as *const u64).read_unaligned() };
8397            let mask = 0xffffffff00000000u64;
8398            let maskedval = padval & mask;
8399            if maskedval != 0 {
8400                return Err(fidl::Error::NonZeroPadding {
8401                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
8402                });
8403            }
8404            fidl::decode!(
8405                fidl::encoding::UnboundedString,
8406                fidl::encoding::DefaultFuchsiaResourceDialect,
8407                &mut self.package_url,
8408                decoder,
8409                offset + 0,
8410                _depth
8411            )?;
8412            fidl::decode!(
8413                fidl::encoding::Endpoint<
8414                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
8415                >,
8416                fidl::encoding::DefaultFuchsiaResourceDialect,
8417                &mut self.directory_request,
8418                decoder,
8419                offset + 16,
8420                _depth
8421            )?;
8422            Ok(())
8423        }
8424    }
8425
8426    impl fidl::encoding::ResourceTypeMarker for NeededBlobsGetMissingBlobsRequest {
8427        type Borrowed<'a> = &'a mut Self;
8428        fn take_or_borrow<'a>(
8429            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8430        ) -> Self::Borrowed<'a> {
8431            value
8432        }
8433    }
8434
8435    unsafe impl fidl::encoding::TypeMarker for NeededBlobsGetMissingBlobsRequest {
8436        type Owned = Self;
8437
8438        #[inline(always)]
8439        fn inline_align(_context: fidl::encoding::Context) -> usize {
8440            4
8441        }
8442
8443        #[inline(always)]
8444        fn inline_size(_context: fidl::encoding::Context) -> usize {
8445            4
8446        }
8447    }
8448
8449    unsafe impl
8450        fidl::encoding::Encode<
8451            NeededBlobsGetMissingBlobsRequest,
8452            fidl::encoding::DefaultFuchsiaResourceDialect,
8453        > for &mut NeededBlobsGetMissingBlobsRequest
8454    {
8455        #[inline]
8456        unsafe fn encode(
8457            self,
8458            encoder: &mut fidl::encoding::Encoder<
8459                '_,
8460                fidl::encoding::DefaultFuchsiaResourceDialect,
8461            >,
8462            offset: usize,
8463            _depth: fidl::encoding::Depth,
8464        ) -> fidl::Result<()> {
8465            encoder.debug_check_bounds::<NeededBlobsGetMissingBlobsRequest>(offset);
8466            // Delegate to tuple encoding.
8467            fidl::encoding::Encode::<NeededBlobsGetMissingBlobsRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
8468                (
8469                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BlobInfoIteratorMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.iterator),
8470                ),
8471                encoder, offset, _depth
8472            )
8473        }
8474    }
8475    unsafe impl<
8476            T0: fidl::encoding::Encode<
8477                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BlobInfoIteratorMarker>>,
8478                fidl::encoding::DefaultFuchsiaResourceDialect,
8479            >,
8480        >
8481        fidl::encoding::Encode<
8482            NeededBlobsGetMissingBlobsRequest,
8483            fidl::encoding::DefaultFuchsiaResourceDialect,
8484        > for (T0,)
8485    {
8486        #[inline]
8487        unsafe fn encode(
8488            self,
8489            encoder: &mut fidl::encoding::Encoder<
8490                '_,
8491                fidl::encoding::DefaultFuchsiaResourceDialect,
8492            >,
8493            offset: usize,
8494            depth: fidl::encoding::Depth,
8495        ) -> fidl::Result<()> {
8496            encoder.debug_check_bounds::<NeededBlobsGetMissingBlobsRequest>(offset);
8497            // Zero out padding regions. There's no need to apply masks
8498            // because the unmasked parts will be overwritten by fields.
8499            // Write the fields.
8500            self.0.encode(encoder, offset + 0, depth)?;
8501            Ok(())
8502        }
8503    }
8504
8505    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8506        for NeededBlobsGetMissingBlobsRequest
8507    {
8508        #[inline(always)]
8509        fn new_empty() -> Self {
8510            Self {
8511                iterator: fidl::new_empty!(
8512                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BlobInfoIteratorMarker>>,
8513                    fidl::encoding::DefaultFuchsiaResourceDialect
8514                ),
8515            }
8516        }
8517
8518        #[inline]
8519        unsafe fn decode(
8520            &mut self,
8521            decoder: &mut fidl::encoding::Decoder<
8522                '_,
8523                fidl::encoding::DefaultFuchsiaResourceDialect,
8524            >,
8525            offset: usize,
8526            _depth: fidl::encoding::Depth,
8527        ) -> fidl::Result<()> {
8528            decoder.debug_check_bounds::<Self>(offset);
8529            // Verify that padding bytes are zero.
8530            fidl::decode!(
8531                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BlobInfoIteratorMarker>>,
8532                fidl::encoding::DefaultFuchsiaResourceDialect,
8533                &mut self.iterator,
8534                decoder,
8535                offset + 0,
8536                _depth
8537            )?;
8538            Ok(())
8539        }
8540    }
8541
8542    impl fidl::encoding::ResourceTypeMarker for NeededBlobsOpenBlobResponse {
8543        type Borrowed<'a> = &'a mut Self;
8544        fn take_or_borrow<'a>(
8545            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8546        ) -> Self::Borrowed<'a> {
8547            value
8548        }
8549    }
8550
8551    unsafe impl fidl::encoding::TypeMarker for NeededBlobsOpenBlobResponse {
8552        type Owned = Self;
8553
8554        #[inline(always)]
8555        fn inline_align(_context: fidl::encoding::Context) -> usize {
8556            8
8557        }
8558
8559        #[inline(always)]
8560        fn inline_size(_context: fidl::encoding::Context) -> usize {
8561            16
8562        }
8563    }
8564
8565    unsafe impl
8566        fidl::encoding::Encode<
8567            NeededBlobsOpenBlobResponse,
8568            fidl::encoding::DefaultFuchsiaResourceDialect,
8569        > for &mut NeededBlobsOpenBlobResponse
8570    {
8571        #[inline]
8572        unsafe fn encode(
8573            self,
8574            encoder: &mut fidl::encoding::Encoder<
8575                '_,
8576                fidl::encoding::DefaultFuchsiaResourceDialect,
8577            >,
8578            offset: usize,
8579            _depth: fidl::encoding::Depth,
8580        ) -> fidl::Result<()> {
8581            encoder.debug_check_bounds::<NeededBlobsOpenBlobResponse>(offset);
8582            // Delegate to tuple encoding.
8583            fidl::encoding::Encode::<NeededBlobsOpenBlobResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
8584                (
8585                    <fidl::encoding::OptionalUnion<BlobWriter> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.writer),
8586                ),
8587                encoder, offset, _depth
8588            )
8589        }
8590    }
8591    unsafe impl<
8592            T0: fidl::encoding::Encode<
8593                fidl::encoding::OptionalUnion<BlobWriter>,
8594                fidl::encoding::DefaultFuchsiaResourceDialect,
8595            >,
8596        >
8597        fidl::encoding::Encode<
8598            NeededBlobsOpenBlobResponse,
8599            fidl::encoding::DefaultFuchsiaResourceDialect,
8600        > for (T0,)
8601    {
8602        #[inline]
8603        unsafe fn encode(
8604            self,
8605            encoder: &mut fidl::encoding::Encoder<
8606                '_,
8607                fidl::encoding::DefaultFuchsiaResourceDialect,
8608            >,
8609            offset: usize,
8610            depth: fidl::encoding::Depth,
8611        ) -> fidl::Result<()> {
8612            encoder.debug_check_bounds::<NeededBlobsOpenBlobResponse>(offset);
8613            // Zero out padding regions. There's no need to apply masks
8614            // because the unmasked parts will be overwritten by fields.
8615            // Write the fields.
8616            self.0.encode(encoder, offset + 0, depth)?;
8617            Ok(())
8618        }
8619    }
8620
8621    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8622        for NeededBlobsOpenBlobResponse
8623    {
8624        #[inline(always)]
8625        fn new_empty() -> Self {
8626            Self {
8627                writer: fidl::new_empty!(
8628                    fidl::encoding::OptionalUnion<BlobWriter>,
8629                    fidl::encoding::DefaultFuchsiaResourceDialect
8630                ),
8631            }
8632        }
8633
8634        #[inline]
8635        unsafe fn decode(
8636            &mut self,
8637            decoder: &mut fidl::encoding::Decoder<
8638                '_,
8639                fidl::encoding::DefaultFuchsiaResourceDialect,
8640            >,
8641            offset: usize,
8642            _depth: fidl::encoding::Depth,
8643        ) -> fidl::Result<()> {
8644            decoder.debug_check_bounds::<Self>(offset);
8645            // Verify that padding bytes are zero.
8646            fidl::decode!(
8647                fidl::encoding::OptionalUnion<BlobWriter>,
8648                fidl::encoding::DefaultFuchsiaResourceDialect,
8649                &mut self.writer,
8650                decoder,
8651                offset + 0,
8652                _depth
8653            )?;
8654            Ok(())
8655        }
8656    }
8657
8658    impl fidl::encoding::ResourceTypeMarker for NeededBlobsOpenMetaBlobResponse {
8659        type Borrowed<'a> = &'a mut Self;
8660        fn take_or_borrow<'a>(
8661            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8662        ) -> Self::Borrowed<'a> {
8663            value
8664        }
8665    }
8666
8667    unsafe impl fidl::encoding::TypeMarker for NeededBlobsOpenMetaBlobResponse {
8668        type Owned = Self;
8669
8670        #[inline(always)]
8671        fn inline_align(_context: fidl::encoding::Context) -> usize {
8672            8
8673        }
8674
8675        #[inline(always)]
8676        fn inline_size(_context: fidl::encoding::Context) -> usize {
8677            16
8678        }
8679    }
8680
8681    unsafe impl
8682        fidl::encoding::Encode<
8683            NeededBlobsOpenMetaBlobResponse,
8684            fidl::encoding::DefaultFuchsiaResourceDialect,
8685        > for &mut NeededBlobsOpenMetaBlobResponse
8686    {
8687        #[inline]
8688        unsafe fn encode(
8689            self,
8690            encoder: &mut fidl::encoding::Encoder<
8691                '_,
8692                fidl::encoding::DefaultFuchsiaResourceDialect,
8693            >,
8694            offset: usize,
8695            _depth: fidl::encoding::Depth,
8696        ) -> fidl::Result<()> {
8697            encoder.debug_check_bounds::<NeededBlobsOpenMetaBlobResponse>(offset);
8698            // Delegate to tuple encoding.
8699            fidl::encoding::Encode::<NeededBlobsOpenMetaBlobResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
8700                (
8701                    <fidl::encoding::OptionalUnion<BlobWriter> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.writer),
8702                ),
8703                encoder, offset, _depth
8704            )
8705        }
8706    }
8707    unsafe impl<
8708            T0: fidl::encoding::Encode<
8709                fidl::encoding::OptionalUnion<BlobWriter>,
8710                fidl::encoding::DefaultFuchsiaResourceDialect,
8711            >,
8712        >
8713        fidl::encoding::Encode<
8714            NeededBlobsOpenMetaBlobResponse,
8715            fidl::encoding::DefaultFuchsiaResourceDialect,
8716        > for (T0,)
8717    {
8718        #[inline]
8719        unsafe fn encode(
8720            self,
8721            encoder: &mut fidl::encoding::Encoder<
8722                '_,
8723                fidl::encoding::DefaultFuchsiaResourceDialect,
8724            >,
8725            offset: usize,
8726            depth: fidl::encoding::Depth,
8727        ) -> fidl::Result<()> {
8728            encoder.debug_check_bounds::<NeededBlobsOpenMetaBlobResponse>(offset);
8729            // Zero out padding regions. There's no need to apply masks
8730            // because the unmasked parts will be overwritten by fields.
8731            // Write the fields.
8732            self.0.encode(encoder, offset + 0, depth)?;
8733            Ok(())
8734        }
8735    }
8736
8737    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8738        for NeededBlobsOpenMetaBlobResponse
8739    {
8740        #[inline(always)]
8741        fn new_empty() -> Self {
8742            Self {
8743                writer: fidl::new_empty!(
8744                    fidl::encoding::OptionalUnion<BlobWriter>,
8745                    fidl::encoding::DefaultFuchsiaResourceDialect
8746                ),
8747            }
8748        }
8749
8750        #[inline]
8751        unsafe fn decode(
8752            &mut self,
8753            decoder: &mut fidl::encoding::Decoder<
8754                '_,
8755                fidl::encoding::DefaultFuchsiaResourceDialect,
8756            >,
8757            offset: usize,
8758            _depth: fidl::encoding::Depth,
8759        ) -> fidl::Result<()> {
8760            decoder.debug_check_bounds::<Self>(offset);
8761            // Verify that padding bytes are zero.
8762            fidl::decode!(
8763                fidl::encoding::OptionalUnion<BlobWriter>,
8764                fidl::encoding::DefaultFuchsiaResourceDialect,
8765                &mut self.writer,
8766                decoder,
8767                offset + 0,
8768                _depth
8769            )?;
8770            Ok(())
8771        }
8772    }
8773
8774    impl fidl::encoding::ResourceTypeMarker for PackageCacheBasePackageIndexRequest {
8775        type Borrowed<'a> = &'a mut Self;
8776        fn take_or_borrow<'a>(
8777            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8778        ) -> Self::Borrowed<'a> {
8779            value
8780        }
8781    }
8782
8783    unsafe impl fidl::encoding::TypeMarker for PackageCacheBasePackageIndexRequest {
8784        type Owned = Self;
8785
8786        #[inline(always)]
8787        fn inline_align(_context: fidl::encoding::Context) -> usize {
8788            4
8789        }
8790
8791        #[inline(always)]
8792        fn inline_size(_context: fidl::encoding::Context) -> usize {
8793            4
8794        }
8795    }
8796
8797    unsafe impl
8798        fidl::encoding::Encode<
8799            PackageCacheBasePackageIndexRequest,
8800            fidl::encoding::DefaultFuchsiaResourceDialect,
8801        > for &mut PackageCacheBasePackageIndexRequest
8802    {
8803        #[inline]
8804        unsafe fn encode(
8805            self,
8806            encoder: &mut fidl::encoding::Encoder<
8807                '_,
8808                fidl::encoding::DefaultFuchsiaResourceDialect,
8809            >,
8810            offset: usize,
8811            _depth: fidl::encoding::Depth,
8812        ) -> fidl::Result<()> {
8813            encoder.debug_check_bounds::<PackageCacheBasePackageIndexRequest>(offset);
8814            // Delegate to tuple encoding.
8815            fidl::encoding::Encode::<
8816                PackageCacheBasePackageIndexRequest,
8817                fidl::encoding::DefaultFuchsiaResourceDialect,
8818            >::encode(
8819                (
8820                    <fidl::encoding::Endpoint<
8821                        fidl::endpoints::ServerEnd<PackageIndexIteratorMarker>,
8822                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
8823                        &mut self.iterator
8824                    ),
8825                ),
8826                encoder,
8827                offset,
8828                _depth,
8829            )
8830        }
8831    }
8832    unsafe impl<
8833            T0: fidl::encoding::Encode<
8834                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PackageIndexIteratorMarker>>,
8835                fidl::encoding::DefaultFuchsiaResourceDialect,
8836            >,
8837        >
8838        fidl::encoding::Encode<
8839            PackageCacheBasePackageIndexRequest,
8840            fidl::encoding::DefaultFuchsiaResourceDialect,
8841        > for (T0,)
8842    {
8843        #[inline]
8844        unsafe fn encode(
8845            self,
8846            encoder: &mut fidl::encoding::Encoder<
8847                '_,
8848                fidl::encoding::DefaultFuchsiaResourceDialect,
8849            >,
8850            offset: usize,
8851            depth: fidl::encoding::Depth,
8852        ) -> fidl::Result<()> {
8853            encoder.debug_check_bounds::<PackageCacheBasePackageIndexRequest>(offset);
8854            // Zero out padding regions. There's no need to apply masks
8855            // because the unmasked parts will be overwritten by fields.
8856            // Write the fields.
8857            self.0.encode(encoder, offset + 0, depth)?;
8858            Ok(())
8859        }
8860    }
8861
8862    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8863        for PackageCacheBasePackageIndexRequest
8864    {
8865        #[inline(always)]
8866        fn new_empty() -> Self {
8867            Self {
8868                iterator: fidl::new_empty!(
8869                    fidl::encoding::Endpoint<
8870                        fidl::endpoints::ServerEnd<PackageIndexIteratorMarker>,
8871                    >,
8872                    fidl::encoding::DefaultFuchsiaResourceDialect
8873                ),
8874            }
8875        }
8876
8877        #[inline]
8878        unsafe fn decode(
8879            &mut self,
8880            decoder: &mut fidl::encoding::Decoder<
8881                '_,
8882                fidl::encoding::DefaultFuchsiaResourceDialect,
8883            >,
8884            offset: usize,
8885            _depth: fidl::encoding::Depth,
8886        ) -> fidl::Result<()> {
8887            decoder.debug_check_bounds::<Self>(offset);
8888            // Verify that padding bytes are zero.
8889            fidl::decode!(
8890                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PackageIndexIteratorMarker>>,
8891                fidl::encoding::DefaultFuchsiaResourceDialect,
8892                &mut self.iterator,
8893                decoder,
8894                offset + 0,
8895                _depth
8896            )?;
8897            Ok(())
8898        }
8899    }
8900
8901    impl fidl::encoding::ResourceTypeMarker for PackageCacheCachePackageIndexRequest {
8902        type Borrowed<'a> = &'a mut Self;
8903        fn take_or_borrow<'a>(
8904            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8905        ) -> Self::Borrowed<'a> {
8906            value
8907        }
8908    }
8909
8910    unsafe impl fidl::encoding::TypeMarker for PackageCacheCachePackageIndexRequest {
8911        type Owned = Self;
8912
8913        #[inline(always)]
8914        fn inline_align(_context: fidl::encoding::Context) -> usize {
8915            4
8916        }
8917
8918        #[inline(always)]
8919        fn inline_size(_context: fidl::encoding::Context) -> usize {
8920            4
8921        }
8922    }
8923
8924    unsafe impl
8925        fidl::encoding::Encode<
8926            PackageCacheCachePackageIndexRequest,
8927            fidl::encoding::DefaultFuchsiaResourceDialect,
8928        > for &mut PackageCacheCachePackageIndexRequest
8929    {
8930        #[inline]
8931        unsafe fn encode(
8932            self,
8933            encoder: &mut fidl::encoding::Encoder<
8934                '_,
8935                fidl::encoding::DefaultFuchsiaResourceDialect,
8936            >,
8937            offset: usize,
8938            _depth: fidl::encoding::Depth,
8939        ) -> fidl::Result<()> {
8940            encoder.debug_check_bounds::<PackageCacheCachePackageIndexRequest>(offset);
8941            // Delegate to tuple encoding.
8942            fidl::encoding::Encode::<
8943                PackageCacheCachePackageIndexRequest,
8944                fidl::encoding::DefaultFuchsiaResourceDialect,
8945            >::encode(
8946                (
8947                    <fidl::encoding::Endpoint<
8948                        fidl::endpoints::ServerEnd<PackageIndexIteratorMarker>,
8949                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
8950                        &mut self.iterator
8951                    ),
8952                ),
8953                encoder,
8954                offset,
8955                _depth,
8956            )
8957        }
8958    }
8959    unsafe impl<
8960            T0: fidl::encoding::Encode<
8961                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PackageIndexIteratorMarker>>,
8962                fidl::encoding::DefaultFuchsiaResourceDialect,
8963            >,
8964        >
8965        fidl::encoding::Encode<
8966            PackageCacheCachePackageIndexRequest,
8967            fidl::encoding::DefaultFuchsiaResourceDialect,
8968        > for (T0,)
8969    {
8970        #[inline]
8971        unsafe fn encode(
8972            self,
8973            encoder: &mut fidl::encoding::Encoder<
8974                '_,
8975                fidl::encoding::DefaultFuchsiaResourceDialect,
8976            >,
8977            offset: usize,
8978            depth: fidl::encoding::Depth,
8979        ) -> fidl::Result<()> {
8980            encoder.debug_check_bounds::<PackageCacheCachePackageIndexRequest>(offset);
8981            // Zero out padding regions. There's no need to apply masks
8982            // because the unmasked parts will be overwritten by fields.
8983            // Write the fields.
8984            self.0.encode(encoder, offset + 0, depth)?;
8985            Ok(())
8986        }
8987    }
8988
8989    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8990        for PackageCacheCachePackageIndexRequest
8991    {
8992        #[inline(always)]
8993        fn new_empty() -> Self {
8994            Self {
8995                iterator: fidl::new_empty!(
8996                    fidl::encoding::Endpoint<
8997                        fidl::endpoints::ServerEnd<PackageIndexIteratorMarker>,
8998                    >,
8999                    fidl::encoding::DefaultFuchsiaResourceDialect
9000                ),
9001            }
9002        }
9003
9004        #[inline]
9005        unsafe fn decode(
9006            &mut self,
9007            decoder: &mut fidl::encoding::Decoder<
9008                '_,
9009                fidl::encoding::DefaultFuchsiaResourceDialect,
9010            >,
9011            offset: usize,
9012            _depth: fidl::encoding::Depth,
9013        ) -> fidl::Result<()> {
9014            decoder.debug_check_bounds::<Self>(offset);
9015            // Verify that padding bytes are zero.
9016            fidl::decode!(
9017                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PackageIndexIteratorMarker>>,
9018                fidl::encoding::DefaultFuchsiaResourceDialect,
9019                &mut self.iterator,
9020                decoder,
9021                offset + 0,
9022                _depth
9023            )?;
9024            Ok(())
9025        }
9026    }
9027
9028    impl fidl::encoding::ResourceTypeMarker for PackageCacheGetRequest {
9029        type Borrowed<'a> = &'a mut Self;
9030        fn take_or_borrow<'a>(
9031            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9032        ) -> Self::Borrowed<'a> {
9033            value
9034        }
9035    }
9036
9037    unsafe impl fidl::encoding::TypeMarker for PackageCacheGetRequest {
9038        type Owned = Self;
9039
9040        #[inline(always)]
9041        fn inline_align(_context: fidl::encoding::Context) -> usize {
9042            8
9043        }
9044
9045        #[inline(always)]
9046        fn inline_size(_context: fidl::encoding::Context) -> usize {
9047            56
9048        }
9049    }
9050
9051    unsafe impl
9052        fidl::encoding::Encode<
9053            PackageCacheGetRequest,
9054            fidl::encoding::DefaultFuchsiaResourceDialect,
9055        > for &mut PackageCacheGetRequest
9056    {
9057        #[inline]
9058        unsafe fn encode(
9059            self,
9060            encoder: &mut fidl::encoding::Encoder<
9061                '_,
9062                fidl::encoding::DefaultFuchsiaResourceDialect,
9063            >,
9064            offset: usize,
9065            _depth: fidl::encoding::Depth,
9066        ) -> fidl::Result<()> {
9067            encoder.debug_check_bounds::<PackageCacheGetRequest>(offset);
9068            // Delegate to tuple encoding.
9069            fidl::encoding::Encode::<PackageCacheGetRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9070                (
9071                    <BlobInfo as fidl::encoding::ValueTypeMarker>::borrow(&self.meta_far_blob),
9072                    <GcProtection as fidl::encoding::ValueTypeMarker>::borrow(&self.gc_protection),
9073                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NeededBlobsMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.needed_blobs),
9074                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.dir),
9075                ),
9076                encoder, offset, _depth
9077            )
9078        }
9079    }
9080    unsafe impl<
9081            T0: fidl::encoding::Encode<BlobInfo, fidl::encoding::DefaultFuchsiaResourceDialect>,
9082            T1: fidl::encoding::Encode<GcProtection, fidl::encoding::DefaultFuchsiaResourceDialect>,
9083            T2: fidl::encoding::Encode<
9084                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NeededBlobsMarker>>,
9085                fidl::encoding::DefaultFuchsiaResourceDialect,
9086            >,
9087            T3: fidl::encoding::Encode<
9088                fidl::encoding::Endpoint<
9089                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
9090                >,
9091                fidl::encoding::DefaultFuchsiaResourceDialect,
9092            >,
9093        >
9094        fidl::encoding::Encode<
9095            PackageCacheGetRequest,
9096            fidl::encoding::DefaultFuchsiaResourceDialect,
9097        > for (T0, T1, T2, T3)
9098    {
9099        #[inline]
9100        unsafe fn encode(
9101            self,
9102            encoder: &mut fidl::encoding::Encoder<
9103                '_,
9104                fidl::encoding::DefaultFuchsiaResourceDialect,
9105            >,
9106            offset: usize,
9107            depth: fidl::encoding::Depth,
9108        ) -> fidl::Result<()> {
9109            encoder.debug_check_bounds::<PackageCacheGetRequest>(offset);
9110            // Zero out padding regions. There's no need to apply masks
9111            // because the unmasked parts will be overwritten by fields.
9112            unsafe {
9113                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(48);
9114                (ptr as *mut u64).write_unaligned(0);
9115            }
9116            // Write the fields.
9117            self.0.encode(encoder, offset + 0, depth)?;
9118            self.1.encode(encoder, offset + 40, depth)?;
9119            self.2.encode(encoder, offset + 44, depth)?;
9120            self.3.encode(encoder, offset + 48, depth)?;
9121            Ok(())
9122        }
9123    }
9124
9125    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9126        for PackageCacheGetRequest
9127    {
9128        #[inline(always)]
9129        fn new_empty() -> Self {
9130            Self {
9131                meta_far_blob: fidl::new_empty!(
9132                    BlobInfo,
9133                    fidl::encoding::DefaultFuchsiaResourceDialect
9134                ),
9135                gc_protection: fidl::new_empty!(
9136                    GcProtection,
9137                    fidl::encoding::DefaultFuchsiaResourceDialect
9138                ),
9139                needed_blobs: fidl::new_empty!(
9140                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NeededBlobsMarker>>,
9141                    fidl::encoding::DefaultFuchsiaResourceDialect
9142                ),
9143                dir: fidl::new_empty!(
9144                    fidl::encoding::Endpoint<
9145                        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
9146                    >,
9147                    fidl::encoding::DefaultFuchsiaResourceDialect
9148                ),
9149            }
9150        }
9151
9152        #[inline]
9153        unsafe fn decode(
9154            &mut self,
9155            decoder: &mut fidl::encoding::Decoder<
9156                '_,
9157                fidl::encoding::DefaultFuchsiaResourceDialect,
9158            >,
9159            offset: usize,
9160            _depth: fidl::encoding::Depth,
9161        ) -> fidl::Result<()> {
9162            decoder.debug_check_bounds::<Self>(offset);
9163            // Verify that padding bytes are zero.
9164            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(48) };
9165            let padval = unsafe { (ptr as *const u64).read_unaligned() };
9166            let mask = 0xffffffff00000000u64;
9167            let maskedval = padval & mask;
9168            if maskedval != 0 {
9169                return Err(fidl::Error::NonZeroPadding {
9170                    padding_start: offset + 48 + ((mask as u64).trailing_zeros() / 8) as usize,
9171                });
9172            }
9173            fidl::decode!(
9174                BlobInfo,
9175                fidl::encoding::DefaultFuchsiaResourceDialect,
9176                &mut self.meta_far_blob,
9177                decoder,
9178                offset + 0,
9179                _depth
9180            )?;
9181            fidl::decode!(
9182                GcProtection,
9183                fidl::encoding::DefaultFuchsiaResourceDialect,
9184                &mut self.gc_protection,
9185                decoder,
9186                offset + 40,
9187                _depth
9188            )?;
9189            fidl::decode!(
9190                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NeededBlobsMarker>>,
9191                fidl::encoding::DefaultFuchsiaResourceDialect,
9192                &mut self.needed_blobs,
9193                decoder,
9194                offset + 44,
9195                _depth
9196            )?;
9197            fidl::decode!(
9198                fidl::encoding::Endpoint<
9199                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
9200                >,
9201                fidl::encoding::DefaultFuchsiaResourceDialect,
9202                &mut self.dir,
9203                decoder,
9204                offset + 48,
9205                _depth
9206            )?;
9207            Ok(())
9208        }
9209    }
9210
9211    impl fidl::encoding::ResourceTypeMarker for PackageCacheGetSubpackageRequest {
9212        type Borrowed<'a> = &'a mut Self;
9213        fn take_or_borrow<'a>(
9214            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9215        ) -> Self::Borrowed<'a> {
9216            value
9217        }
9218    }
9219
9220    unsafe impl fidl::encoding::TypeMarker for PackageCacheGetSubpackageRequest {
9221        type Owned = Self;
9222
9223        #[inline(always)]
9224        fn inline_align(_context: fidl::encoding::Context) -> usize {
9225            8
9226        }
9227
9228        #[inline(always)]
9229        fn inline_size(_context: fidl::encoding::Context) -> usize {
9230            56
9231        }
9232    }
9233
9234    unsafe impl
9235        fidl::encoding::Encode<
9236            PackageCacheGetSubpackageRequest,
9237            fidl::encoding::DefaultFuchsiaResourceDialect,
9238        > for &mut PackageCacheGetSubpackageRequest
9239    {
9240        #[inline]
9241        unsafe fn encode(
9242            self,
9243            encoder: &mut fidl::encoding::Encoder<
9244                '_,
9245                fidl::encoding::DefaultFuchsiaResourceDialect,
9246            >,
9247            offset: usize,
9248            _depth: fidl::encoding::Depth,
9249        ) -> fidl::Result<()> {
9250            encoder.debug_check_bounds::<PackageCacheGetSubpackageRequest>(offset);
9251            // Delegate to tuple encoding.
9252            fidl::encoding::Encode::<
9253                PackageCacheGetSubpackageRequest,
9254                fidl::encoding::DefaultFuchsiaResourceDialect,
9255            >::encode(
9256                (
9257                    <BlobId as fidl::encoding::ValueTypeMarker>::borrow(&self.superpackage),
9258                    <PackageUrl as fidl::encoding::ValueTypeMarker>::borrow(&self.subpackage),
9259                    <fidl::encoding::Endpoint<
9260                        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
9261                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
9262                        &mut self.dir
9263                    ),
9264                ),
9265                encoder,
9266                offset,
9267                _depth,
9268            )
9269        }
9270    }
9271    unsafe impl<
9272            T0: fidl::encoding::Encode<BlobId, fidl::encoding::DefaultFuchsiaResourceDialect>,
9273            T1: fidl::encoding::Encode<PackageUrl, fidl::encoding::DefaultFuchsiaResourceDialect>,
9274            T2: fidl::encoding::Encode<
9275                fidl::encoding::Endpoint<
9276                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
9277                >,
9278                fidl::encoding::DefaultFuchsiaResourceDialect,
9279            >,
9280        >
9281        fidl::encoding::Encode<
9282            PackageCacheGetSubpackageRequest,
9283            fidl::encoding::DefaultFuchsiaResourceDialect,
9284        > for (T0, T1, T2)
9285    {
9286        #[inline]
9287        unsafe fn encode(
9288            self,
9289            encoder: &mut fidl::encoding::Encoder<
9290                '_,
9291                fidl::encoding::DefaultFuchsiaResourceDialect,
9292            >,
9293            offset: usize,
9294            depth: fidl::encoding::Depth,
9295        ) -> fidl::Result<()> {
9296            encoder.debug_check_bounds::<PackageCacheGetSubpackageRequest>(offset);
9297            // Zero out padding regions. There's no need to apply masks
9298            // because the unmasked parts will be overwritten by fields.
9299            unsafe {
9300                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(48);
9301                (ptr as *mut u64).write_unaligned(0);
9302            }
9303            // Write the fields.
9304            self.0.encode(encoder, offset + 0, depth)?;
9305            self.1.encode(encoder, offset + 32, depth)?;
9306            self.2.encode(encoder, offset + 48, depth)?;
9307            Ok(())
9308        }
9309    }
9310
9311    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9312        for PackageCacheGetSubpackageRequest
9313    {
9314        #[inline(always)]
9315        fn new_empty() -> Self {
9316            Self {
9317                superpackage: fidl::new_empty!(
9318                    BlobId,
9319                    fidl::encoding::DefaultFuchsiaResourceDialect
9320                ),
9321                subpackage: fidl::new_empty!(
9322                    PackageUrl,
9323                    fidl::encoding::DefaultFuchsiaResourceDialect
9324                ),
9325                dir: fidl::new_empty!(
9326                    fidl::encoding::Endpoint<
9327                        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
9328                    >,
9329                    fidl::encoding::DefaultFuchsiaResourceDialect
9330                ),
9331            }
9332        }
9333
9334        #[inline]
9335        unsafe fn decode(
9336            &mut self,
9337            decoder: &mut fidl::encoding::Decoder<
9338                '_,
9339                fidl::encoding::DefaultFuchsiaResourceDialect,
9340            >,
9341            offset: usize,
9342            _depth: fidl::encoding::Depth,
9343        ) -> fidl::Result<()> {
9344            decoder.debug_check_bounds::<Self>(offset);
9345            // Verify that padding bytes are zero.
9346            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(48) };
9347            let padval = unsafe { (ptr as *const u64).read_unaligned() };
9348            let mask = 0xffffffff00000000u64;
9349            let maskedval = padval & mask;
9350            if maskedval != 0 {
9351                return Err(fidl::Error::NonZeroPadding {
9352                    padding_start: offset + 48 + ((mask as u64).trailing_zeros() / 8) as usize,
9353                });
9354            }
9355            fidl::decode!(
9356                BlobId,
9357                fidl::encoding::DefaultFuchsiaResourceDialect,
9358                &mut self.superpackage,
9359                decoder,
9360                offset + 0,
9361                _depth
9362            )?;
9363            fidl::decode!(
9364                PackageUrl,
9365                fidl::encoding::DefaultFuchsiaResourceDialect,
9366                &mut self.subpackage,
9367                decoder,
9368                offset + 32,
9369                _depth
9370            )?;
9371            fidl::decode!(
9372                fidl::encoding::Endpoint<
9373                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
9374                >,
9375                fidl::encoding::DefaultFuchsiaResourceDialect,
9376                &mut self.dir,
9377                decoder,
9378                offset + 48,
9379                _depth
9380            )?;
9381            Ok(())
9382        }
9383    }
9384
9385    impl fidl::encoding::ResourceTypeMarker for PackageResolverResolveRequest {
9386        type Borrowed<'a> = &'a mut Self;
9387        fn take_or_borrow<'a>(
9388            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9389        ) -> Self::Borrowed<'a> {
9390            value
9391        }
9392    }
9393
9394    unsafe impl fidl::encoding::TypeMarker for PackageResolverResolveRequest {
9395        type Owned = Self;
9396
9397        #[inline(always)]
9398        fn inline_align(_context: fidl::encoding::Context) -> usize {
9399            8
9400        }
9401
9402        #[inline(always)]
9403        fn inline_size(_context: fidl::encoding::Context) -> usize {
9404            24
9405        }
9406    }
9407
9408    unsafe impl
9409        fidl::encoding::Encode<
9410            PackageResolverResolveRequest,
9411            fidl::encoding::DefaultFuchsiaResourceDialect,
9412        > for &mut PackageResolverResolveRequest
9413    {
9414        #[inline]
9415        unsafe fn encode(
9416            self,
9417            encoder: &mut fidl::encoding::Encoder<
9418                '_,
9419                fidl::encoding::DefaultFuchsiaResourceDialect,
9420            >,
9421            offset: usize,
9422            _depth: fidl::encoding::Depth,
9423        ) -> fidl::Result<()> {
9424            encoder.debug_check_bounds::<PackageResolverResolveRequest>(offset);
9425            // Delegate to tuple encoding.
9426            fidl::encoding::Encode::<
9427                PackageResolverResolveRequest,
9428                fidl::encoding::DefaultFuchsiaResourceDialect,
9429            >::encode(
9430                (
9431                    <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(
9432                        &self.package_url,
9433                    ),
9434                    <fidl::encoding::Endpoint<
9435                        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
9436                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
9437                        &mut self.dir
9438                    ),
9439                ),
9440                encoder,
9441                offset,
9442                _depth,
9443            )
9444        }
9445    }
9446    unsafe impl<
9447            T0: fidl::encoding::Encode<
9448                fidl::encoding::UnboundedString,
9449                fidl::encoding::DefaultFuchsiaResourceDialect,
9450            >,
9451            T1: fidl::encoding::Encode<
9452                fidl::encoding::Endpoint<
9453                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
9454                >,
9455                fidl::encoding::DefaultFuchsiaResourceDialect,
9456            >,
9457        >
9458        fidl::encoding::Encode<
9459            PackageResolverResolveRequest,
9460            fidl::encoding::DefaultFuchsiaResourceDialect,
9461        > for (T0, T1)
9462    {
9463        #[inline]
9464        unsafe fn encode(
9465            self,
9466            encoder: &mut fidl::encoding::Encoder<
9467                '_,
9468                fidl::encoding::DefaultFuchsiaResourceDialect,
9469            >,
9470            offset: usize,
9471            depth: fidl::encoding::Depth,
9472        ) -> fidl::Result<()> {
9473            encoder.debug_check_bounds::<PackageResolverResolveRequest>(offset);
9474            // Zero out padding regions. There's no need to apply masks
9475            // because the unmasked parts will be overwritten by fields.
9476            unsafe {
9477                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
9478                (ptr as *mut u64).write_unaligned(0);
9479            }
9480            // Write the fields.
9481            self.0.encode(encoder, offset + 0, depth)?;
9482            self.1.encode(encoder, offset + 16, depth)?;
9483            Ok(())
9484        }
9485    }
9486
9487    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9488        for PackageResolverResolveRequest
9489    {
9490        #[inline(always)]
9491        fn new_empty() -> Self {
9492            Self {
9493                package_url: fidl::new_empty!(
9494                    fidl::encoding::UnboundedString,
9495                    fidl::encoding::DefaultFuchsiaResourceDialect
9496                ),
9497                dir: fidl::new_empty!(
9498                    fidl::encoding::Endpoint<
9499                        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
9500                    >,
9501                    fidl::encoding::DefaultFuchsiaResourceDialect
9502                ),
9503            }
9504        }
9505
9506        #[inline]
9507        unsafe fn decode(
9508            &mut self,
9509            decoder: &mut fidl::encoding::Decoder<
9510                '_,
9511                fidl::encoding::DefaultFuchsiaResourceDialect,
9512            >,
9513            offset: usize,
9514            _depth: fidl::encoding::Depth,
9515        ) -> fidl::Result<()> {
9516            decoder.debug_check_bounds::<Self>(offset);
9517            // Verify that padding bytes are zero.
9518            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
9519            let padval = unsafe { (ptr as *const u64).read_unaligned() };
9520            let mask = 0xffffffff00000000u64;
9521            let maskedval = padval & mask;
9522            if maskedval != 0 {
9523                return Err(fidl::Error::NonZeroPadding {
9524                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
9525                });
9526            }
9527            fidl::decode!(
9528                fidl::encoding::UnboundedString,
9529                fidl::encoding::DefaultFuchsiaResourceDialect,
9530                &mut self.package_url,
9531                decoder,
9532                offset + 0,
9533                _depth
9534            )?;
9535            fidl::decode!(
9536                fidl::encoding::Endpoint<
9537                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
9538                >,
9539                fidl::encoding::DefaultFuchsiaResourceDialect,
9540                &mut self.dir,
9541                decoder,
9542                offset + 16,
9543                _depth
9544            )?;
9545            Ok(())
9546        }
9547    }
9548
9549    impl fidl::encoding::ResourceTypeMarker for PackageResolverResolveWithContextRequest {
9550        type Borrowed<'a> = &'a mut Self;
9551        fn take_or_borrow<'a>(
9552            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9553        ) -> Self::Borrowed<'a> {
9554            value
9555        }
9556    }
9557
9558    unsafe impl fidl::encoding::TypeMarker for PackageResolverResolveWithContextRequest {
9559        type Owned = Self;
9560
9561        #[inline(always)]
9562        fn inline_align(_context: fidl::encoding::Context) -> usize {
9563            8
9564        }
9565
9566        #[inline(always)]
9567        fn inline_size(_context: fidl::encoding::Context) -> usize {
9568            40
9569        }
9570    }
9571
9572    unsafe impl
9573        fidl::encoding::Encode<
9574            PackageResolverResolveWithContextRequest,
9575            fidl::encoding::DefaultFuchsiaResourceDialect,
9576        > for &mut PackageResolverResolveWithContextRequest
9577    {
9578        #[inline]
9579        unsafe fn encode(
9580            self,
9581            encoder: &mut fidl::encoding::Encoder<
9582                '_,
9583                fidl::encoding::DefaultFuchsiaResourceDialect,
9584            >,
9585            offset: usize,
9586            _depth: fidl::encoding::Depth,
9587        ) -> fidl::Result<()> {
9588            encoder.debug_check_bounds::<PackageResolverResolveWithContextRequest>(offset);
9589            // Delegate to tuple encoding.
9590            fidl::encoding::Encode::<
9591                PackageResolverResolveWithContextRequest,
9592                fidl::encoding::DefaultFuchsiaResourceDialect,
9593            >::encode(
9594                (
9595                    <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(
9596                        &self.package_url,
9597                    ),
9598                    <ResolutionContext as fidl::encoding::ValueTypeMarker>::borrow(&self.context),
9599                    <fidl::encoding::Endpoint<
9600                        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
9601                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
9602                        &mut self.dir
9603                    ),
9604                ),
9605                encoder,
9606                offset,
9607                _depth,
9608            )
9609        }
9610    }
9611    unsafe impl<
9612            T0: fidl::encoding::Encode<
9613                fidl::encoding::UnboundedString,
9614                fidl::encoding::DefaultFuchsiaResourceDialect,
9615            >,
9616            T1: fidl::encoding::Encode<
9617                ResolutionContext,
9618                fidl::encoding::DefaultFuchsiaResourceDialect,
9619            >,
9620            T2: fidl::encoding::Encode<
9621                fidl::encoding::Endpoint<
9622                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
9623                >,
9624                fidl::encoding::DefaultFuchsiaResourceDialect,
9625            >,
9626        >
9627        fidl::encoding::Encode<
9628            PackageResolverResolveWithContextRequest,
9629            fidl::encoding::DefaultFuchsiaResourceDialect,
9630        > for (T0, T1, T2)
9631    {
9632        #[inline]
9633        unsafe fn encode(
9634            self,
9635            encoder: &mut fidl::encoding::Encoder<
9636                '_,
9637                fidl::encoding::DefaultFuchsiaResourceDialect,
9638            >,
9639            offset: usize,
9640            depth: fidl::encoding::Depth,
9641        ) -> fidl::Result<()> {
9642            encoder.debug_check_bounds::<PackageResolverResolveWithContextRequest>(offset);
9643            // Zero out padding regions. There's no need to apply masks
9644            // because the unmasked parts will be overwritten by fields.
9645            unsafe {
9646                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
9647                (ptr as *mut u64).write_unaligned(0);
9648            }
9649            // Write the fields.
9650            self.0.encode(encoder, offset + 0, depth)?;
9651            self.1.encode(encoder, offset + 16, depth)?;
9652            self.2.encode(encoder, offset + 32, depth)?;
9653            Ok(())
9654        }
9655    }
9656
9657    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9658        for PackageResolverResolveWithContextRequest
9659    {
9660        #[inline(always)]
9661        fn new_empty() -> Self {
9662            Self {
9663                package_url: fidl::new_empty!(
9664                    fidl::encoding::UnboundedString,
9665                    fidl::encoding::DefaultFuchsiaResourceDialect
9666                ),
9667                context: fidl::new_empty!(
9668                    ResolutionContext,
9669                    fidl::encoding::DefaultFuchsiaResourceDialect
9670                ),
9671                dir: fidl::new_empty!(
9672                    fidl::encoding::Endpoint<
9673                        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
9674                    >,
9675                    fidl::encoding::DefaultFuchsiaResourceDialect
9676                ),
9677            }
9678        }
9679
9680        #[inline]
9681        unsafe fn decode(
9682            &mut self,
9683            decoder: &mut fidl::encoding::Decoder<
9684                '_,
9685                fidl::encoding::DefaultFuchsiaResourceDialect,
9686            >,
9687            offset: usize,
9688            _depth: fidl::encoding::Depth,
9689        ) -> fidl::Result<()> {
9690            decoder.debug_check_bounds::<Self>(offset);
9691            // Verify that padding bytes are zero.
9692            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
9693            let padval = unsafe { (ptr as *const u64).read_unaligned() };
9694            let mask = 0xffffffff00000000u64;
9695            let maskedval = padval & mask;
9696            if maskedval != 0 {
9697                return Err(fidl::Error::NonZeroPadding {
9698                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
9699                });
9700            }
9701            fidl::decode!(
9702                fidl::encoding::UnboundedString,
9703                fidl::encoding::DefaultFuchsiaResourceDialect,
9704                &mut self.package_url,
9705                decoder,
9706                offset + 0,
9707                _depth
9708            )?;
9709            fidl::decode!(
9710                ResolutionContext,
9711                fidl::encoding::DefaultFuchsiaResourceDialect,
9712                &mut self.context,
9713                decoder,
9714                offset + 16,
9715                _depth
9716            )?;
9717            fidl::decode!(
9718                fidl::encoding::Endpoint<
9719                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
9720                >,
9721                fidl::encoding::DefaultFuchsiaResourceDialect,
9722                &mut self.dir,
9723                decoder,
9724                offset + 32,
9725                _depth
9726            )?;
9727            Ok(())
9728        }
9729    }
9730
9731    impl fidl::encoding::ResourceTypeMarker for RepositoryManagerListRequest {
9732        type Borrowed<'a> = &'a mut Self;
9733        fn take_or_borrow<'a>(
9734            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9735        ) -> Self::Borrowed<'a> {
9736            value
9737        }
9738    }
9739
9740    unsafe impl fidl::encoding::TypeMarker for RepositoryManagerListRequest {
9741        type Owned = Self;
9742
9743        #[inline(always)]
9744        fn inline_align(_context: fidl::encoding::Context) -> usize {
9745            4
9746        }
9747
9748        #[inline(always)]
9749        fn inline_size(_context: fidl::encoding::Context) -> usize {
9750            4
9751        }
9752    }
9753
9754    unsafe impl
9755        fidl::encoding::Encode<
9756            RepositoryManagerListRequest,
9757            fidl::encoding::DefaultFuchsiaResourceDialect,
9758        > for &mut RepositoryManagerListRequest
9759    {
9760        #[inline]
9761        unsafe fn encode(
9762            self,
9763            encoder: &mut fidl::encoding::Encoder<
9764                '_,
9765                fidl::encoding::DefaultFuchsiaResourceDialect,
9766            >,
9767            offset: usize,
9768            _depth: fidl::encoding::Depth,
9769        ) -> fidl::Result<()> {
9770            encoder.debug_check_bounds::<RepositoryManagerListRequest>(offset);
9771            // Delegate to tuple encoding.
9772            fidl::encoding::Encode::<RepositoryManagerListRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9773                (
9774                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RepositoryIteratorMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.iterator),
9775                ),
9776                encoder, offset, _depth
9777            )
9778        }
9779    }
9780    unsafe impl<
9781            T0: fidl::encoding::Encode<
9782                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RepositoryIteratorMarker>>,
9783                fidl::encoding::DefaultFuchsiaResourceDialect,
9784            >,
9785        >
9786        fidl::encoding::Encode<
9787            RepositoryManagerListRequest,
9788            fidl::encoding::DefaultFuchsiaResourceDialect,
9789        > for (T0,)
9790    {
9791        #[inline]
9792        unsafe fn encode(
9793            self,
9794            encoder: &mut fidl::encoding::Encoder<
9795                '_,
9796                fidl::encoding::DefaultFuchsiaResourceDialect,
9797            >,
9798            offset: usize,
9799            depth: fidl::encoding::Depth,
9800        ) -> fidl::Result<()> {
9801            encoder.debug_check_bounds::<RepositoryManagerListRequest>(offset);
9802            // Zero out padding regions. There's no need to apply masks
9803            // because the unmasked parts will be overwritten by fields.
9804            // Write the fields.
9805            self.0.encode(encoder, offset + 0, depth)?;
9806            Ok(())
9807        }
9808    }
9809
9810    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9811        for RepositoryManagerListRequest
9812    {
9813        #[inline(always)]
9814        fn new_empty() -> Self {
9815            Self {
9816                iterator: fidl::new_empty!(
9817                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RepositoryIteratorMarker>>,
9818                    fidl::encoding::DefaultFuchsiaResourceDialect
9819                ),
9820            }
9821        }
9822
9823        #[inline]
9824        unsafe fn decode(
9825            &mut self,
9826            decoder: &mut fidl::encoding::Decoder<
9827                '_,
9828                fidl::encoding::DefaultFuchsiaResourceDialect,
9829            >,
9830            offset: usize,
9831            _depth: fidl::encoding::Depth,
9832        ) -> fidl::Result<()> {
9833            decoder.debug_check_bounds::<Self>(offset);
9834            // Verify that padding bytes are zero.
9835            fidl::decode!(
9836                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RepositoryIteratorMarker>>,
9837                fidl::encoding::DefaultFuchsiaResourceDialect,
9838                &mut self.iterator,
9839                decoder,
9840                offset + 0,
9841                _depth
9842            )?;
9843            Ok(())
9844        }
9845    }
9846
9847    impl fidl::encoding::ResourceTypeMarker for RetainedPackagesReplaceRequest {
9848        type Borrowed<'a> = &'a mut Self;
9849        fn take_or_borrow<'a>(
9850            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9851        ) -> Self::Borrowed<'a> {
9852            value
9853        }
9854    }
9855
9856    unsafe impl fidl::encoding::TypeMarker for RetainedPackagesReplaceRequest {
9857        type Owned = Self;
9858
9859        #[inline(always)]
9860        fn inline_align(_context: fidl::encoding::Context) -> usize {
9861            4
9862        }
9863
9864        #[inline(always)]
9865        fn inline_size(_context: fidl::encoding::Context) -> usize {
9866            4
9867        }
9868    }
9869
9870    unsafe impl
9871        fidl::encoding::Encode<
9872            RetainedPackagesReplaceRequest,
9873            fidl::encoding::DefaultFuchsiaResourceDialect,
9874        > for &mut RetainedPackagesReplaceRequest
9875    {
9876        #[inline]
9877        unsafe fn encode(
9878            self,
9879            encoder: &mut fidl::encoding::Encoder<
9880                '_,
9881                fidl::encoding::DefaultFuchsiaResourceDialect,
9882            >,
9883            offset: usize,
9884            _depth: fidl::encoding::Depth,
9885        ) -> fidl::Result<()> {
9886            encoder.debug_check_bounds::<RetainedPackagesReplaceRequest>(offset);
9887            // Delegate to tuple encoding.
9888            fidl::encoding::Encode::<RetainedPackagesReplaceRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9889                (
9890                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<BlobIdIteratorMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.iterator),
9891                ),
9892                encoder, offset, _depth
9893            )
9894        }
9895    }
9896    unsafe impl<
9897            T0: fidl::encoding::Encode<
9898                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<BlobIdIteratorMarker>>,
9899                fidl::encoding::DefaultFuchsiaResourceDialect,
9900            >,
9901        >
9902        fidl::encoding::Encode<
9903            RetainedPackagesReplaceRequest,
9904            fidl::encoding::DefaultFuchsiaResourceDialect,
9905        > for (T0,)
9906    {
9907        #[inline]
9908        unsafe fn encode(
9909            self,
9910            encoder: &mut fidl::encoding::Encoder<
9911                '_,
9912                fidl::encoding::DefaultFuchsiaResourceDialect,
9913            >,
9914            offset: usize,
9915            depth: fidl::encoding::Depth,
9916        ) -> fidl::Result<()> {
9917            encoder.debug_check_bounds::<RetainedPackagesReplaceRequest>(offset);
9918            // Zero out padding regions. There's no need to apply masks
9919            // because the unmasked parts will be overwritten by fields.
9920            // Write the fields.
9921            self.0.encode(encoder, offset + 0, depth)?;
9922            Ok(())
9923        }
9924    }
9925
9926    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9927        for RetainedPackagesReplaceRequest
9928    {
9929        #[inline(always)]
9930        fn new_empty() -> Self {
9931            Self {
9932                iterator: fidl::new_empty!(
9933                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<BlobIdIteratorMarker>>,
9934                    fidl::encoding::DefaultFuchsiaResourceDialect
9935                ),
9936            }
9937        }
9938
9939        #[inline]
9940        unsafe fn decode(
9941            &mut self,
9942            decoder: &mut fidl::encoding::Decoder<
9943                '_,
9944                fidl::encoding::DefaultFuchsiaResourceDialect,
9945            >,
9946            offset: usize,
9947            _depth: fidl::encoding::Depth,
9948        ) -> fidl::Result<()> {
9949            decoder.debug_check_bounds::<Self>(offset);
9950            // Verify that padding bytes are zero.
9951            fidl::decode!(
9952                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<BlobIdIteratorMarker>>,
9953                fidl::encoding::DefaultFuchsiaResourceDialect,
9954                &mut self.iterator,
9955                decoder,
9956                offset + 0,
9957                _depth
9958            )?;
9959            Ok(())
9960        }
9961    }
9962
9963    impl fidl::encoding::ResourceTypeMarker for BlobWriter {
9964        type Borrowed<'a> = &'a mut Self;
9965        fn take_or_borrow<'a>(
9966            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9967        ) -> Self::Borrowed<'a> {
9968            value
9969        }
9970    }
9971
9972    unsafe impl fidl::encoding::TypeMarker for BlobWriter {
9973        type Owned = Self;
9974
9975        #[inline(always)]
9976        fn inline_align(_context: fidl::encoding::Context) -> usize {
9977            8
9978        }
9979
9980        #[inline(always)]
9981        fn inline_size(_context: fidl::encoding::Context) -> usize {
9982            16
9983        }
9984    }
9985
9986    unsafe impl fidl::encoding::Encode<BlobWriter, fidl::encoding::DefaultFuchsiaResourceDialect>
9987        for &mut BlobWriter
9988    {
9989        #[inline]
9990        unsafe fn encode(
9991            self,
9992            encoder: &mut fidl::encoding::Encoder<
9993                '_,
9994                fidl::encoding::DefaultFuchsiaResourceDialect,
9995            >,
9996            offset: usize,
9997            _depth: fidl::encoding::Depth,
9998        ) -> fidl::Result<()> {
9999            encoder.debug_check_bounds::<BlobWriter>(offset);
10000            encoder.write_num::<u64>(self.ordinal(), offset);
10001            match self {
10002                BlobWriter::File(ref mut val) => fidl::encoding::encode_in_envelope::<
10003                    fidl::encoding::Endpoint<
10004                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
10005                    >,
10006                    fidl::encoding::DefaultFuchsiaResourceDialect,
10007                >(
10008                    <fidl::encoding::Endpoint<
10009                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
10010                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10011                        val
10012                    ),
10013                    encoder,
10014                    offset + 8,
10015                    _depth,
10016                ),
10017                BlobWriter::Writer(ref mut val) => fidl::encoding::encode_in_envelope::<
10018                    fidl::encoding::Endpoint<
10019                        fidl::endpoints::ClientEnd<fidl_fuchsia_fxfs::BlobWriterMarker>,
10020                    >,
10021                    fidl::encoding::DefaultFuchsiaResourceDialect,
10022                >(
10023                    <fidl::encoding::Endpoint<
10024                        fidl::endpoints::ClientEnd<fidl_fuchsia_fxfs::BlobWriterMarker>,
10025                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10026                        val
10027                    ),
10028                    encoder,
10029                    offset + 8,
10030                    _depth,
10031                ),
10032            }
10033        }
10034    }
10035
10036    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for BlobWriter {
10037        #[inline(always)]
10038        fn new_empty() -> Self {
10039            Self::File(fidl::new_empty!(
10040                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>>,
10041                fidl::encoding::DefaultFuchsiaResourceDialect
10042            ))
10043        }
10044
10045        #[inline]
10046        unsafe fn decode(
10047            &mut self,
10048            decoder: &mut fidl::encoding::Decoder<
10049                '_,
10050                fidl::encoding::DefaultFuchsiaResourceDialect,
10051            >,
10052            offset: usize,
10053            mut depth: fidl::encoding::Depth,
10054        ) -> fidl::Result<()> {
10055            decoder.debug_check_bounds::<Self>(offset);
10056            #[allow(unused_variables)]
10057            let next_out_of_line = decoder.next_out_of_line();
10058            let handles_before = decoder.remaining_handles();
10059            let (ordinal, inlined, num_bytes, num_handles) =
10060                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
10061
10062            let member_inline_size = match ordinal {
10063                1 => <fidl::encoding::Endpoint<
10064                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
10065                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
10066                2 => <fidl::encoding::Endpoint<
10067                    fidl::endpoints::ClientEnd<fidl_fuchsia_fxfs::BlobWriterMarker>,
10068                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
10069                _ => return Err(fidl::Error::UnknownUnionTag),
10070            };
10071
10072            if inlined != (member_inline_size <= 4) {
10073                return Err(fidl::Error::InvalidInlineBitInEnvelope);
10074            }
10075            let _inner_offset;
10076            if inlined {
10077                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
10078                _inner_offset = offset + 8;
10079            } else {
10080                depth.increment()?;
10081                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10082            }
10083            match ordinal {
10084                1 => {
10085                    #[allow(irrefutable_let_patterns)]
10086                    if let BlobWriter::File(_) = self {
10087                        // Do nothing, read the value into the object
10088                    } else {
10089                        // Initialize `self` to the right variant
10090                        *self = BlobWriter::File(fidl::new_empty!(
10091                            fidl::encoding::Endpoint<
10092                                fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
10093                            >,
10094                            fidl::encoding::DefaultFuchsiaResourceDialect
10095                        ));
10096                    }
10097                    #[allow(irrefutable_let_patterns)]
10098                    if let BlobWriter::File(ref mut val) = self {
10099                        fidl::decode!(
10100                            fidl::encoding::Endpoint<
10101                                fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
10102                            >,
10103                            fidl::encoding::DefaultFuchsiaResourceDialect,
10104                            val,
10105                            decoder,
10106                            _inner_offset,
10107                            depth
10108                        )?;
10109                    } else {
10110                        unreachable!()
10111                    }
10112                }
10113                2 => {
10114                    #[allow(irrefutable_let_patterns)]
10115                    if let BlobWriter::Writer(_) = self {
10116                        // Do nothing, read the value into the object
10117                    } else {
10118                        // Initialize `self` to the right variant
10119                        *self = BlobWriter::Writer(fidl::new_empty!(
10120                            fidl::encoding::Endpoint<
10121                                fidl::endpoints::ClientEnd<fidl_fuchsia_fxfs::BlobWriterMarker>,
10122                            >,
10123                            fidl::encoding::DefaultFuchsiaResourceDialect
10124                        ));
10125                    }
10126                    #[allow(irrefutable_let_patterns)]
10127                    if let BlobWriter::Writer(ref mut val) = self {
10128                        fidl::decode!(
10129                            fidl::encoding::Endpoint<
10130                                fidl::endpoints::ClientEnd<fidl_fuchsia_fxfs::BlobWriterMarker>,
10131                            >,
10132                            fidl::encoding::DefaultFuchsiaResourceDialect,
10133                            val,
10134                            decoder,
10135                            _inner_offset,
10136                            depth
10137                        )?;
10138                    } else {
10139                        unreachable!()
10140                    }
10141                }
10142                ordinal => panic!("unexpected ordinal {:?}", ordinal),
10143            }
10144            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
10145                return Err(fidl::Error::InvalidNumBytesInEnvelope);
10146            }
10147            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10148                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10149            }
10150            Ok(())
10151        }
10152    }
10153}