Skip to main content

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