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