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