Skip to main content

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