Skip to main content

fidl_fuchsia_memory_attribution/
fidl_fuchsia_memory_attribution.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_memory_attribution_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct PagerStatsSinkSendPagerStatsRequest {
16    pub pager_stats_vmo: fidl::Vmo,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20    for PagerStatsSinkSendPagerStatsRequest
21{
22}
23
24/// Represents a newly added principal.
25#[derive(Debug, Default, PartialEq)]
26pub struct NewPrincipal {
27    /// The identifier of this principal.
28    pub identifier: Option<u64>,
29    /// Description of the identity of the principal.
30    ///
31    /// Description holds a human-friendly (or a reference to a human-friendly)
32    /// identity descriptor of the principal. This will be used by clients to
33    /// identify this principal to users at display time.
34    pub description: Option<Description>,
35    /// The type of the principal.
36    pub principal_type: Option<PrincipalType>,
37    /// If this principal provides attribution information, a channel to its
38    /// provider.
39    pub detailed_attribution: Option<fidl::endpoints::ClientEnd<ProviderMarker>>,
40    #[doc(hidden)]
41    pub __source_breaking: fidl::marker::SourceBreaking,
42}
43
44impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for NewPrincipal {}
45
46#[derive(Debug, Default, PartialEq)]
47pub struct ProviderGetResponse {
48    pub attributions: Option<Vec<AttributionUpdate>>,
49    #[doc(hidden)]
50    pub __source_breaking: fidl::marker::SourceBreaking,
51}
52
53impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ProviderGetResponse {}
54
55/// The complete set of Resources used by a Principal.
56///
57/// Upon receiving this message, the previous set of Resources attributed to the identified
58/// Principal by this connection should be replaced. If, on another connection, another
59/// Provider attributed resources to this principal, these attributions should be kept.
60#[derive(Debug, Default, PartialEq)]
61pub struct UpdatedPrincipal {
62    /// The identifier of this principal.
63    pub identifier: Option<u64>,
64    /// The resources owned by this principal.
65    ///
66    /// If the size of the Resource vector is too big to fit in a FIDL message, `buffer` should
67    /// contain a serialized vector of Resources.
68    pub resources: Option<Resources>,
69    #[doc(hidden)]
70    pub __source_breaking: fidl::marker::SourceBreaking,
71}
72
73impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for UpdatedPrincipal {}
74
75/// Describes a change affecting attribution of resources to a single principal.
76#[derive(Debug)]
77pub enum AttributionUpdate {
78    /// Reports a new principal managed by the reporter.
79    ///
80    /// Declaring a Principal means that the declarer/reporter is providing the
81    /// resources for the Principal to run. Typically, Component Framework
82    /// Runners will declare the components they run as Principals.
83    Add(NewPrincipal),
84    /// Replaces the attribution information for a Principal.
85    ///
86    /// When this is received, the client is should discard any attribution
87    /// information received by this channel for the Principal, and replace it
88    /// with this information.
89    Update(UpdatedPrincipal),
90    /// Removes a Principal.
91    ///
92    /// Declares that a Principal is no longer active on the system. All
93    /// attribution information for this Principal can be removed after this
94    /// message. Any remaining resources will still be attributed according to
95    /// the default attribution rules.
96    Remove(u64),
97    #[doc(hidden)]
98    __SourceBreaking { unknown_ordinal: u64 },
99}
100
101/// Pattern that matches an unknown `AttributionUpdate` member.
102#[macro_export]
103macro_rules! AttributionUpdateUnknown {
104    () => {
105        _
106    };
107}
108
109// Custom PartialEq so that unknown variants are not equal to themselves.
110impl PartialEq for AttributionUpdate {
111    fn eq(&self, other: &Self) -> bool {
112        match (self, other) {
113            (Self::Add(x), Self::Add(y)) => *x == *y,
114            (Self::Update(x), Self::Update(y)) => *x == *y,
115            (Self::Remove(x), Self::Remove(y)) => *x == *y,
116            _ => false,
117        }
118    }
119}
120
121impl AttributionUpdate {
122    #[inline]
123    pub fn ordinal(&self) -> u64 {
124        match *self {
125            Self::Add(_) => 1,
126            Self::Update(_) => 2,
127            Self::Remove(_) => 3,
128            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
129        }
130    }
131
132    #[inline]
133    pub fn unknown_variant_for_testing() -> Self {
134        Self::__SourceBreaking { unknown_ordinal: 0 }
135    }
136
137    #[inline]
138    pub fn is_unknown(&self) -> bool {
139        match self {
140            Self::__SourceBreaking { .. } => true,
141            _ => false,
142        }
143    }
144}
145
146impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for AttributionUpdate {}
147
148#[derive(Debug)]
149pub enum Description {
150    /// Token identifying the component instance run by this principal.
151    ///
152    /// This is the token defined in the component_instance field of
153    /// fuchsia.component.runner.ComponentStartInfo.
154    Component(fidl::Event),
155    /// A subpart of a component, which isn't a fully-blown Component within
156    /// Component Framework but still represents a coherent unit of
157    /// computation. This can be, for instance, a Linux process under Starnix.
158    ///
159    /// This name needs to be unique within the component this principal is
160    /// part of.
161    Part(String),
162    #[doc(hidden)]
163    __SourceBreaking { unknown_ordinal: u64 },
164}
165
166/// Pattern that matches an unknown `Description` member.
167#[macro_export]
168macro_rules! DescriptionUnknown {
169    () => {
170        _
171    };
172}
173
174// Custom PartialEq so that unknown variants are not equal to themselves.
175impl PartialEq for Description {
176    fn eq(&self, other: &Self) -> bool {
177        match (self, other) {
178            (Self::Component(x), Self::Component(y)) => *x == *y,
179            (Self::Part(x), Self::Part(y)) => *x == *y,
180            _ => false,
181        }
182    }
183}
184
185impl Description {
186    #[inline]
187    pub fn ordinal(&self) -> u64 {
188        match *self {
189            Self::Component(_) => 1,
190            Self::Part(_) => 2,
191            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
192        }
193    }
194
195    #[inline]
196    pub fn unknown_variant_for_testing() -> Self {
197        Self::__SourceBreaking { unknown_ordinal: 0 }
198    }
199
200    #[inline]
201    pub fn is_unknown(&self) -> bool {
202        match self {
203            Self::__SourceBreaking { .. } => true,
204            _ => false,
205        }
206    }
207}
208
209impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for Description {}
210
211#[derive(Debug)]
212pub enum Resources {
213    Data(Data),
214    /// buffer is read-only.
215    Buffer(fidl::Vmo),
216    #[doc(hidden)]
217    __SourceBreaking {
218        unknown_ordinal: u64,
219    },
220}
221
222/// Pattern that matches an unknown `Resources` member.
223#[macro_export]
224macro_rules! ResourcesUnknown {
225    () => {
226        _
227    };
228}
229
230// Custom PartialEq so that unknown variants are not equal to themselves.
231impl PartialEq for Resources {
232    fn eq(&self, other: &Self) -> bool {
233        match (self, other) {
234            (Self::Data(x), Self::Data(y)) => *x == *y,
235            (Self::Buffer(x), Self::Buffer(y)) => *x == *y,
236            _ => false,
237        }
238    }
239}
240
241impl Resources {
242    #[inline]
243    pub fn ordinal(&self) -> u64 {
244        match *self {
245            Self::Data(_) => 1,
246            Self::Buffer(_) => 2,
247            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
248        }
249    }
250
251    #[inline]
252    pub fn unknown_variant_for_testing() -> Self {
253        Self::__SourceBreaking { unknown_ordinal: 0 }
254    }
255
256    #[inline]
257    pub fn is_unknown(&self) -> bool {
258        match self {
259            Self::__SourceBreaking { .. } => true,
260            _ => false,
261        }
262    }
263}
264
265impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for Resources {}
266
267#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
268pub struct PagerStatsSinkMarker;
269
270impl fidl::endpoints::ProtocolMarker for PagerStatsSinkMarker {
271    type Proxy = PagerStatsSinkProxy;
272    type RequestStream = PagerStatsSinkRequestStream;
273    #[cfg(target_os = "fuchsia")]
274    type SynchronousProxy = PagerStatsSinkSynchronousProxy;
275
276    const DEBUG_NAME: &'static str = "fuchsia.memory.attribution.PagerStatsSink";
277}
278impl fidl::endpoints::DiscoverableProtocolMarker for PagerStatsSinkMarker {}
279
280pub trait PagerStatsSinkProxyInterface: Send + Sync {
281    fn r#send_pager_stats(&self, pager_stats_vmo: fidl::Vmo) -> Result<(), fidl::Error>;
282}
283#[derive(Debug)]
284#[cfg(target_os = "fuchsia")]
285pub struct PagerStatsSinkSynchronousProxy {
286    client: fidl::client::sync::Client,
287}
288
289#[cfg(target_os = "fuchsia")]
290impl fidl::endpoints::SynchronousProxy for PagerStatsSinkSynchronousProxy {
291    type Proxy = PagerStatsSinkProxy;
292    type Protocol = PagerStatsSinkMarker;
293
294    fn from_channel(inner: fidl::Channel) -> Self {
295        Self::new(inner)
296    }
297
298    fn into_channel(self) -> fidl::Channel {
299        self.client.into_channel()
300    }
301
302    fn as_channel(&self) -> &fidl::Channel {
303        self.client.as_channel()
304    }
305}
306
307#[cfg(target_os = "fuchsia")]
308impl PagerStatsSinkSynchronousProxy {
309    pub fn new(channel: fidl::Channel) -> Self {
310        Self { client: fidl::client::sync::Client::new(channel) }
311    }
312
313    pub fn into_channel(self) -> fidl::Channel {
314        self.client.into_channel()
315    }
316
317    /// Waits until an event arrives and returns it. It is safe for other
318    /// threads to make concurrent requests while waiting for an event.
319    pub fn wait_for_event(
320        &self,
321        deadline: zx::MonotonicInstant,
322    ) -> Result<PagerStatsSinkEvent, fidl::Error> {
323        PagerStatsSinkEvent::decode(self.client.wait_for_event::<PagerStatsSinkMarker>(deadline)?)
324    }
325
326    /// Sends a VMO containing shared counts of page refaults and total page faults, both measured
327    /// in pages supplied by the pager including readahead. The shared counts are stored as two
328    /// canonical monotonic atomic 64-bit unsigned integers from the start of the VMO:
329    /// - Offset 0: `page_refaults` (pages supplied that had already been supplied before)
330    /// - Offset 8: `page_faults` (total pages supplied by the user pager)
331    pub fn r#send_pager_stats(&self, mut pager_stats_vmo: fidl::Vmo) -> Result<(), fidl::Error> {
332        self.client.send::<PagerStatsSinkSendPagerStatsRequest>(
333            (pager_stats_vmo,),
334            0x1bbe2ac953db8380,
335            fidl::encoding::DynamicFlags::FLEXIBLE,
336        )
337    }
338}
339
340#[cfg(target_os = "fuchsia")]
341impl From<PagerStatsSinkSynchronousProxy> for zx::NullableHandle {
342    fn from(value: PagerStatsSinkSynchronousProxy) -> Self {
343        value.into_channel().into()
344    }
345}
346
347#[cfg(target_os = "fuchsia")]
348impl From<fidl::Channel> for PagerStatsSinkSynchronousProxy {
349    fn from(value: fidl::Channel) -> Self {
350        Self::new(value)
351    }
352}
353
354#[cfg(target_os = "fuchsia")]
355impl fidl::endpoints::FromClient for PagerStatsSinkSynchronousProxy {
356    type Protocol = PagerStatsSinkMarker;
357
358    fn from_client(value: fidl::endpoints::ClientEnd<PagerStatsSinkMarker>) -> Self {
359        Self::new(value.into_channel())
360    }
361}
362
363#[derive(Debug, Clone)]
364pub struct PagerStatsSinkProxy {
365    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
366}
367
368impl fidl::endpoints::Proxy for PagerStatsSinkProxy {
369    type Protocol = PagerStatsSinkMarker;
370
371    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
372        Self::new(inner)
373    }
374
375    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
376        self.client.into_channel().map_err(|client| Self { client })
377    }
378
379    fn as_channel(&self) -> &::fidl::AsyncChannel {
380        self.client.as_channel()
381    }
382}
383
384impl PagerStatsSinkProxy {
385    /// Create a new Proxy for fuchsia.memory.attribution/PagerStatsSink.
386    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
387        let protocol_name = <PagerStatsSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
388        Self { client: fidl::client::Client::new(channel, protocol_name) }
389    }
390
391    /// Get a Stream of events from the remote end of the protocol.
392    ///
393    /// # Panics
394    ///
395    /// Panics if the event stream was already taken.
396    pub fn take_event_stream(&self) -> PagerStatsSinkEventStream {
397        PagerStatsSinkEventStream { event_receiver: self.client.take_event_receiver() }
398    }
399
400    /// Sends a VMO containing shared counts of page refaults and total page faults, both measured
401    /// in pages supplied by the pager including readahead. The shared counts are stored as two
402    /// canonical monotonic atomic 64-bit unsigned integers from the start of the VMO:
403    /// - Offset 0: `page_refaults` (pages supplied that had already been supplied before)
404    /// - Offset 8: `page_faults` (total pages supplied by the user pager)
405    pub fn r#send_pager_stats(&self, mut pager_stats_vmo: fidl::Vmo) -> Result<(), fidl::Error> {
406        PagerStatsSinkProxyInterface::r#send_pager_stats(self, pager_stats_vmo)
407    }
408}
409
410impl PagerStatsSinkProxyInterface for PagerStatsSinkProxy {
411    fn r#send_pager_stats(&self, mut pager_stats_vmo: fidl::Vmo) -> Result<(), fidl::Error> {
412        self.client.send::<PagerStatsSinkSendPagerStatsRequest>(
413            (pager_stats_vmo,),
414            0x1bbe2ac953db8380,
415            fidl::encoding::DynamicFlags::FLEXIBLE,
416        )
417    }
418}
419
420pub struct PagerStatsSinkEventStream {
421    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
422}
423
424impl std::marker::Unpin for PagerStatsSinkEventStream {}
425
426impl futures::stream::FusedStream for PagerStatsSinkEventStream {
427    fn is_terminated(&self) -> bool {
428        self.event_receiver.is_terminated()
429    }
430}
431
432impl futures::Stream for PagerStatsSinkEventStream {
433    type Item = Result<PagerStatsSinkEvent, fidl::Error>;
434
435    fn poll_next(
436        mut self: std::pin::Pin<&mut Self>,
437        cx: &mut std::task::Context<'_>,
438    ) -> std::task::Poll<Option<Self::Item>> {
439        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
440            &mut self.event_receiver,
441            cx
442        )?) {
443            Some(buf) => std::task::Poll::Ready(Some(PagerStatsSinkEvent::decode(buf))),
444            None => std::task::Poll::Ready(None),
445        }
446    }
447}
448
449#[derive(Debug)]
450pub enum PagerStatsSinkEvent {
451    #[non_exhaustive]
452    _UnknownEvent {
453        /// Ordinal of the event that was sent.
454        ordinal: u64,
455    },
456}
457
458impl PagerStatsSinkEvent {
459    /// Decodes a message buffer as a [`PagerStatsSinkEvent`].
460    fn decode(
461        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
462    ) -> Result<PagerStatsSinkEvent, fidl::Error> {
463        let (bytes, _handles) = buf.split_mut();
464        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
465        debug_assert_eq!(tx_header.tx_id, 0);
466        match tx_header.ordinal {
467            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
468                Ok(PagerStatsSinkEvent::_UnknownEvent { ordinal: tx_header.ordinal })
469            }
470            _ => Err(fidl::Error::UnknownOrdinal {
471                ordinal: tx_header.ordinal,
472                protocol_name:
473                    <PagerStatsSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
474            }),
475        }
476    }
477}
478
479/// A Stream of incoming requests for fuchsia.memory.attribution/PagerStatsSink.
480pub struct PagerStatsSinkRequestStream {
481    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
482    is_terminated: bool,
483}
484
485impl std::marker::Unpin for PagerStatsSinkRequestStream {}
486
487impl futures::stream::FusedStream for PagerStatsSinkRequestStream {
488    fn is_terminated(&self) -> bool {
489        self.is_terminated
490    }
491}
492
493impl fidl::endpoints::RequestStream for PagerStatsSinkRequestStream {
494    type Protocol = PagerStatsSinkMarker;
495    type ControlHandle = PagerStatsSinkControlHandle;
496
497    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
498        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
499    }
500
501    fn control_handle(&self) -> Self::ControlHandle {
502        PagerStatsSinkControlHandle { inner: self.inner.clone() }
503    }
504
505    fn into_inner(
506        self,
507    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
508    {
509        (self.inner, self.is_terminated)
510    }
511
512    fn from_inner(
513        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
514        is_terminated: bool,
515    ) -> Self {
516        Self { inner, is_terminated }
517    }
518}
519
520impl futures::Stream for PagerStatsSinkRequestStream {
521    type Item = Result<PagerStatsSinkRequest, fidl::Error>;
522
523    fn poll_next(
524        mut self: std::pin::Pin<&mut Self>,
525        cx: &mut std::task::Context<'_>,
526    ) -> std::task::Poll<Option<Self::Item>> {
527        let this = &mut *self;
528        if this.inner.check_shutdown(cx) {
529            this.is_terminated = true;
530            return std::task::Poll::Ready(None);
531        }
532        if this.is_terminated {
533            panic!("polled PagerStatsSinkRequestStream after completion");
534        }
535        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
536            |bytes, handles| {
537                match this.inner.channel().read_etc(cx, bytes, handles) {
538                    std::task::Poll::Ready(Ok(())) => {}
539                    std::task::Poll::Pending => return std::task::Poll::Pending,
540                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
541                        this.is_terminated = true;
542                        return std::task::Poll::Ready(None);
543                    }
544                    std::task::Poll::Ready(Err(e)) => {
545                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
546                            e.into(),
547                        ))));
548                    }
549                }
550
551                // A message has been received from the channel
552                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
553
554                std::task::Poll::Ready(Some(match header.ordinal {
555                    0x1bbe2ac953db8380 => {
556                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
557                        let mut req = fidl::new_empty!(
558                            PagerStatsSinkSendPagerStatsRequest,
559                            fidl::encoding::DefaultFuchsiaResourceDialect
560                        );
561                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PagerStatsSinkSendPagerStatsRequest>(&header, _body_bytes, handles, &mut req)?;
562                        let control_handle =
563                            PagerStatsSinkControlHandle { inner: this.inner.clone() };
564                        Ok(PagerStatsSinkRequest::SendPagerStats {
565                            pager_stats_vmo: req.pager_stats_vmo,
566
567                            control_handle,
568                        })
569                    }
570                    _ if header.tx_id == 0
571                        && header
572                            .dynamic_flags()
573                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
574                    {
575                        Ok(PagerStatsSinkRequest::_UnknownMethod {
576                            ordinal: header.ordinal,
577                            control_handle: PagerStatsSinkControlHandle {
578                                inner: this.inner.clone(),
579                            },
580                            method_type: fidl::MethodType::OneWay,
581                        })
582                    }
583                    _ if header
584                        .dynamic_flags()
585                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
586                    {
587                        this.inner.send_framework_err(
588                            fidl::encoding::FrameworkErr::UnknownMethod,
589                            header.tx_id,
590                            header.ordinal,
591                            header.dynamic_flags(),
592                            (bytes, handles),
593                        )?;
594                        Ok(PagerStatsSinkRequest::_UnknownMethod {
595                            ordinal: header.ordinal,
596                            control_handle: PagerStatsSinkControlHandle {
597                                inner: this.inner.clone(),
598                            },
599                            method_type: fidl::MethodType::TwoWay,
600                        })
601                    }
602                    _ => Err(fidl::Error::UnknownOrdinal {
603                        ordinal: header.ordinal,
604                        protocol_name:
605                            <PagerStatsSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
606                    }),
607                }))
608            },
609        )
610    }
611}
612
613/// Protocol used by user pagers to publish memory attribution statistics.
614#[derive(Debug)]
615pub enum PagerStatsSinkRequest {
616    /// Sends a VMO containing shared counts of page refaults and total page faults, both measured
617    /// in pages supplied by the pager including readahead. The shared counts are stored as two
618    /// canonical monotonic atomic 64-bit unsigned integers from the start of the VMO:
619    /// - Offset 0: `page_refaults` (pages supplied that had already been supplied before)
620    /// - Offset 8: `page_faults` (total pages supplied by the user pager)
621    SendPagerStats { pager_stats_vmo: fidl::Vmo, control_handle: PagerStatsSinkControlHandle },
622    /// An interaction was received which does not match any known method.
623    #[non_exhaustive]
624    _UnknownMethod {
625        /// Ordinal of the method that was called.
626        ordinal: u64,
627        control_handle: PagerStatsSinkControlHandle,
628        method_type: fidl::MethodType,
629    },
630}
631
632impl PagerStatsSinkRequest {
633    #[allow(irrefutable_let_patterns)]
634    pub fn into_send_pager_stats(self) -> Option<(fidl::Vmo, PagerStatsSinkControlHandle)> {
635        if let PagerStatsSinkRequest::SendPagerStats { pager_stats_vmo, control_handle } = self {
636            Some((pager_stats_vmo, control_handle))
637        } else {
638            None
639        }
640    }
641
642    /// Name of the method defined in FIDL
643    pub fn method_name(&self) -> &'static str {
644        match *self {
645            PagerStatsSinkRequest::SendPagerStats { .. } => "send_pager_stats",
646            PagerStatsSinkRequest::_UnknownMethod {
647                method_type: fidl::MethodType::OneWay, ..
648            } => "unknown one-way method",
649            PagerStatsSinkRequest::_UnknownMethod {
650                method_type: fidl::MethodType::TwoWay, ..
651            } => "unknown two-way method",
652        }
653    }
654}
655
656#[derive(Debug, Clone)]
657pub struct PagerStatsSinkControlHandle {
658    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
659}
660
661impl PagerStatsSinkControlHandle {
662    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
663        self.inner.shutdown_with_epitaph(status.into())
664    }
665}
666
667impl fidl::endpoints::ControlHandle for PagerStatsSinkControlHandle {
668    fn shutdown(&self) {
669        self.inner.shutdown()
670    }
671
672    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
673        self.inner.shutdown_with_epitaph(status)
674    }
675
676    fn is_closed(&self) -> bool {
677        self.inner.channel().is_closed()
678    }
679    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
680        self.inner.channel().on_closed()
681    }
682
683    #[cfg(target_os = "fuchsia")]
684    fn signal_peer(
685        &self,
686        clear_mask: zx::Signals,
687        set_mask: zx::Signals,
688    ) -> Result<(), zx_status::Status> {
689        use fidl::Peered;
690        self.inner.channel().signal_peer(clear_mask, set_mask)
691    }
692}
693
694impl PagerStatsSinkControlHandle {}
695
696#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
697pub struct ProviderMarker;
698
699impl fidl::endpoints::ProtocolMarker for ProviderMarker {
700    type Proxy = ProviderProxy;
701    type RequestStream = ProviderRequestStream;
702    #[cfg(target_os = "fuchsia")]
703    type SynchronousProxy = ProviderSynchronousProxy;
704
705    const DEBUG_NAME: &'static str = "fuchsia.memory.attribution.Provider";
706}
707impl fidl::endpoints::DiscoverableProtocolMarker for ProviderMarker {}
708pub type ProviderGetResult = Result<ProviderGetResponse, Error>;
709
710pub trait ProviderProxyInterface: Send + Sync {
711    type GetResponseFut: std::future::Future<Output = Result<ProviderGetResult, fidl::Error>> + Send;
712    fn r#get(&self) -> Self::GetResponseFut;
713}
714#[derive(Debug)]
715#[cfg(target_os = "fuchsia")]
716pub struct ProviderSynchronousProxy {
717    client: fidl::client::sync::Client,
718}
719
720#[cfg(target_os = "fuchsia")]
721impl fidl::endpoints::SynchronousProxy for ProviderSynchronousProxy {
722    type Proxy = ProviderProxy;
723    type Protocol = ProviderMarker;
724
725    fn from_channel(inner: fidl::Channel) -> Self {
726        Self::new(inner)
727    }
728
729    fn into_channel(self) -> fidl::Channel {
730        self.client.into_channel()
731    }
732
733    fn as_channel(&self) -> &fidl::Channel {
734        self.client.as_channel()
735    }
736}
737
738#[cfg(target_os = "fuchsia")]
739impl ProviderSynchronousProxy {
740    pub fn new(channel: fidl::Channel) -> Self {
741        Self { client: fidl::client::sync::Client::new(channel) }
742    }
743
744    pub fn into_channel(self) -> fidl::Channel {
745        self.client.into_channel()
746    }
747
748    /// Waits until an event arrives and returns it. It is safe for other
749    /// threads to make concurrent requests while waiting for an event.
750    pub fn wait_for_event(
751        &self,
752        deadline: zx::MonotonicInstant,
753    ) -> Result<ProviderEvent, fidl::Error> {
754        ProviderEvent::decode(self.client.wait_for_event::<ProviderMarker>(deadline)?)
755    }
756
757    /// Returns the attribution information known to the provider.
758    ///
759    /// The first call returns immediately with the current information.
760    /// Subsequent calls will be held if no additional information is
761    /// available, and return only when there are changes to the attribution
762    /// information to be reported.
763    ///
764    /// Runners will typically report the kernel resources (e.g. job, process,
765    /// etc) associated with each component that they are responsible for
766    /// running.
767    ///
768    /// Components may optionally report resource usage by different categories
769    /// within their implementation.
770    pub fn r#get(
771        &self,
772        ___deadline: zx::MonotonicInstant,
773    ) -> Result<ProviderGetResult, fidl::Error> {
774        let _response = self.client.send_query::<
775            fidl::encoding::EmptyPayload,
776            fidl::encoding::FlexibleResultType<ProviderGetResponse, Error>,
777            ProviderMarker,
778        >(
779            (),
780            0x7a2f2d2cdcfcc945,
781            fidl::encoding::DynamicFlags::FLEXIBLE,
782            ___deadline,
783        )?
784        .into_result::<ProviderMarker>("get")?;
785        Ok(_response.map(|x| x))
786    }
787}
788
789#[cfg(target_os = "fuchsia")]
790impl From<ProviderSynchronousProxy> for zx::NullableHandle {
791    fn from(value: ProviderSynchronousProxy) -> Self {
792        value.into_channel().into()
793    }
794}
795
796#[cfg(target_os = "fuchsia")]
797impl From<fidl::Channel> for ProviderSynchronousProxy {
798    fn from(value: fidl::Channel) -> Self {
799        Self::new(value)
800    }
801}
802
803#[cfg(target_os = "fuchsia")]
804impl fidl::endpoints::FromClient for ProviderSynchronousProxy {
805    type Protocol = ProviderMarker;
806
807    fn from_client(value: fidl::endpoints::ClientEnd<ProviderMarker>) -> Self {
808        Self::new(value.into_channel())
809    }
810}
811
812#[derive(Debug, Clone)]
813pub struct ProviderProxy {
814    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
815}
816
817impl fidl::endpoints::Proxy for ProviderProxy {
818    type Protocol = ProviderMarker;
819
820    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
821        Self::new(inner)
822    }
823
824    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
825        self.client.into_channel().map_err(|client| Self { client })
826    }
827
828    fn as_channel(&self) -> &::fidl::AsyncChannel {
829        self.client.as_channel()
830    }
831}
832
833impl ProviderProxy {
834    /// Create a new Proxy for fuchsia.memory.attribution/Provider.
835    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
836        let protocol_name = <ProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
837        Self { client: fidl::client::Client::new(channel, protocol_name) }
838    }
839
840    /// Get a Stream of events from the remote end of the protocol.
841    ///
842    /// # Panics
843    ///
844    /// Panics if the event stream was already taken.
845    pub fn take_event_stream(&self) -> ProviderEventStream {
846        ProviderEventStream { event_receiver: self.client.take_event_receiver() }
847    }
848
849    /// Returns the attribution information known to the provider.
850    ///
851    /// The first call returns immediately with the current information.
852    /// Subsequent calls will be held if no additional information is
853    /// available, and return only when there are changes to the attribution
854    /// information to be reported.
855    ///
856    /// Runners will typically report the kernel resources (e.g. job, process,
857    /// etc) associated with each component that they are responsible for
858    /// running.
859    ///
860    /// Components may optionally report resource usage by different categories
861    /// within their implementation.
862    pub fn r#get(
863        &self,
864    ) -> fidl::client::QueryResponseFut<
865        ProviderGetResult,
866        fidl::encoding::DefaultFuchsiaResourceDialect,
867    > {
868        ProviderProxyInterface::r#get(self)
869    }
870}
871
872impl ProviderProxyInterface for ProviderProxy {
873    type GetResponseFut = fidl::client::QueryResponseFut<
874        ProviderGetResult,
875        fidl::encoding::DefaultFuchsiaResourceDialect,
876    >;
877    fn r#get(&self) -> Self::GetResponseFut {
878        fn _decode(
879            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
880        ) -> Result<ProviderGetResult, fidl::Error> {
881            let _response = fidl::client::decode_transaction_body::<
882                fidl::encoding::FlexibleResultType<ProviderGetResponse, Error>,
883                fidl::encoding::DefaultFuchsiaResourceDialect,
884                0x7a2f2d2cdcfcc945,
885            >(_buf?)?
886            .into_result::<ProviderMarker>("get")?;
887            Ok(_response.map(|x| x))
888        }
889        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ProviderGetResult>(
890            (),
891            0x7a2f2d2cdcfcc945,
892            fidl::encoding::DynamicFlags::FLEXIBLE,
893            _decode,
894        )
895    }
896}
897
898pub struct ProviderEventStream {
899    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
900}
901
902impl std::marker::Unpin for ProviderEventStream {}
903
904impl futures::stream::FusedStream for ProviderEventStream {
905    fn is_terminated(&self) -> bool {
906        self.event_receiver.is_terminated()
907    }
908}
909
910impl futures::Stream for ProviderEventStream {
911    type Item = Result<ProviderEvent, fidl::Error>;
912
913    fn poll_next(
914        mut self: std::pin::Pin<&mut Self>,
915        cx: &mut std::task::Context<'_>,
916    ) -> std::task::Poll<Option<Self::Item>> {
917        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
918            &mut self.event_receiver,
919            cx
920        )?) {
921            Some(buf) => std::task::Poll::Ready(Some(ProviderEvent::decode(buf))),
922            None => std::task::Poll::Ready(None),
923        }
924    }
925}
926
927#[derive(Debug)]
928pub enum ProviderEvent {
929    #[non_exhaustive]
930    _UnknownEvent {
931        /// Ordinal of the event that was sent.
932        ordinal: u64,
933    },
934}
935
936impl ProviderEvent {
937    /// Decodes a message buffer as a [`ProviderEvent`].
938    fn decode(
939        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
940    ) -> Result<ProviderEvent, fidl::Error> {
941        let (bytes, _handles) = buf.split_mut();
942        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
943        debug_assert_eq!(tx_header.tx_id, 0);
944        match tx_header.ordinal {
945            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
946                Ok(ProviderEvent::_UnknownEvent { ordinal: tx_header.ordinal })
947            }
948            _ => Err(fidl::Error::UnknownOrdinal {
949                ordinal: tx_header.ordinal,
950                protocol_name: <ProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
951            }),
952        }
953    }
954}
955
956/// A Stream of incoming requests for fuchsia.memory.attribution/Provider.
957pub struct ProviderRequestStream {
958    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
959    is_terminated: bool,
960}
961
962impl std::marker::Unpin for ProviderRequestStream {}
963
964impl futures::stream::FusedStream for ProviderRequestStream {
965    fn is_terminated(&self) -> bool {
966        self.is_terminated
967    }
968}
969
970impl fidl::endpoints::RequestStream for ProviderRequestStream {
971    type Protocol = ProviderMarker;
972    type ControlHandle = ProviderControlHandle;
973
974    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
975        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
976    }
977
978    fn control_handle(&self) -> Self::ControlHandle {
979        ProviderControlHandle { inner: self.inner.clone() }
980    }
981
982    fn into_inner(
983        self,
984    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
985    {
986        (self.inner, self.is_terminated)
987    }
988
989    fn from_inner(
990        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
991        is_terminated: bool,
992    ) -> Self {
993        Self { inner, is_terminated }
994    }
995}
996
997impl futures::Stream for ProviderRequestStream {
998    type Item = Result<ProviderRequest, fidl::Error>;
999
1000    fn poll_next(
1001        mut self: std::pin::Pin<&mut Self>,
1002        cx: &mut std::task::Context<'_>,
1003    ) -> std::task::Poll<Option<Self::Item>> {
1004        let this = &mut *self;
1005        if this.inner.check_shutdown(cx) {
1006            this.is_terminated = true;
1007            return std::task::Poll::Ready(None);
1008        }
1009        if this.is_terminated {
1010            panic!("polled ProviderRequestStream after completion");
1011        }
1012        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1013            |bytes, handles| {
1014                match this.inner.channel().read_etc(cx, bytes, handles) {
1015                    std::task::Poll::Ready(Ok(())) => {}
1016                    std::task::Poll::Pending => return std::task::Poll::Pending,
1017                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1018                        this.is_terminated = true;
1019                        return std::task::Poll::Ready(None);
1020                    }
1021                    std::task::Poll::Ready(Err(e)) => {
1022                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1023                            e.into(),
1024                        ))));
1025                    }
1026                }
1027
1028                // A message has been received from the channel
1029                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1030
1031                std::task::Poll::Ready(Some(match header.ordinal {
1032                    0x7a2f2d2cdcfcc945 => {
1033                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1034                        let mut req = fidl::new_empty!(
1035                            fidl::encoding::EmptyPayload,
1036                            fidl::encoding::DefaultFuchsiaResourceDialect
1037                        );
1038                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1039                        let control_handle = ProviderControlHandle { inner: this.inner.clone() };
1040                        Ok(ProviderRequest::Get {
1041                            responder: ProviderGetResponder {
1042                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1043                                tx_id: header.tx_id,
1044                            },
1045                        })
1046                    }
1047                    _ if header.tx_id == 0
1048                        && header
1049                            .dynamic_flags()
1050                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1051                    {
1052                        Ok(ProviderRequest::_UnknownMethod {
1053                            ordinal: header.ordinal,
1054                            control_handle: ProviderControlHandle { inner: this.inner.clone() },
1055                            method_type: fidl::MethodType::OneWay,
1056                        })
1057                    }
1058                    _ if header
1059                        .dynamic_flags()
1060                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1061                    {
1062                        this.inner.send_framework_err(
1063                            fidl::encoding::FrameworkErr::UnknownMethod,
1064                            header.tx_id,
1065                            header.ordinal,
1066                            header.dynamic_flags(),
1067                            (bytes, handles),
1068                        )?;
1069                        Ok(ProviderRequest::_UnknownMethod {
1070                            ordinal: header.ordinal,
1071                            control_handle: ProviderControlHandle { inner: this.inner.clone() },
1072                            method_type: fidl::MethodType::TwoWay,
1073                        })
1074                    }
1075                    _ => Err(fidl::Error::UnknownOrdinal {
1076                        ordinal: header.ordinal,
1077                        protocol_name:
1078                            <ProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1079                    }),
1080                }))
1081            },
1082        )
1083    }
1084}
1085
1086/// Provides memory attribution information under this principal.
1087///
1088/// The typical expected usage of this protocol is:
1089///  - Component Runners implement this protocol and declare it in their
1090///    manifest.
1091///  - A Component that wants to provide extra internal information may also
1092///    declare and implement this protocol;
1093///  - Clients connect to a `Provider`, and use the `Get` methods to
1094///    recursively explore the Principal hierarchy.
1095///
1096/// Clients will typically maintain the connection and start a hanging get to
1097/// retrieve attribution information. Runners need to inspect the manifest of
1098/// their runnees to determine if they serve this protocol, and proactively
1099/// create the connection. They can also proxy this protocol in case their
1100/// runnee provides attribution information in an unsuitable format.
1101#[derive(Debug)]
1102pub enum ProviderRequest {
1103    /// Returns the attribution information known to the provider.
1104    ///
1105    /// The first call returns immediately with the current information.
1106    /// Subsequent calls will be held if no additional information is
1107    /// available, and return only when there are changes to the attribution
1108    /// information to be reported.
1109    ///
1110    /// Runners will typically report the kernel resources (e.g. job, process,
1111    /// etc) associated with each component that they are responsible for
1112    /// running.
1113    ///
1114    /// Components may optionally report resource usage by different categories
1115    /// within their implementation.
1116    Get { responder: ProviderGetResponder },
1117    /// An interaction was received which does not match any known method.
1118    #[non_exhaustive]
1119    _UnknownMethod {
1120        /// Ordinal of the method that was called.
1121        ordinal: u64,
1122        control_handle: ProviderControlHandle,
1123        method_type: fidl::MethodType,
1124    },
1125}
1126
1127impl ProviderRequest {
1128    #[allow(irrefutable_let_patterns)]
1129    pub fn into_get(self) -> Option<(ProviderGetResponder)> {
1130        if let ProviderRequest::Get { responder } = self { Some((responder)) } else { None }
1131    }
1132
1133    /// Name of the method defined in FIDL
1134    pub fn method_name(&self) -> &'static str {
1135        match *self {
1136            ProviderRequest::Get { .. } => "get",
1137            ProviderRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
1138                "unknown one-way method"
1139            }
1140            ProviderRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
1141                "unknown two-way method"
1142            }
1143        }
1144    }
1145}
1146
1147#[derive(Debug, Clone)]
1148pub struct ProviderControlHandle {
1149    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1150}
1151
1152impl ProviderControlHandle {
1153    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1154        self.inner.shutdown_with_epitaph(status.into())
1155    }
1156}
1157
1158impl fidl::endpoints::ControlHandle for ProviderControlHandle {
1159    fn shutdown(&self) {
1160        self.inner.shutdown()
1161    }
1162
1163    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1164        self.inner.shutdown_with_epitaph(status)
1165    }
1166
1167    fn is_closed(&self) -> bool {
1168        self.inner.channel().is_closed()
1169    }
1170    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1171        self.inner.channel().on_closed()
1172    }
1173
1174    #[cfg(target_os = "fuchsia")]
1175    fn signal_peer(
1176        &self,
1177        clear_mask: zx::Signals,
1178        set_mask: zx::Signals,
1179    ) -> Result<(), zx_status::Status> {
1180        use fidl::Peered;
1181        self.inner.channel().signal_peer(clear_mask, set_mask)
1182    }
1183}
1184
1185impl ProviderControlHandle {}
1186
1187#[must_use = "FIDL methods require a response to be sent"]
1188#[derive(Debug)]
1189pub struct ProviderGetResponder {
1190    control_handle: std::mem::ManuallyDrop<ProviderControlHandle>,
1191    tx_id: u32,
1192}
1193
1194/// Set the the channel to be shutdown (see [`ProviderControlHandle::shutdown`])
1195/// if the responder is dropped without sending a response, so that the client
1196/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1197impl std::ops::Drop for ProviderGetResponder {
1198    fn drop(&mut self) {
1199        self.control_handle.shutdown();
1200        // Safety: drops once, never accessed again
1201        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1202    }
1203}
1204
1205impl fidl::endpoints::Responder for ProviderGetResponder {
1206    type ControlHandle = ProviderControlHandle;
1207
1208    fn control_handle(&self) -> &ProviderControlHandle {
1209        &self.control_handle
1210    }
1211
1212    fn drop_without_shutdown(mut self) {
1213        // Safety: drops once, never accessed again due to mem::forget
1214        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1215        // Prevent Drop from running (which would shut down the channel)
1216        std::mem::forget(self);
1217    }
1218}
1219
1220impl ProviderGetResponder {
1221    /// Sends a response to the FIDL transaction.
1222    ///
1223    /// Sets the channel to shutdown if an error occurs.
1224    pub fn send(self, mut result: Result<ProviderGetResponse, Error>) -> Result<(), fidl::Error> {
1225        let _result = self.send_raw(result);
1226        if _result.is_err() {
1227            self.control_handle.shutdown();
1228        }
1229        self.drop_without_shutdown();
1230        _result
1231    }
1232
1233    /// Similar to "send" but does not shutdown the channel if an error occurs.
1234    pub fn send_no_shutdown_on_err(
1235        self,
1236        mut result: Result<ProviderGetResponse, Error>,
1237    ) -> Result<(), fidl::Error> {
1238        let _result = self.send_raw(result);
1239        self.drop_without_shutdown();
1240        _result
1241    }
1242
1243    fn send_raw(&self, mut result: Result<ProviderGetResponse, Error>) -> Result<(), fidl::Error> {
1244        self.control_handle
1245            .inner
1246            .send::<fidl::encoding::FlexibleResultType<ProviderGetResponse, Error>>(
1247                fidl::encoding::FlexibleResult::new(result.as_mut().map_err(|e| *e)),
1248                self.tx_id,
1249                0x7a2f2d2cdcfcc945,
1250                fidl::encoding::DynamicFlags::FLEXIBLE,
1251            )
1252    }
1253}
1254
1255mod internal {
1256    use super::*;
1257
1258    impl fidl::encoding::ResourceTypeMarker for PagerStatsSinkSendPagerStatsRequest {
1259        type Borrowed<'a> = &'a mut Self;
1260        fn take_or_borrow<'a>(
1261            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1262        ) -> Self::Borrowed<'a> {
1263            value
1264        }
1265    }
1266
1267    unsafe impl fidl::encoding::TypeMarker for PagerStatsSinkSendPagerStatsRequest {
1268        type Owned = Self;
1269
1270        #[inline(always)]
1271        fn inline_align(_context: fidl::encoding::Context) -> usize {
1272            4
1273        }
1274
1275        #[inline(always)]
1276        fn inline_size(_context: fidl::encoding::Context) -> usize {
1277            4
1278        }
1279    }
1280
1281    unsafe impl
1282        fidl::encoding::Encode<
1283            PagerStatsSinkSendPagerStatsRequest,
1284            fidl::encoding::DefaultFuchsiaResourceDialect,
1285        > for &mut PagerStatsSinkSendPagerStatsRequest
1286    {
1287        #[inline]
1288        unsafe fn encode(
1289            self,
1290            encoder: &mut fidl::encoding::Encoder<
1291                '_,
1292                fidl::encoding::DefaultFuchsiaResourceDialect,
1293            >,
1294            offset: usize,
1295            _depth: fidl::encoding::Depth,
1296        ) -> fidl::Result<()> {
1297            encoder.debug_check_bounds::<PagerStatsSinkSendPagerStatsRequest>(offset);
1298            // Delegate to tuple encoding.
1299            fidl::encoding::Encode::<
1300                PagerStatsSinkSendPagerStatsRequest,
1301                fidl::encoding::DefaultFuchsiaResourceDialect,
1302            >::encode(
1303                (<fidl::encoding::HandleType<
1304                    fidl::Vmo,
1305                    { fidl::ObjectType::VMO.into_raw() },
1306                    49255,
1307                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1308                    &mut self.pager_stats_vmo,
1309                ),),
1310                encoder,
1311                offset,
1312                _depth,
1313            )
1314        }
1315    }
1316    unsafe impl<
1317        T0: fidl::encoding::Encode<
1318                fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 49255>,
1319                fidl::encoding::DefaultFuchsiaResourceDialect,
1320            >,
1321    >
1322        fidl::encoding::Encode<
1323            PagerStatsSinkSendPagerStatsRequest,
1324            fidl::encoding::DefaultFuchsiaResourceDialect,
1325        > for (T0,)
1326    {
1327        #[inline]
1328        unsafe fn encode(
1329            self,
1330            encoder: &mut fidl::encoding::Encoder<
1331                '_,
1332                fidl::encoding::DefaultFuchsiaResourceDialect,
1333            >,
1334            offset: usize,
1335            depth: fidl::encoding::Depth,
1336        ) -> fidl::Result<()> {
1337            encoder.debug_check_bounds::<PagerStatsSinkSendPagerStatsRequest>(offset);
1338            // Zero out padding regions. There's no need to apply masks
1339            // because the unmasked parts will be overwritten by fields.
1340            // Write the fields.
1341            self.0.encode(encoder, offset + 0, depth)?;
1342            Ok(())
1343        }
1344    }
1345
1346    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1347        for PagerStatsSinkSendPagerStatsRequest
1348    {
1349        #[inline(always)]
1350        fn new_empty() -> Self {
1351            Self {
1352                pager_stats_vmo: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 49255>, fidl::encoding::DefaultFuchsiaResourceDialect),
1353            }
1354        }
1355
1356        #[inline]
1357        unsafe fn decode(
1358            &mut self,
1359            decoder: &mut fidl::encoding::Decoder<
1360                '_,
1361                fidl::encoding::DefaultFuchsiaResourceDialect,
1362            >,
1363            offset: usize,
1364            _depth: fidl::encoding::Depth,
1365        ) -> fidl::Result<()> {
1366            decoder.debug_check_bounds::<Self>(offset);
1367            // Verify that padding bytes are zero.
1368            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 49255>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.pager_stats_vmo, decoder, offset + 0, _depth)?;
1369            Ok(())
1370        }
1371    }
1372
1373    impl NewPrincipal {
1374        #[inline(always)]
1375        fn max_ordinal_present(&self) -> u64 {
1376            if let Some(_) = self.detailed_attribution {
1377                return 4;
1378            }
1379            if let Some(_) = self.principal_type {
1380                return 3;
1381            }
1382            if let Some(_) = self.description {
1383                return 2;
1384            }
1385            if let Some(_) = self.identifier {
1386                return 1;
1387            }
1388            0
1389        }
1390    }
1391
1392    impl fidl::encoding::ResourceTypeMarker for NewPrincipal {
1393        type Borrowed<'a> = &'a mut Self;
1394        fn take_or_borrow<'a>(
1395            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1396        ) -> Self::Borrowed<'a> {
1397            value
1398        }
1399    }
1400
1401    unsafe impl fidl::encoding::TypeMarker for NewPrincipal {
1402        type Owned = Self;
1403
1404        #[inline(always)]
1405        fn inline_align(_context: fidl::encoding::Context) -> usize {
1406            8
1407        }
1408
1409        #[inline(always)]
1410        fn inline_size(_context: fidl::encoding::Context) -> usize {
1411            16
1412        }
1413    }
1414
1415    unsafe impl fidl::encoding::Encode<NewPrincipal, fidl::encoding::DefaultFuchsiaResourceDialect>
1416        for &mut NewPrincipal
1417    {
1418        unsafe fn encode(
1419            self,
1420            encoder: &mut fidl::encoding::Encoder<
1421                '_,
1422                fidl::encoding::DefaultFuchsiaResourceDialect,
1423            >,
1424            offset: usize,
1425            mut depth: fidl::encoding::Depth,
1426        ) -> fidl::Result<()> {
1427            encoder.debug_check_bounds::<NewPrincipal>(offset);
1428            // Vector header
1429            let max_ordinal: u64 = self.max_ordinal_present();
1430            encoder.write_num(max_ordinal, offset);
1431            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1432            // Calling encoder.out_of_line_offset(0) is not allowed.
1433            if max_ordinal == 0 {
1434                return Ok(());
1435            }
1436            depth.increment()?;
1437            let envelope_size = 8;
1438            let bytes_len = max_ordinal as usize * envelope_size;
1439            #[allow(unused_variables)]
1440            let offset = encoder.out_of_line_offset(bytes_len);
1441            let mut _prev_end_offset: usize = 0;
1442            if 1 > max_ordinal {
1443                return Ok(());
1444            }
1445
1446            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1447            // are envelope_size bytes.
1448            let cur_offset: usize = (1 - 1) * envelope_size;
1449
1450            // Zero reserved fields.
1451            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1452
1453            // Safety:
1454            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1455            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1456            //   envelope_size bytes, there is always sufficient room.
1457            fidl::encoding::encode_in_envelope_optional::<
1458                u64,
1459                fidl::encoding::DefaultFuchsiaResourceDialect,
1460            >(
1461                self.identifier.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
1462                encoder,
1463                offset + cur_offset,
1464                depth,
1465            )?;
1466
1467            _prev_end_offset = cur_offset + envelope_size;
1468            if 2 > max_ordinal {
1469                return Ok(());
1470            }
1471
1472            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1473            // are envelope_size bytes.
1474            let cur_offset: usize = (2 - 1) * envelope_size;
1475
1476            // Zero reserved fields.
1477            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1478
1479            // Safety:
1480            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1481            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1482            //   envelope_size bytes, there is always sufficient room.
1483            fidl::encoding::encode_in_envelope_optional::<
1484                Description,
1485                fidl::encoding::DefaultFuchsiaResourceDialect,
1486            >(
1487                self.description
1488                    .as_mut()
1489                    .map(<Description as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
1490                encoder,
1491                offset + cur_offset,
1492                depth,
1493            )?;
1494
1495            _prev_end_offset = cur_offset + envelope_size;
1496            if 3 > max_ordinal {
1497                return Ok(());
1498            }
1499
1500            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1501            // are envelope_size bytes.
1502            let cur_offset: usize = (3 - 1) * envelope_size;
1503
1504            // Zero reserved fields.
1505            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1506
1507            // Safety:
1508            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1509            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1510            //   envelope_size bytes, there is always sufficient room.
1511            fidl::encoding::encode_in_envelope_optional::<
1512                PrincipalType,
1513                fidl::encoding::DefaultFuchsiaResourceDialect,
1514            >(
1515                self.principal_type
1516                    .as_ref()
1517                    .map(<PrincipalType as fidl::encoding::ValueTypeMarker>::borrow),
1518                encoder,
1519                offset + cur_offset,
1520                depth,
1521            )?;
1522
1523            _prev_end_offset = cur_offset + envelope_size;
1524            if 4 > max_ordinal {
1525                return Ok(());
1526            }
1527
1528            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1529            // are envelope_size bytes.
1530            let cur_offset: usize = (4 - 1) * envelope_size;
1531
1532            // Zero reserved fields.
1533            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1534
1535            // Safety:
1536            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1537            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1538            //   envelope_size bytes, there is always sufficient room.
1539            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
1540            self.detailed_attribution.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
1541            encoder, offset + cur_offset, depth
1542        )?;
1543
1544            _prev_end_offset = cur_offset + envelope_size;
1545
1546            Ok(())
1547        }
1548    }
1549
1550    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for NewPrincipal {
1551        #[inline(always)]
1552        fn new_empty() -> Self {
1553            Self::default()
1554        }
1555
1556        unsafe fn decode(
1557            &mut self,
1558            decoder: &mut fidl::encoding::Decoder<
1559                '_,
1560                fidl::encoding::DefaultFuchsiaResourceDialect,
1561            >,
1562            offset: usize,
1563            mut depth: fidl::encoding::Depth,
1564        ) -> fidl::Result<()> {
1565            decoder.debug_check_bounds::<Self>(offset);
1566            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1567                None => return Err(fidl::Error::NotNullable),
1568                Some(len) => len,
1569            };
1570            // Calling decoder.out_of_line_offset(0) is not allowed.
1571            if len == 0 {
1572                return Ok(());
1573            };
1574            depth.increment()?;
1575            let envelope_size = 8;
1576            let bytes_len = len * envelope_size;
1577            let offset = decoder.out_of_line_offset(bytes_len)?;
1578            // Decode the envelope for each type.
1579            let mut _next_ordinal_to_read = 0;
1580            let mut next_offset = offset;
1581            let end_offset = offset + bytes_len;
1582            _next_ordinal_to_read += 1;
1583            if next_offset >= end_offset {
1584                return Ok(());
1585            }
1586
1587            // Decode unknown envelopes for gaps in ordinals.
1588            while _next_ordinal_to_read < 1 {
1589                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1590                _next_ordinal_to_read += 1;
1591                next_offset += envelope_size;
1592            }
1593
1594            let next_out_of_line = decoder.next_out_of_line();
1595            let handles_before = decoder.remaining_handles();
1596            if let Some((inlined, num_bytes, num_handles)) =
1597                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1598            {
1599                let member_inline_size =
1600                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1601                if inlined != (member_inline_size <= 4) {
1602                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1603                }
1604                let inner_offset;
1605                let mut inner_depth = depth.clone();
1606                if inlined {
1607                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1608                    inner_offset = next_offset;
1609                } else {
1610                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1611                    inner_depth.increment()?;
1612                }
1613                let val_ref = self.identifier.get_or_insert_with(|| {
1614                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
1615                });
1616                fidl::decode!(
1617                    u64,
1618                    fidl::encoding::DefaultFuchsiaResourceDialect,
1619                    val_ref,
1620                    decoder,
1621                    inner_offset,
1622                    inner_depth
1623                )?;
1624                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1625                {
1626                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1627                }
1628                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1629                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1630                }
1631            }
1632
1633            next_offset += envelope_size;
1634            _next_ordinal_to_read += 1;
1635            if next_offset >= end_offset {
1636                return Ok(());
1637            }
1638
1639            // Decode unknown envelopes for gaps in ordinals.
1640            while _next_ordinal_to_read < 2 {
1641                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1642                _next_ordinal_to_read += 1;
1643                next_offset += envelope_size;
1644            }
1645
1646            let next_out_of_line = decoder.next_out_of_line();
1647            let handles_before = decoder.remaining_handles();
1648            if let Some((inlined, num_bytes, num_handles)) =
1649                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1650            {
1651                let member_inline_size =
1652                    <Description as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1653                if inlined != (member_inline_size <= 4) {
1654                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1655                }
1656                let inner_offset;
1657                let mut inner_depth = depth.clone();
1658                if inlined {
1659                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1660                    inner_offset = next_offset;
1661                } else {
1662                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1663                    inner_depth.increment()?;
1664                }
1665                let val_ref = self.description.get_or_insert_with(|| {
1666                    fidl::new_empty!(Description, fidl::encoding::DefaultFuchsiaResourceDialect)
1667                });
1668                fidl::decode!(
1669                    Description,
1670                    fidl::encoding::DefaultFuchsiaResourceDialect,
1671                    val_ref,
1672                    decoder,
1673                    inner_offset,
1674                    inner_depth
1675                )?;
1676                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1677                {
1678                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1679                }
1680                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1681                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1682                }
1683            }
1684
1685            next_offset += envelope_size;
1686            _next_ordinal_to_read += 1;
1687            if next_offset >= end_offset {
1688                return Ok(());
1689            }
1690
1691            // Decode unknown envelopes for gaps in ordinals.
1692            while _next_ordinal_to_read < 3 {
1693                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1694                _next_ordinal_to_read += 1;
1695                next_offset += envelope_size;
1696            }
1697
1698            let next_out_of_line = decoder.next_out_of_line();
1699            let handles_before = decoder.remaining_handles();
1700            if let Some((inlined, num_bytes, num_handles)) =
1701                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1702            {
1703                let member_inline_size =
1704                    <PrincipalType as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1705                if inlined != (member_inline_size <= 4) {
1706                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1707                }
1708                let inner_offset;
1709                let mut inner_depth = depth.clone();
1710                if inlined {
1711                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1712                    inner_offset = next_offset;
1713                } else {
1714                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1715                    inner_depth.increment()?;
1716                }
1717                let val_ref = self.principal_type.get_or_insert_with(|| {
1718                    fidl::new_empty!(PrincipalType, fidl::encoding::DefaultFuchsiaResourceDialect)
1719                });
1720                fidl::decode!(
1721                    PrincipalType,
1722                    fidl::encoding::DefaultFuchsiaResourceDialect,
1723                    val_ref,
1724                    decoder,
1725                    inner_offset,
1726                    inner_depth
1727                )?;
1728                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1729                {
1730                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1731                }
1732                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1733                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1734                }
1735            }
1736
1737            next_offset += envelope_size;
1738            _next_ordinal_to_read += 1;
1739            if next_offset >= end_offset {
1740                return Ok(());
1741            }
1742
1743            // Decode unknown envelopes for gaps in ordinals.
1744            while _next_ordinal_to_read < 4 {
1745                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1746                _next_ordinal_to_read += 1;
1747                next_offset += envelope_size;
1748            }
1749
1750            let next_out_of_line = decoder.next_out_of_line();
1751            let handles_before = decoder.remaining_handles();
1752            if let Some((inlined, num_bytes, num_handles)) =
1753                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1754            {
1755                let member_inline_size = <fidl::encoding::Endpoint<
1756                    fidl::endpoints::ClientEnd<ProviderMarker>,
1757                > as fidl::encoding::TypeMarker>::inline_size(
1758                    decoder.context
1759                );
1760                if inlined != (member_inline_size <= 4) {
1761                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1762                }
1763                let inner_offset;
1764                let mut inner_depth = depth.clone();
1765                if inlined {
1766                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1767                    inner_offset = next_offset;
1768                } else {
1769                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1770                    inner_depth.increment()?;
1771                }
1772                let val_ref = self.detailed_attribution.get_or_insert_with(|| {
1773                    fidl::new_empty!(
1774                        fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderMarker>>,
1775                        fidl::encoding::DefaultFuchsiaResourceDialect
1776                    )
1777                });
1778                fidl::decode!(
1779                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderMarker>>,
1780                    fidl::encoding::DefaultFuchsiaResourceDialect,
1781                    val_ref,
1782                    decoder,
1783                    inner_offset,
1784                    inner_depth
1785                )?;
1786                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1787                {
1788                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1789                }
1790                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1791                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1792                }
1793            }
1794
1795            next_offset += envelope_size;
1796
1797            // Decode the remaining unknown envelopes.
1798            while next_offset < end_offset {
1799                _next_ordinal_to_read += 1;
1800                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1801                next_offset += envelope_size;
1802            }
1803
1804            Ok(())
1805        }
1806    }
1807
1808    impl ProviderGetResponse {
1809        #[inline(always)]
1810        fn max_ordinal_present(&self) -> u64 {
1811            if let Some(_) = self.attributions {
1812                return 1;
1813            }
1814            0
1815        }
1816    }
1817
1818    impl fidl::encoding::ResourceTypeMarker for ProviderGetResponse {
1819        type Borrowed<'a> = &'a mut Self;
1820        fn take_or_borrow<'a>(
1821            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1822        ) -> Self::Borrowed<'a> {
1823            value
1824        }
1825    }
1826
1827    unsafe impl fidl::encoding::TypeMarker for ProviderGetResponse {
1828        type Owned = Self;
1829
1830        #[inline(always)]
1831        fn inline_align(_context: fidl::encoding::Context) -> usize {
1832            8
1833        }
1834
1835        #[inline(always)]
1836        fn inline_size(_context: fidl::encoding::Context) -> usize {
1837            16
1838        }
1839    }
1840
1841    unsafe impl
1842        fidl::encoding::Encode<ProviderGetResponse, fidl::encoding::DefaultFuchsiaResourceDialect>
1843        for &mut ProviderGetResponse
1844    {
1845        unsafe fn encode(
1846            self,
1847            encoder: &mut fidl::encoding::Encoder<
1848                '_,
1849                fidl::encoding::DefaultFuchsiaResourceDialect,
1850            >,
1851            offset: usize,
1852            mut depth: fidl::encoding::Depth,
1853        ) -> fidl::Result<()> {
1854            encoder.debug_check_bounds::<ProviderGetResponse>(offset);
1855            // Vector header
1856            let max_ordinal: u64 = self.max_ordinal_present();
1857            encoder.write_num(max_ordinal, offset);
1858            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1859            // Calling encoder.out_of_line_offset(0) is not allowed.
1860            if max_ordinal == 0 {
1861                return Ok(());
1862            }
1863            depth.increment()?;
1864            let envelope_size = 8;
1865            let bytes_len = max_ordinal as usize * envelope_size;
1866            #[allow(unused_variables)]
1867            let offset = encoder.out_of_line_offset(bytes_len);
1868            let mut _prev_end_offset: usize = 0;
1869            if 1 > max_ordinal {
1870                return Ok(());
1871            }
1872
1873            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1874            // are envelope_size bytes.
1875            let cur_offset: usize = (1 - 1) * envelope_size;
1876
1877            // Zero reserved fields.
1878            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1879
1880            // Safety:
1881            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1882            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1883            //   envelope_size bytes, there is always sufficient room.
1884            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<AttributionUpdate>, fidl::encoding::DefaultFuchsiaResourceDialect>(
1885            self.attributions.as_mut().map(<fidl::encoding::UnboundedVector<AttributionUpdate> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
1886            encoder, offset + cur_offset, depth
1887        )?;
1888
1889            _prev_end_offset = cur_offset + envelope_size;
1890
1891            Ok(())
1892        }
1893    }
1894
1895    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1896        for ProviderGetResponse
1897    {
1898        #[inline(always)]
1899        fn new_empty() -> Self {
1900            Self::default()
1901        }
1902
1903        unsafe fn decode(
1904            &mut self,
1905            decoder: &mut fidl::encoding::Decoder<
1906                '_,
1907                fidl::encoding::DefaultFuchsiaResourceDialect,
1908            >,
1909            offset: usize,
1910            mut depth: fidl::encoding::Depth,
1911        ) -> fidl::Result<()> {
1912            decoder.debug_check_bounds::<Self>(offset);
1913            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1914                None => return Err(fidl::Error::NotNullable),
1915                Some(len) => len,
1916            };
1917            // Calling decoder.out_of_line_offset(0) is not allowed.
1918            if len == 0 {
1919                return Ok(());
1920            };
1921            depth.increment()?;
1922            let envelope_size = 8;
1923            let bytes_len = len * envelope_size;
1924            let offset = decoder.out_of_line_offset(bytes_len)?;
1925            // Decode the envelope for each type.
1926            let mut _next_ordinal_to_read = 0;
1927            let mut next_offset = offset;
1928            let end_offset = offset + bytes_len;
1929            _next_ordinal_to_read += 1;
1930            if next_offset >= end_offset {
1931                return Ok(());
1932            }
1933
1934            // Decode unknown envelopes for gaps in ordinals.
1935            while _next_ordinal_to_read < 1 {
1936                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1937                _next_ordinal_to_read += 1;
1938                next_offset += envelope_size;
1939            }
1940
1941            let next_out_of_line = decoder.next_out_of_line();
1942            let handles_before = decoder.remaining_handles();
1943            if let Some((inlined, num_bytes, num_handles)) =
1944                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1945            {
1946                let member_inline_size = <fidl::encoding::UnboundedVector<AttributionUpdate> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1947                if inlined != (member_inline_size <= 4) {
1948                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1949                }
1950                let inner_offset;
1951                let mut inner_depth = depth.clone();
1952                if inlined {
1953                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1954                    inner_offset = next_offset;
1955                } else {
1956                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1957                    inner_depth.increment()?;
1958                }
1959                let val_ref = self.attributions.get_or_insert_with(|| {
1960                    fidl::new_empty!(
1961                        fidl::encoding::UnboundedVector<AttributionUpdate>,
1962                        fidl::encoding::DefaultFuchsiaResourceDialect
1963                    )
1964                });
1965                fidl::decode!(
1966                    fidl::encoding::UnboundedVector<AttributionUpdate>,
1967                    fidl::encoding::DefaultFuchsiaResourceDialect,
1968                    val_ref,
1969                    decoder,
1970                    inner_offset,
1971                    inner_depth
1972                )?;
1973                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1974                {
1975                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1976                }
1977                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1978                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1979                }
1980            }
1981
1982            next_offset += envelope_size;
1983
1984            // Decode the remaining unknown envelopes.
1985            while next_offset < end_offset {
1986                _next_ordinal_to_read += 1;
1987                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1988                next_offset += envelope_size;
1989            }
1990
1991            Ok(())
1992        }
1993    }
1994
1995    impl UpdatedPrincipal {
1996        #[inline(always)]
1997        fn max_ordinal_present(&self) -> u64 {
1998            if let Some(_) = self.resources {
1999                return 2;
2000            }
2001            if let Some(_) = self.identifier {
2002                return 1;
2003            }
2004            0
2005        }
2006    }
2007
2008    impl fidl::encoding::ResourceTypeMarker for UpdatedPrincipal {
2009        type Borrowed<'a> = &'a mut Self;
2010        fn take_or_borrow<'a>(
2011            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2012        ) -> Self::Borrowed<'a> {
2013            value
2014        }
2015    }
2016
2017    unsafe impl fidl::encoding::TypeMarker for UpdatedPrincipal {
2018        type Owned = Self;
2019
2020        #[inline(always)]
2021        fn inline_align(_context: fidl::encoding::Context) -> usize {
2022            8
2023        }
2024
2025        #[inline(always)]
2026        fn inline_size(_context: fidl::encoding::Context) -> usize {
2027            16
2028        }
2029    }
2030
2031    unsafe impl
2032        fidl::encoding::Encode<UpdatedPrincipal, fidl::encoding::DefaultFuchsiaResourceDialect>
2033        for &mut UpdatedPrincipal
2034    {
2035        unsafe fn encode(
2036            self,
2037            encoder: &mut fidl::encoding::Encoder<
2038                '_,
2039                fidl::encoding::DefaultFuchsiaResourceDialect,
2040            >,
2041            offset: usize,
2042            mut depth: fidl::encoding::Depth,
2043        ) -> fidl::Result<()> {
2044            encoder.debug_check_bounds::<UpdatedPrincipal>(offset);
2045            // Vector header
2046            let max_ordinal: u64 = self.max_ordinal_present();
2047            encoder.write_num(max_ordinal, offset);
2048            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2049            // Calling encoder.out_of_line_offset(0) is not allowed.
2050            if max_ordinal == 0 {
2051                return Ok(());
2052            }
2053            depth.increment()?;
2054            let envelope_size = 8;
2055            let bytes_len = max_ordinal as usize * envelope_size;
2056            #[allow(unused_variables)]
2057            let offset = encoder.out_of_line_offset(bytes_len);
2058            let mut _prev_end_offset: usize = 0;
2059            if 1 > max_ordinal {
2060                return Ok(());
2061            }
2062
2063            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2064            // are envelope_size bytes.
2065            let cur_offset: usize = (1 - 1) * envelope_size;
2066
2067            // Zero reserved fields.
2068            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2069
2070            // Safety:
2071            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2072            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2073            //   envelope_size bytes, there is always sufficient room.
2074            fidl::encoding::encode_in_envelope_optional::<
2075                u64,
2076                fidl::encoding::DefaultFuchsiaResourceDialect,
2077            >(
2078                self.identifier.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
2079                encoder,
2080                offset + cur_offset,
2081                depth,
2082            )?;
2083
2084            _prev_end_offset = cur_offset + envelope_size;
2085            if 2 > max_ordinal {
2086                return Ok(());
2087            }
2088
2089            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2090            // are envelope_size bytes.
2091            let cur_offset: usize = (2 - 1) * envelope_size;
2092
2093            // Zero reserved fields.
2094            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2095
2096            // Safety:
2097            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2098            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2099            //   envelope_size bytes, there is always sufficient room.
2100            fidl::encoding::encode_in_envelope_optional::<
2101                Resources,
2102                fidl::encoding::DefaultFuchsiaResourceDialect,
2103            >(
2104                self.resources
2105                    .as_mut()
2106                    .map(<Resources as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
2107                encoder,
2108                offset + cur_offset,
2109                depth,
2110            )?;
2111
2112            _prev_end_offset = cur_offset + envelope_size;
2113
2114            Ok(())
2115        }
2116    }
2117
2118    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2119        for UpdatedPrincipal
2120    {
2121        #[inline(always)]
2122        fn new_empty() -> Self {
2123            Self::default()
2124        }
2125
2126        unsafe fn decode(
2127            &mut self,
2128            decoder: &mut fidl::encoding::Decoder<
2129                '_,
2130                fidl::encoding::DefaultFuchsiaResourceDialect,
2131            >,
2132            offset: usize,
2133            mut depth: fidl::encoding::Depth,
2134        ) -> fidl::Result<()> {
2135            decoder.debug_check_bounds::<Self>(offset);
2136            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2137                None => return Err(fidl::Error::NotNullable),
2138                Some(len) => len,
2139            };
2140            // Calling decoder.out_of_line_offset(0) is not allowed.
2141            if len == 0 {
2142                return Ok(());
2143            };
2144            depth.increment()?;
2145            let envelope_size = 8;
2146            let bytes_len = len * envelope_size;
2147            let offset = decoder.out_of_line_offset(bytes_len)?;
2148            // Decode the envelope for each type.
2149            let mut _next_ordinal_to_read = 0;
2150            let mut next_offset = offset;
2151            let end_offset = offset + bytes_len;
2152            _next_ordinal_to_read += 1;
2153            if next_offset >= end_offset {
2154                return Ok(());
2155            }
2156
2157            // Decode unknown envelopes for gaps in ordinals.
2158            while _next_ordinal_to_read < 1 {
2159                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2160                _next_ordinal_to_read += 1;
2161                next_offset += envelope_size;
2162            }
2163
2164            let next_out_of_line = decoder.next_out_of_line();
2165            let handles_before = decoder.remaining_handles();
2166            if let Some((inlined, num_bytes, num_handles)) =
2167                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2168            {
2169                let member_inline_size =
2170                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2171                if inlined != (member_inline_size <= 4) {
2172                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2173                }
2174                let inner_offset;
2175                let mut inner_depth = depth.clone();
2176                if inlined {
2177                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2178                    inner_offset = next_offset;
2179                } else {
2180                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2181                    inner_depth.increment()?;
2182                }
2183                let val_ref = self.identifier.get_or_insert_with(|| {
2184                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
2185                });
2186                fidl::decode!(
2187                    u64,
2188                    fidl::encoding::DefaultFuchsiaResourceDialect,
2189                    val_ref,
2190                    decoder,
2191                    inner_offset,
2192                    inner_depth
2193                )?;
2194                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2195                {
2196                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2197                }
2198                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2199                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2200                }
2201            }
2202
2203            next_offset += envelope_size;
2204            _next_ordinal_to_read += 1;
2205            if next_offset >= end_offset {
2206                return Ok(());
2207            }
2208
2209            // Decode unknown envelopes for gaps in ordinals.
2210            while _next_ordinal_to_read < 2 {
2211                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2212                _next_ordinal_to_read += 1;
2213                next_offset += envelope_size;
2214            }
2215
2216            let next_out_of_line = decoder.next_out_of_line();
2217            let handles_before = decoder.remaining_handles();
2218            if let Some((inlined, num_bytes, num_handles)) =
2219                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2220            {
2221                let member_inline_size =
2222                    <Resources as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2223                if inlined != (member_inline_size <= 4) {
2224                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2225                }
2226                let inner_offset;
2227                let mut inner_depth = depth.clone();
2228                if inlined {
2229                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2230                    inner_offset = next_offset;
2231                } else {
2232                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2233                    inner_depth.increment()?;
2234                }
2235                let val_ref = self.resources.get_or_insert_with(|| {
2236                    fidl::new_empty!(Resources, fidl::encoding::DefaultFuchsiaResourceDialect)
2237                });
2238                fidl::decode!(
2239                    Resources,
2240                    fidl::encoding::DefaultFuchsiaResourceDialect,
2241                    val_ref,
2242                    decoder,
2243                    inner_offset,
2244                    inner_depth
2245                )?;
2246                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2247                {
2248                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2249                }
2250                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2251                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2252                }
2253            }
2254
2255            next_offset += envelope_size;
2256
2257            // Decode the remaining unknown envelopes.
2258            while next_offset < end_offset {
2259                _next_ordinal_to_read += 1;
2260                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2261                next_offset += envelope_size;
2262            }
2263
2264            Ok(())
2265        }
2266    }
2267
2268    impl fidl::encoding::ResourceTypeMarker for AttributionUpdate {
2269        type Borrowed<'a> = &'a mut Self;
2270        fn take_or_borrow<'a>(
2271            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2272        ) -> Self::Borrowed<'a> {
2273            value
2274        }
2275    }
2276
2277    unsafe impl fidl::encoding::TypeMarker for AttributionUpdate {
2278        type Owned = Self;
2279
2280        #[inline(always)]
2281        fn inline_align(_context: fidl::encoding::Context) -> usize {
2282            8
2283        }
2284
2285        #[inline(always)]
2286        fn inline_size(_context: fidl::encoding::Context) -> usize {
2287            16
2288        }
2289    }
2290
2291    unsafe impl
2292        fidl::encoding::Encode<AttributionUpdate, fidl::encoding::DefaultFuchsiaResourceDialect>
2293        for &mut AttributionUpdate
2294    {
2295        #[inline]
2296        unsafe fn encode(
2297            self,
2298            encoder: &mut fidl::encoding::Encoder<
2299                '_,
2300                fidl::encoding::DefaultFuchsiaResourceDialect,
2301            >,
2302            offset: usize,
2303            _depth: fidl::encoding::Depth,
2304        ) -> fidl::Result<()> {
2305            encoder.debug_check_bounds::<AttributionUpdate>(offset);
2306            encoder.write_num::<u64>(self.ordinal(), offset);
2307            match self {
2308                AttributionUpdate::Add(ref mut val) => fidl::encoding::encode_in_envelope::<
2309                    NewPrincipal,
2310                    fidl::encoding::DefaultFuchsiaResourceDialect,
2311                >(
2312                    <NewPrincipal as fidl::encoding::ResourceTypeMarker>::take_or_borrow(val),
2313                    encoder,
2314                    offset + 8,
2315                    _depth,
2316                ),
2317                AttributionUpdate::Update(ref mut val) => fidl::encoding::encode_in_envelope::<
2318                    UpdatedPrincipal,
2319                    fidl::encoding::DefaultFuchsiaResourceDialect,
2320                >(
2321                    <UpdatedPrincipal as fidl::encoding::ResourceTypeMarker>::take_or_borrow(val),
2322                    encoder,
2323                    offset + 8,
2324                    _depth,
2325                ),
2326                AttributionUpdate::Remove(ref val) => fidl::encoding::encode_in_envelope::<
2327                    u64,
2328                    fidl::encoding::DefaultFuchsiaResourceDialect,
2329                >(
2330                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(val),
2331                    encoder,
2332                    offset + 8,
2333                    _depth,
2334                ),
2335                AttributionUpdate::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
2336            }
2337        }
2338    }
2339
2340    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2341        for AttributionUpdate
2342    {
2343        #[inline(always)]
2344        fn new_empty() -> Self {
2345            Self::__SourceBreaking { unknown_ordinal: 0 }
2346        }
2347
2348        #[inline]
2349        unsafe fn decode(
2350            &mut self,
2351            decoder: &mut fidl::encoding::Decoder<
2352                '_,
2353                fidl::encoding::DefaultFuchsiaResourceDialect,
2354            >,
2355            offset: usize,
2356            mut depth: fidl::encoding::Depth,
2357        ) -> fidl::Result<()> {
2358            decoder.debug_check_bounds::<Self>(offset);
2359            #[allow(unused_variables)]
2360            let next_out_of_line = decoder.next_out_of_line();
2361            let handles_before = decoder.remaining_handles();
2362            let (ordinal, inlined, num_bytes, num_handles) =
2363                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2364
2365            let member_inline_size = match ordinal {
2366                1 => <NewPrincipal as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2367                2 => <UpdatedPrincipal as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2368                3 => <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2369                0 => return Err(fidl::Error::UnknownUnionTag),
2370                _ => num_bytes as usize,
2371            };
2372
2373            if inlined != (member_inline_size <= 4) {
2374                return Err(fidl::Error::InvalidInlineBitInEnvelope);
2375            }
2376            let _inner_offset;
2377            if inlined {
2378                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2379                _inner_offset = offset + 8;
2380            } else {
2381                depth.increment()?;
2382                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2383            }
2384            match ordinal {
2385                1 => {
2386                    #[allow(irrefutable_let_patterns)]
2387                    if let AttributionUpdate::Add(_) = self {
2388                        // Do nothing, read the value into the object
2389                    } else {
2390                        // Initialize `self` to the right variant
2391                        *self = AttributionUpdate::Add(fidl::new_empty!(
2392                            NewPrincipal,
2393                            fidl::encoding::DefaultFuchsiaResourceDialect
2394                        ));
2395                    }
2396                    #[allow(irrefutable_let_patterns)]
2397                    if let AttributionUpdate::Add(ref mut val) = self {
2398                        fidl::decode!(
2399                            NewPrincipal,
2400                            fidl::encoding::DefaultFuchsiaResourceDialect,
2401                            val,
2402                            decoder,
2403                            _inner_offset,
2404                            depth
2405                        )?;
2406                    } else {
2407                        unreachable!()
2408                    }
2409                }
2410                2 => {
2411                    #[allow(irrefutable_let_patterns)]
2412                    if let AttributionUpdate::Update(_) = self {
2413                        // Do nothing, read the value into the object
2414                    } else {
2415                        // Initialize `self` to the right variant
2416                        *self = AttributionUpdate::Update(fidl::new_empty!(
2417                            UpdatedPrincipal,
2418                            fidl::encoding::DefaultFuchsiaResourceDialect
2419                        ));
2420                    }
2421                    #[allow(irrefutable_let_patterns)]
2422                    if let AttributionUpdate::Update(ref mut val) = self {
2423                        fidl::decode!(
2424                            UpdatedPrincipal,
2425                            fidl::encoding::DefaultFuchsiaResourceDialect,
2426                            val,
2427                            decoder,
2428                            _inner_offset,
2429                            depth
2430                        )?;
2431                    } else {
2432                        unreachable!()
2433                    }
2434                }
2435                3 => {
2436                    #[allow(irrefutable_let_patterns)]
2437                    if let AttributionUpdate::Remove(_) = self {
2438                        // Do nothing, read the value into the object
2439                    } else {
2440                        // Initialize `self` to the right variant
2441                        *self = AttributionUpdate::Remove(fidl::new_empty!(
2442                            u64,
2443                            fidl::encoding::DefaultFuchsiaResourceDialect
2444                        ));
2445                    }
2446                    #[allow(irrefutable_let_patterns)]
2447                    if let AttributionUpdate::Remove(ref mut val) = self {
2448                        fidl::decode!(
2449                            u64,
2450                            fidl::encoding::DefaultFuchsiaResourceDialect,
2451                            val,
2452                            decoder,
2453                            _inner_offset,
2454                            depth
2455                        )?;
2456                    } else {
2457                        unreachable!()
2458                    }
2459                }
2460                #[allow(deprecated)]
2461                ordinal => {
2462                    for _ in 0..num_handles {
2463                        decoder.drop_next_handle()?;
2464                    }
2465                    *self = AttributionUpdate::__SourceBreaking { unknown_ordinal: ordinal };
2466                }
2467            }
2468            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2469                return Err(fidl::Error::InvalidNumBytesInEnvelope);
2470            }
2471            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2472                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2473            }
2474            Ok(())
2475        }
2476    }
2477
2478    impl fidl::encoding::ResourceTypeMarker for Description {
2479        type Borrowed<'a> = &'a mut Self;
2480        fn take_or_borrow<'a>(
2481            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2482        ) -> Self::Borrowed<'a> {
2483            value
2484        }
2485    }
2486
2487    unsafe impl fidl::encoding::TypeMarker for Description {
2488        type Owned = Self;
2489
2490        #[inline(always)]
2491        fn inline_align(_context: fidl::encoding::Context) -> usize {
2492            8
2493        }
2494
2495        #[inline(always)]
2496        fn inline_size(_context: fidl::encoding::Context) -> usize {
2497            16
2498        }
2499    }
2500
2501    unsafe impl fidl::encoding::Encode<Description, fidl::encoding::DefaultFuchsiaResourceDialect>
2502        for &mut Description
2503    {
2504        #[inline]
2505        unsafe fn encode(
2506            self,
2507            encoder: &mut fidl::encoding::Encoder<
2508                '_,
2509                fidl::encoding::DefaultFuchsiaResourceDialect,
2510            >,
2511            offset: usize,
2512            _depth: fidl::encoding::Depth,
2513        ) -> fidl::Result<()> {
2514            encoder.debug_check_bounds::<Description>(offset);
2515            encoder.write_num::<u64>(self.ordinal(), offset);
2516            match self {
2517                Description::Component(ref mut val) => fidl::encoding::encode_in_envelope::<
2518                    fidl::encoding::HandleType<
2519                        fidl::Event,
2520                        { fidl::ObjectType::EVENT.into_raw() },
2521                        2147483648,
2522                    >,
2523                    fidl::encoding::DefaultFuchsiaResourceDialect,
2524                >(
2525                    <fidl::encoding::HandleType<
2526                        fidl::Event,
2527                        { fidl::ObjectType::EVENT.into_raw() },
2528                        2147483648,
2529                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2530                        val
2531                    ),
2532                    encoder,
2533                    offset + 8,
2534                    _depth,
2535                ),
2536                Description::Part(ref val) => fidl::encoding::encode_in_envelope::<
2537                    fidl::encoding::UnboundedString,
2538                    fidl::encoding::DefaultFuchsiaResourceDialect,
2539                >(
2540                    <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(
2541                        val,
2542                    ),
2543                    encoder,
2544                    offset + 8,
2545                    _depth,
2546                ),
2547                Description::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
2548            }
2549        }
2550    }
2551
2552    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Description {
2553        #[inline(always)]
2554        fn new_empty() -> Self {
2555            Self::__SourceBreaking { unknown_ordinal: 0 }
2556        }
2557
2558        #[inline]
2559        unsafe fn decode(
2560            &mut self,
2561            decoder: &mut fidl::encoding::Decoder<
2562                '_,
2563                fidl::encoding::DefaultFuchsiaResourceDialect,
2564            >,
2565            offset: usize,
2566            mut depth: fidl::encoding::Depth,
2567        ) -> fidl::Result<()> {
2568            decoder.debug_check_bounds::<Self>(offset);
2569            #[allow(unused_variables)]
2570            let next_out_of_line = decoder.next_out_of_line();
2571            let handles_before = decoder.remaining_handles();
2572            let (ordinal, inlined, num_bytes, num_handles) =
2573                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2574
2575            let member_inline_size = match ordinal {
2576                1 => <fidl::encoding::HandleType<
2577                    fidl::Event,
2578                    { fidl::ObjectType::EVENT.into_raw() },
2579                    2147483648,
2580                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2581                2 => <fidl::encoding::UnboundedString as fidl::encoding::TypeMarker>::inline_size(
2582                    decoder.context,
2583                ),
2584                0 => return Err(fidl::Error::UnknownUnionTag),
2585                _ => num_bytes as usize,
2586            };
2587
2588            if inlined != (member_inline_size <= 4) {
2589                return Err(fidl::Error::InvalidInlineBitInEnvelope);
2590            }
2591            let _inner_offset;
2592            if inlined {
2593                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2594                _inner_offset = offset + 8;
2595            } else {
2596                depth.increment()?;
2597                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2598            }
2599            match ordinal {
2600                1 => {
2601                    #[allow(irrefutable_let_patterns)]
2602                    if let Description::Component(_) = self {
2603                        // Do nothing, read the value into the object
2604                    } else {
2605                        // Initialize `self` to the right variant
2606                        *self = Description::Component(
2607                            fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
2608                        );
2609                    }
2610                    #[allow(irrefutable_let_patterns)]
2611                    if let Description::Component(ref mut val) = self {
2612                        fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val, decoder, _inner_offset, depth)?;
2613                    } else {
2614                        unreachable!()
2615                    }
2616                }
2617                2 => {
2618                    #[allow(irrefutable_let_patterns)]
2619                    if let Description::Part(_) = self {
2620                        // Do nothing, read the value into the object
2621                    } else {
2622                        // Initialize `self` to the right variant
2623                        *self = Description::Part(fidl::new_empty!(
2624                            fidl::encoding::UnboundedString,
2625                            fidl::encoding::DefaultFuchsiaResourceDialect
2626                        ));
2627                    }
2628                    #[allow(irrefutable_let_patterns)]
2629                    if let Description::Part(ref mut val) = self {
2630                        fidl::decode!(
2631                            fidl::encoding::UnboundedString,
2632                            fidl::encoding::DefaultFuchsiaResourceDialect,
2633                            val,
2634                            decoder,
2635                            _inner_offset,
2636                            depth
2637                        )?;
2638                    } else {
2639                        unreachable!()
2640                    }
2641                }
2642                #[allow(deprecated)]
2643                ordinal => {
2644                    for _ in 0..num_handles {
2645                        decoder.drop_next_handle()?;
2646                    }
2647                    *self = Description::__SourceBreaking { unknown_ordinal: ordinal };
2648                }
2649            }
2650            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2651                return Err(fidl::Error::InvalidNumBytesInEnvelope);
2652            }
2653            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2654                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2655            }
2656            Ok(())
2657        }
2658    }
2659
2660    impl fidl::encoding::ResourceTypeMarker for Resources {
2661        type Borrowed<'a> = &'a mut Self;
2662        fn take_or_borrow<'a>(
2663            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2664        ) -> Self::Borrowed<'a> {
2665            value
2666        }
2667    }
2668
2669    unsafe impl fidl::encoding::TypeMarker for Resources {
2670        type Owned = Self;
2671
2672        #[inline(always)]
2673        fn inline_align(_context: fidl::encoding::Context) -> usize {
2674            8
2675        }
2676
2677        #[inline(always)]
2678        fn inline_size(_context: fidl::encoding::Context) -> usize {
2679            16
2680        }
2681    }
2682
2683    unsafe impl fidl::encoding::Encode<Resources, fidl::encoding::DefaultFuchsiaResourceDialect>
2684        for &mut Resources
2685    {
2686        #[inline]
2687        unsafe fn encode(
2688            self,
2689            encoder: &mut fidl::encoding::Encoder<
2690                '_,
2691                fidl::encoding::DefaultFuchsiaResourceDialect,
2692            >,
2693            offset: usize,
2694            _depth: fidl::encoding::Depth,
2695        ) -> fidl::Result<()> {
2696            encoder.debug_check_bounds::<Resources>(offset);
2697            encoder.write_num::<u64>(self.ordinal(), offset);
2698            match self {
2699                Resources::Data(ref val) => fidl::encoding::encode_in_envelope::<
2700                    Data,
2701                    fidl::encoding::DefaultFuchsiaResourceDialect,
2702                >(
2703                    <Data as fidl::encoding::ValueTypeMarker>::borrow(val),
2704                    encoder,
2705                    offset + 8,
2706                    _depth,
2707                ),
2708                Resources::Buffer(ref mut val) => fidl::encoding::encode_in_envelope::<
2709                    fidl::encoding::HandleType<
2710                        fidl::Vmo,
2711                        { fidl::ObjectType::VMO.into_raw() },
2712                        2147483648,
2713                    >,
2714                    fidl::encoding::DefaultFuchsiaResourceDialect,
2715                >(
2716                    <fidl::encoding::HandleType<
2717                        fidl::Vmo,
2718                        { fidl::ObjectType::VMO.into_raw() },
2719                        2147483648,
2720                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2721                        val
2722                    ),
2723                    encoder,
2724                    offset + 8,
2725                    _depth,
2726                ),
2727                Resources::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
2728            }
2729        }
2730    }
2731
2732    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Resources {
2733        #[inline(always)]
2734        fn new_empty() -> Self {
2735            Self::__SourceBreaking { unknown_ordinal: 0 }
2736        }
2737
2738        #[inline]
2739        unsafe fn decode(
2740            &mut self,
2741            decoder: &mut fidl::encoding::Decoder<
2742                '_,
2743                fidl::encoding::DefaultFuchsiaResourceDialect,
2744            >,
2745            offset: usize,
2746            mut depth: fidl::encoding::Depth,
2747        ) -> fidl::Result<()> {
2748            decoder.debug_check_bounds::<Self>(offset);
2749            #[allow(unused_variables)]
2750            let next_out_of_line = decoder.next_out_of_line();
2751            let handles_before = decoder.remaining_handles();
2752            let (ordinal, inlined, num_bytes, num_handles) =
2753                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2754
2755            let member_inline_size = match ordinal {
2756                1 => <Data as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2757                2 => <fidl::encoding::HandleType<
2758                    fidl::Vmo,
2759                    { fidl::ObjectType::VMO.into_raw() },
2760                    2147483648,
2761                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2762                0 => return Err(fidl::Error::UnknownUnionTag),
2763                _ => num_bytes as usize,
2764            };
2765
2766            if inlined != (member_inline_size <= 4) {
2767                return Err(fidl::Error::InvalidInlineBitInEnvelope);
2768            }
2769            let _inner_offset;
2770            if inlined {
2771                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2772                _inner_offset = offset + 8;
2773            } else {
2774                depth.increment()?;
2775                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2776            }
2777            match ordinal {
2778                1 => {
2779                    #[allow(irrefutable_let_patterns)]
2780                    if let Resources::Data(_) = self {
2781                        // Do nothing, read the value into the object
2782                    } else {
2783                        // Initialize `self` to the right variant
2784                        *self = Resources::Data(fidl::new_empty!(
2785                            Data,
2786                            fidl::encoding::DefaultFuchsiaResourceDialect
2787                        ));
2788                    }
2789                    #[allow(irrefutable_let_patterns)]
2790                    if let Resources::Data(ref mut val) = self {
2791                        fidl::decode!(
2792                            Data,
2793                            fidl::encoding::DefaultFuchsiaResourceDialect,
2794                            val,
2795                            decoder,
2796                            _inner_offset,
2797                            depth
2798                        )?;
2799                    } else {
2800                        unreachable!()
2801                    }
2802                }
2803                2 => {
2804                    #[allow(irrefutable_let_patterns)]
2805                    if let Resources::Buffer(_) = self {
2806                        // Do nothing, read the value into the object
2807                    } else {
2808                        // Initialize `self` to the right variant
2809                        *self = Resources::Buffer(
2810                            fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
2811                        );
2812                    }
2813                    #[allow(irrefutable_let_patterns)]
2814                    if let Resources::Buffer(ref mut val) = self {
2815                        fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val, decoder, _inner_offset, depth)?;
2816                    } else {
2817                        unreachable!()
2818                    }
2819                }
2820                #[allow(deprecated)]
2821                ordinal => {
2822                    for _ in 0..num_handles {
2823                        decoder.drop_next_handle()?;
2824                    }
2825                    *self = Resources::__SourceBreaking { unknown_ordinal: ordinal };
2826                }
2827            }
2828            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2829                return Err(fidl::Error::InvalidNumBytesInEnvelope);
2830            }
2831            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2832                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2833            }
2834            Ok(())
2835        }
2836    }
2837}