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