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