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