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