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