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