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 {
692            Some((responder))
693        } else {
694            None
695        }
696    }
697
698    /// Name of the method defined in FIDL
699    pub fn method_name(&self) -> &'static str {
700        match *self {
701            ProviderRequest::Get { .. } => "get",
702            ProviderRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
703                "unknown one-way method"
704            }
705            ProviderRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
706                "unknown two-way method"
707            }
708        }
709    }
710}
711
712#[derive(Debug, Clone)]
713pub struct ProviderControlHandle {
714    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
715}
716
717impl fidl::endpoints::ControlHandle for ProviderControlHandle {
718    fn shutdown(&self) {
719        self.inner.shutdown()
720    }
721    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
722        self.inner.shutdown_with_epitaph(status)
723    }
724
725    fn is_closed(&self) -> bool {
726        self.inner.channel().is_closed()
727    }
728    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
729        self.inner.channel().on_closed()
730    }
731
732    #[cfg(target_os = "fuchsia")]
733    fn signal_peer(
734        &self,
735        clear_mask: zx::Signals,
736        set_mask: zx::Signals,
737    ) -> Result<(), zx_status::Status> {
738        use fidl::Peered;
739        self.inner.channel().signal_peer(clear_mask, set_mask)
740    }
741}
742
743impl ProviderControlHandle {}
744
745#[must_use = "FIDL methods require a response to be sent"]
746#[derive(Debug)]
747pub struct ProviderGetResponder {
748    control_handle: std::mem::ManuallyDrop<ProviderControlHandle>,
749    tx_id: u32,
750}
751
752/// Set the the channel to be shutdown (see [`ProviderControlHandle::shutdown`])
753/// if the responder is dropped without sending a response, so that the client
754/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
755impl std::ops::Drop for ProviderGetResponder {
756    fn drop(&mut self) {
757        self.control_handle.shutdown();
758        // Safety: drops once, never accessed again
759        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
760    }
761}
762
763impl fidl::endpoints::Responder for ProviderGetResponder {
764    type ControlHandle = ProviderControlHandle;
765
766    fn control_handle(&self) -> &ProviderControlHandle {
767        &self.control_handle
768    }
769
770    fn drop_without_shutdown(mut self) {
771        // Safety: drops once, never accessed again due to mem::forget
772        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
773        // Prevent Drop from running (which would shut down the channel)
774        std::mem::forget(self);
775    }
776}
777
778impl ProviderGetResponder {
779    /// Sends a response to the FIDL transaction.
780    ///
781    /// Sets the channel to shutdown if an error occurs.
782    pub fn send(self, mut result: Result<ProviderGetResponse, Error>) -> Result<(), fidl::Error> {
783        let _result = self.send_raw(result);
784        if _result.is_err() {
785            self.control_handle.shutdown();
786        }
787        self.drop_without_shutdown();
788        _result
789    }
790
791    /// Similar to "send" but does not shutdown the channel if an error occurs.
792    pub fn send_no_shutdown_on_err(
793        self,
794        mut result: Result<ProviderGetResponse, Error>,
795    ) -> Result<(), fidl::Error> {
796        let _result = self.send_raw(result);
797        self.drop_without_shutdown();
798        _result
799    }
800
801    fn send_raw(&self, mut result: Result<ProviderGetResponse, Error>) -> Result<(), fidl::Error> {
802        self.control_handle
803            .inner
804            .send::<fidl::encoding::FlexibleResultType<ProviderGetResponse, Error>>(
805                fidl::encoding::FlexibleResult::new(result.as_mut().map_err(|e| *e)),
806                self.tx_id,
807                0x7a2f2d2cdcfcc945,
808                fidl::encoding::DynamicFlags::FLEXIBLE,
809            )
810    }
811}
812
813mod internal {
814    use super::*;
815
816    impl NewPrincipal {
817        #[inline(always)]
818        fn max_ordinal_present(&self) -> u64 {
819            if let Some(_) = self.detailed_attribution {
820                return 4;
821            }
822            if let Some(_) = self.principal_type {
823                return 3;
824            }
825            if let Some(_) = self.description {
826                return 2;
827            }
828            if let Some(_) = self.identifier {
829                return 1;
830            }
831            0
832        }
833    }
834
835    impl fidl::encoding::ResourceTypeMarker for NewPrincipal {
836        type Borrowed<'a> = &'a mut Self;
837        fn take_or_borrow<'a>(
838            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
839        ) -> Self::Borrowed<'a> {
840            value
841        }
842    }
843
844    unsafe impl fidl::encoding::TypeMarker for NewPrincipal {
845        type Owned = Self;
846
847        #[inline(always)]
848        fn inline_align(_context: fidl::encoding::Context) -> usize {
849            8
850        }
851
852        #[inline(always)]
853        fn inline_size(_context: fidl::encoding::Context) -> usize {
854            16
855        }
856    }
857
858    unsafe impl fidl::encoding::Encode<NewPrincipal, fidl::encoding::DefaultFuchsiaResourceDialect>
859        for &mut NewPrincipal
860    {
861        unsafe fn encode(
862            self,
863            encoder: &mut fidl::encoding::Encoder<
864                '_,
865                fidl::encoding::DefaultFuchsiaResourceDialect,
866            >,
867            offset: usize,
868            mut depth: fidl::encoding::Depth,
869        ) -> fidl::Result<()> {
870            encoder.debug_check_bounds::<NewPrincipal>(offset);
871            // Vector header
872            let max_ordinal: u64 = self.max_ordinal_present();
873            encoder.write_num(max_ordinal, offset);
874            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
875            // Calling encoder.out_of_line_offset(0) is not allowed.
876            if max_ordinal == 0 {
877                return Ok(());
878            }
879            depth.increment()?;
880            let envelope_size = 8;
881            let bytes_len = max_ordinal as usize * envelope_size;
882            #[allow(unused_variables)]
883            let offset = encoder.out_of_line_offset(bytes_len);
884            let mut _prev_end_offset: usize = 0;
885            if 1 > max_ordinal {
886                return Ok(());
887            }
888
889            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
890            // are envelope_size bytes.
891            let cur_offset: usize = (1 - 1) * envelope_size;
892
893            // Zero reserved fields.
894            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
895
896            // Safety:
897            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
898            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
899            //   envelope_size bytes, there is always sufficient room.
900            fidl::encoding::encode_in_envelope_optional::<
901                u64,
902                fidl::encoding::DefaultFuchsiaResourceDialect,
903            >(
904                self.identifier.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
905                encoder,
906                offset + cur_offset,
907                depth,
908            )?;
909
910            _prev_end_offset = cur_offset + envelope_size;
911            if 2 > max_ordinal {
912                return Ok(());
913            }
914
915            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
916            // are envelope_size bytes.
917            let cur_offset: usize = (2 - 1) * envelope_size;
918
919            // Zero reserved fields.
920            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
921
922            // Safety:
923            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
924            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
925            //   envelope_size bytes, there is always sufficient room.
926            fidl::encoding::encode_in_envelope_optional::<
927                Description,
928                fidl::encoding::DefaultFuchsiaResourceDialect,
929            >(
930                self.description
931                    .as_mut()
932                    .map(<Description as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
933                encoder,
934                offset + cur_offset,
935                depth,
936            )?;
937
938            _prev_end_offset = cur_offset + envelope_size;
939            if 3 > max_ordinal {
940                return Ok(());
941            }
942
943            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
944            // are envelope_size bytes.
945            let cur_offset: usize = (3 - 1) * envelope_size;
946
947            // Zero reserved fields.
948            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
949
950            // Safety:
951            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
952            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
953            //   envelope_size bytes, there is always sufficient room.
954            fidl::encoding::encode_in_envelope_optional::<
955                PrincipalType,
956                fidl::encoding::DefaultFuchsiaResourceDialect,
957            >(
958                self.principal_type
959                    .as_ref()
960                    .map(<PrincipalType as fidl::encoding::ValueTypeMarker>::borrow),
961                encoder,
962                offset + cur_offset,
963                depth,
964            )?;
965
966            _prev_end_offset = cur_offset + envelope_size;
967            if 4 > max_ordinal {
968                return Ok(());
969            }
970
971            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
972            // are envelope_size bytes.
973            let cur_offset: usize = (4 - 1) * envelope_size;
974
975            // Zero reserved fields.
976            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
977
978            // Safety:
979            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
980            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
981            //   envelope_size bytes, there is always sufficient room.
982            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
983            self.detailed_attribution.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
984            encoder, offset + cur_offset, depth
985        )?;
986
987            _prev_end_offset = cur_offset + envelope_size;
988
989            Ok(())
990        }
991    }
992
993    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for NewPrincipal {
994        #[inline(always)]
995        fn new_empty() -> Self {
996            Self::default()
997        }
998
999        unsafe fn decode(
1000            &mut self,
1001            decoder: &mut fidl::encoding::Decoder<
1002                '_,
1003                fidl::encoding::DefaultFuchsiaResourceDialect,
1004            >,
1005            offset: usize,
1006            mut depth: fidl::encoding::Depth,
1007        ) -> fidl::Result<()> {
1008            decoder.debug_check_bounds::<Self>(offset);
1009            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1010                None => return Err(fidl::Error::NotNullable),
1011                Some(len) => len,
1012            };
1013            // Calling decoder.out_of_line_offset(0) is not allowed.
1014            if len == 0 {
1015                return Ok(());
1016            };
1017            depth.increment()?;
1018            let envelope_size = 8;
1019            let bytes_len = len * envelope_size;
1020            let offset = decoder.out_of_line_offset(bytes_len)?;
1021            // Decode the envelope for each type.
1022            let mut _next_ordinal_to_read = 0;
1023            let mut next_offset = offset;
1024            let end_offset = offset + bytes_len;
1025            _next_ordinal_to_read += 1;
1026            if next_offset >= end_offset {
1027                return Ok(());
1028            }
1029
1030            // Decode unknown envelopes for gaps in ordinals.
1031            while _next_ordinal_to_read < 1 {
1032                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1033                _next_ordinal_to_read += 1;
1034                next_offset += envelope_size;
1035            }
1036
1037            let next_out_of_line = decoder.next_out_of_line();
1038            let handles_before = decoder.remaining_handles();
1039            if let Some((inlined, num_bytes, num_handles)) =
1040                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1041            {
1042                let member_inline_size =
1043                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1044                if inlined != (member_inline_size <= 4) {
1045                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1046                }
1047                let inner_offset;
1048                let mut inner_depth = depth.clone();
1049                if inlined {
1050                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1051                    inner_offset = next_offset;
1052                } else {
1053                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1054                    inner_depth.increment()?;
1055                }
1056                let val_ref = self.identifier.get_or_insert_with(|| {
1057                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
1058                });
1059                fidl::decode!(
1060                    u64,
1061                    fidl::encoding::DefaultFuchsiaResourceDialect,
1062                    val_ref,
1063                    decoder,
1064                    inner_offset,
1065                    inner_depth
1066                )?;
1067                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1068                {
1069                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1070                }
1071                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1072                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1073                }
1074            }
1075
1076            next_offset += envelope_size;
1077            _next_ordinal_to_read += 1;
1078            if next_offset >= end_offset {
1079                return Ok(());
1080            }
1081
1082            // Decode unknown envelopes for gaps in ordinals.
1083            while _next_ordinal_to_read < 2 {
1084                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1085                _next_ordinal_to_read += 1;
1086                next_offset += envelope_size;
1087            }
1088
1089            let next_out_of_line = decoder.next_out_of_line();
1090            let handles_before = decoder.remaining_handles();
1091            if let Some((inlined, num_bytes, num_handles)) =
1092                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1093            {
1094                let member_inline_size =
1095                    <Description as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1096                if inlined != (member_inline_size <= 4) {
1097                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1098                }
1099                let inner_offset;
1100                let mut inner_depth = depth.clone();
1101                if inlined {
1102                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1103                    inner_offset = next_offset;
1104                } else {
1105                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1106                    inner_depth.increment()?;
1107                }
1108                let val_ref = self.description.get_or_insert_with(|| {
1109                    fidl::new_empty!(Description, fidl::encoding::DefaultFuchsiaResourceDialect)
1110                });
1111                fidl::decode!(
1112                    Description,
1113                    fidl::encoding::DefaultFuchsiaResourceDialect,
1114                    val_ref,
1115                    decoder,
1116                    inner_offset,
1117                    inner_depth
1118                )?;
1119                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1120                {
1121                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1122                }
1123                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1124                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1125                }
1126            }
1127
1128            next_offset += envelope_size;
1129            _next_ordinal_to_read += 1;
1130            if next_offset >= end_offset {
1131                return Ok(());
1132            }
1133
1134            // Decode unknown envelopes for gaps in ordinals.
1135            while _next_ordinal_to_read < 3 {
1136                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1137                _next_ordinal_to_read += 1;
1138                next_offset += envelope_size;
1139            }
1140
1141            let next_out_of_line = decoder.next_out_of_line();
1142            let handles_before = decoder.remaining_handles();
1143            if let Some((inlined, num_bytes, num_handles)) =
1144                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1145            {
1146                let member_inline_size =
1147                    <PrincipalType as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1148                if inlined != (member_inline_size <= 4) {
1149                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1150                }
1151                let inner_offset;
1152                let mut inner_depth = depth.clone();
1153                if inlined {
1154                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1155                    inner_offset = next_offset;
1156                } else {
1157                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1158                    inner_depth.increment()?;
1159                }
1160                let val_ref = self.principal_type.get_or_insert_with(|| {
1161                    fidl::new_empty!(PrincipalType, fidl::encoding::DefaultFuchsiaResourceDialect)
1162                });
1163                fidl::decode!(
1164                    PrincipalType,
1165                    fidl::encoding::DefaultFuchsiaResourceDialect,
1166                    val_ref,
1167                    decoder,
1168                    inner_offset,
1169                    inner_depth
1170                )?;
1171                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1172                {
1173                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1174                }
1175                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1176                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1177                }
1178            }
1179
1180            next_offset += envelope_size;
1181            _next_ordinal_to_read += 1;
1182            if next_offset >= end_offset {
1183                return Ok(());
1184            }
1185
1186            // Decode unknown envelopes for gaps in ordinals.
1187            while _next_ordinal_to_read < 4 {
1188                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1189                _next_ordinal_to_read += 1;
1190                next_offset += envelope_size;
1191            }
1192
1193            let next_out_of_line = decoder.next_out_of_line();
1194            let handles_before = decoder.remaining_handles();
1195            if let Some((inlined, num_bytes, num_handles)) =
1196                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1197            {
1198                let member_inline_size = <fidl::encoding::Endpoint<
1199                    fidl::endpoints::ClientEnd<ProviderMarker>,
1200                > as fidl::encoding::TypeMarker>::inline_size(
1201                    decoder.context
1202                );
1203                if inlined != (member_inline_size <= 4) {
1204                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1205                }
1206                let inner_offset;
1207                let mut inner_depth = depth.clone();
1208                if inlined {
1209                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1210                    inner_offset = next_offset;
1211                } else {
1212                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1213                    inner_depth.increment()?;
1214                }
1215                let val_ref = self.detailed_attribution.get_or_insert_with(|| {
1216                    fidl::new_empty!(
1217                        fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderMarker>>,
1218                        fidl::encoding::DefaultFuchsiaResourceDialect
1219                    )
1220                });
1221                fidl::decode!(
1222                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderMarker>>,
1223                    fidl::encoding::DefaultFuchsiaResourceDialect,
1224                    val_ref,
1225                    decoder,
1226                    inner_offset,
1227                    inner_depth
1228                )?;
1229                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1230                {
1231                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1232                }
1233                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1234                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1235                }
1236            }
1237
1238            next_offset += envelope_size;
1239
1240            // Decode the remaining unknown envelopes.
1241            while next_offset < end_offset {
1242                _next_ordinal_to_read += 1;
1243                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1244                next_offset += envelope_size;
1245            }
1246
1247            Ok(())
1248        }
1249    }
1250
1251    impl ProviderGetResponse {
1252        #[inline(always)]
1253        fn max_ordinal_present(&self) -> u64 {
1254            if let Some(_) = self.attributions {
1255                return 1;
1256            }
1257            0
1258        }
1259    }
1260
1261    impl fidl::encoding::ResourceTypeMarker for ProviderGetResponse {
1262        type Borrowed<'a> = &'a mut Self;
1263        fn take_or_borrow<'a>(
1264            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1265        ) -> Self::Borrowed<'a> {
1266            value
1267        }
1268    }
1269
1270    unsafe impl fidl::encoding::TypeMarker for ProviderGetResponse {
1271        type Owned = Self;
1272
1273        #[inline(always)]
1274        fn inline_align(_context: fidl::encoding::Context) -> usize {
1275            8
1276        }
1277
1278        #[inline(always)]
1279        fn inline_size(_context: fidl::encoding::Context) -> usize {
1280            16
1281        }
1282    }
1283
1284    unsafe impl
1285        fidl::encoding::Encode<ProviderGetResponse, fidl::encoding::DefaultFuchsiaResourceDialect>
1286        for &mut ProviderGetResponse
1287    {
1288        unsafe fn encode(
1289            self,
1290            encoder: &mut fidl::encoding::Encoder<
1291                '_,
1292                fidl::encoding::DefaultFuchsiaResourceDialect,
1293            >,
1294            offset: usize,
1295            mut depth: fidl::encoding::Depth,
1296        ) -> fidl::Result<()> {
1297            encoder.debug_check_bounds::<ProviderGetResponse>(offset);
1298            // Vector header
1299            let max_ordinal: u64 = self.max_ordinal_present();
1300            encoder.write_num(max_ordinal, offset);
1301            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1302            // Calling encoder.out_of_line_offset(0) is not allowed.
1303            if max_ordinal == 0 {
1304                return Ok(());
1305            }
1306            depth.increment()?;
1307            let envelope_size = 8;
1308            let bytes_len = max_ordinal as usize * envelope_size;
1309            #[allow(unused_variables)]
1310            let offset = encoder.out_of_line_offset(bytes_len);
1311            let mut _prev_end_offset: usize = 0;
1312            if 1 > max_ordinal {
1313                return Ok(());
1314            }
1315
1316            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1317            // are envelope_size bytes.
1318            let cur_offset: usize = (1 - 1) * envelope_size;
1319
1320            // Zero reserved fields.
1321            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1322
1323            // Safety:
1324            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1325            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1326            //   envelope_size bytes, there is always sufficient room.
1327            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<AttributionUpdate>, fidl::encoding::DefaultFuchsiaResourceDialect>(
1328            self.attributions.as_mut().map(<fidl::encoding::UnboundedVector<AttributionUpdate> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
1329            encoder, offset + cur_offset, depth
1330        )?;
1331
1332            _prev_end_offset = cur_offset + envelope_size;
1333
1334            Ok(())
1335        }
1336    }
1337
1338    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1339        for ProviderGetResponse
1340    {
1341        #[inline(always)]
1342        fn new_empty() -> Self {
1343            Self::default()
1344        }
1345
1346        unsafe fn decode(
1347            &mut self,
1348            decoder: &mut fidl::encoding::Decoder<
1349                '_,
1350                fidl::encoding::DefaultFuchsiaResourceDialect,
1351            >,
1352            offset: usize,
1353            mut depth: fidl::encoding::Depth,
1354        ) -> fidl::Result<()> {
1355            decoder.debug_check_bounds::<Self>(offset);
1356            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1357                None => return Err(fidl::Error::NotNullable),
1358                Some(len) => len,
1359            };
1360            // Calling decoder.out_of_line_offset(0) is not allowed.
1361            if len == 0 {
1362                return Ok(());
1363            };
1364            depth.increment()?;
1365            let envelope_size = 8;
1366            let bytes_len = len * envelope_size;
1367            let offset = decoder.out_of_line_offset(bytes_len)?;
1368            // Decode the envelope for each type.
1369            let mut _next_ordinal_to_read = 0;
1370            let mut next_offset = offset;
1371            let end_offset = offset + bytes_len;
1372            _next_ordinal_to_read += 1;
1373            if next_offset >= end_offset {
1374                return Ok(());
1375            }
1376
1377            // Decode unknown envelopes for gaps in ordinals.
1378            while _next_ordinal_to_read < 1 {
1379                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1380                _next_ordinal_to_read += 1;
1381                next_offset += envelope_size;
1382            }
1383
1384            let next_out_of_line = decoder.next_out_of_line();
1385            let handles_before = decoder.remaining_handles();
1386            if let Some((inlined, num_bytes, num_handles)) =
1387                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1388            {
1389                let member_inline_size = <fidl::encoding::UnboundedVector<AttributionUpdate> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1390                if inlined != (member_inline_size <= 4) {
1391                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1392                }
1393                let inner_offset;
1394                let mut inner_depth = depth.clone();
1395                if inlined {
1396                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1397                    inner_offset = next_offset;
1398                } else {
1399                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1400                    inner_depth.increment()?;
1401                }
1402                let val_ref = self.attributions.get_or_insert_with(|| {
1403                    fidl::new_empty!(
1404                        fidl::encoding::UnboundedVector<AttributionUpdate>,
1405                        fidl::encoding::DefaultFuchsiaResourceDialect
1406                    )
1407                });
1408                fidl::decode!(
1409                    fidl::encoding::UnboundedVector<AttributionUpdate>,
1410                    fidl::encoding::DefaultFuchsiaResourceDialect,
1411                    val_ref,
1412                    decoder,
1413                    inner_offset,
1414                    inner_depth
1415                )?;
1416                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1417                {
1418                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1419                }
1420                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1421                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1422                }
1423            }
1424
1425            next_offset += envelope_size;
1426
1427            // Decode the remaining unknown envelopes.
1428            while next_offset < end_offset {
1429                _next_ordinal_to_read += 1;
1430                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1431                next_offset += envelope_size;
1432            }
1433
1434            Ok(())
1435        }
1436    }
1437
1438    impl UpdatedPrincipal {
1439        #[inline(always)]
1440        fn max_ordinal_present(&self) -> u64 {
1441            if let Some(_) = self.resources {
1442                return 2;
1443            }
1444            if let Some(_) = self.identifier {
1445                return 1;
1446            }
1447            0
1448        }
1449    }
1450
1451    impl fidl::encoding::ResourceTypeMarker for UpdatedPrincipal {
1452        type Borrowed<'a> = &'a mut Self;
1453        fn take_or_borrow<'a>(
1454            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1455        ) -> Self::Borrowed<'a> {
1456            value
1457        }
1458    }
1459
1460    unsafe impl fidl::encoding::TypeMarker for UpdatedPrincipal {
1461        type Owned = Self;
1462
1463        #[inline(always)]
1464        fn inline_align(_context: fidl::encoding::Context) -> usize {
1465            8
1466        }
1467
1468        #[inline(always)]
1469        fn inline_size(_context: fidl::encoding::Context) -> usize {
1470            16
1471        }
1472    }
1473
1474    unsafe impl
1475        fidl::encoding::Encode<UpdatedPrincipal, fidl::encoding::DefaultFuchsiaResourceDialect>
1476        for &mut UpdatedPrincipal
1477    {
1478        unsafe fn encode(
1479            self,
1480            encoder: &mut fidl::encoding::Encoder<
1481                '_,
1482                fidl::encoding::DefaultFuchsiaResourceDialect,
1483            >,
1484            offset: usize,
1485            mut depth: fidl::encoding::Depth,
1486        ) -> fidl::Result<()> {
1487            encoder.debug_check_bounds::<UpdatedPrincipal>(offset);
1488            // Vector header
1489            let max_ordinal: u64 = self.max_ordinal_present();
1490            encoder.write_num(max_ordinal, offset);
1491            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1492            // Calling encoder.out_of_line_offset(0) is not allowed.
1493            if max_ordinal == 0 {
1494                return Ok(());
1495            }
1496            depth.increment()?;
1497            let envelope_size = 8;
1498            let bytes_len = max_ordinal as usize * envelope_size;
1499            #[allow(unused_variables)]
1500            let offset = encoder.out_of_line_offset(bytes_len);
1501            let mut _prev_end_offset: usize = 0;
1502            if 1 > max_ordinal {
1503                return Ok(());
1504            }
1505
1506            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1507            // are envelope_size bytes.
1508            let cur_offset: usize = (1 - 1) * envelope_size;
1509
1510            // Zero reserved fields.
1511            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1512
1513            // Safety:
1514            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1515            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1516            //   envelope_size bytes, there is always sufficient room.
1517            fidl::encoding::encode_in_envelope_optional::<
1518                u64,
1519                fidl::encoding::DefaultFuchsiaResourceDialect,
1520            >(
1521                self.identifier.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
1522                encoder,
1523                offset + cur_offset,
1524                depth,
1525            )?;
1526
1527            _prev_end_offset = cur_offset + envelope_size;
1528            if 2 > max_ordinal {
1529                return Ok(());
1530            }
1531
1532            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1533            // are envelope_size bytes.
1534            let cur_offset: usize = (2 - 1) * envelope_size;
1535
1536            // Zero reserved fields.
1537            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1538
1539            // Safety:
1540            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1541            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1542            //   envelope_size bytes, there is always sufficient room.
1543            fidl::encoding::encode_in_envelope_optional::<
1544                Resources,
1545                fidl::encoding::DefaultFuchsiaResourceDialect,
1546            >(
1547                self.resources
1548                    .as_mut()
1549                    .map(<Resources as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
1550                encoder,
1551                offset + cur_offset,
1552                depth,
1553            )?;
1554
1555            _prev_end_offset = cur_offset + envelope_size;
1556
1557            Ok(())
1558        }
1559    }
1560
1561    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1562        for UpdatedPrincipal
1563    {
1564        #[inline(always)]
1565        fn new_empty() -> Self {
1566            Self::default()
1567        }
1568
1569        unsafe fn decode(
1570            &mut self,
1571            decoder: &mut fidl::encoding::Decoder<
1572                '_,
1573                fidl::encoding::DefaultFuchsiaResourceDialect,
1574            >,
1575            offset: usize,
1576            mut depth: fidl::encoding::Depth,
1577        ) -> fidl::Result<()> {
1578            decoder.debug_check_bounds::<Self>(offset);
1579            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1580                None => return Err(fidl::Error::NotNullable),
1581                Some(len) => len,
1582            };
1583            // Calling decoder.out_of_line_offset(0) is not allowed.
1584            if len == 0 {
1585                return Ok(());
1586            };
1587            depth.increment()?;
1588            let envelope_size = 8;
1589            let bytes_len = len * envelope_size;
1590            let offset = decoder.out_of_line_offset(bytes_len)?;
1591            // Decode the envelope for each type.
1592            let mut _next_ordinal_to_read = 0;
1593            let mut next_offset = offset;
1594            let end_offset = offset + bytes_len;
1595            _next_ordinal_to_read += 1;
1596            if next_offset >= end_offset {
1597                return Ok(());
1598            }
1599
1600            // Decode unknown envelopes for gaps in ordinals.
1601            while _next_ordinal_to_read < 1 {
1602                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1603                _next_ordinal_to_read += 1;
1604                next_offset += envelope_size;
1605            }
1606
1607            let next_out_of_line = decoder.next_out_of_line();
1608            let handles_before = decoder.remaining_handles();
1609            if let Some((inlined, num_bytes, num_handles)) =
1610                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1611            {
1612                let member_inline_size =
1613                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1614                if inlined != (member_inline_size <= 4) {
1615                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1616                }
1617                let inner_offset;
1618                let mut inner_depth = depth.clone();
1619                if inlined {
1620                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1621                    inner_offset = next_offset;
1622                } else {
1623                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1624                    inner_depth.increment()?;
1625                }
1626                let val_ref = self.identifier.get_or_insert_with(|| {
1627                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
1628                });
1629                fidl::decode!(
1630                    u64,
1631                    fidl::encoding::DefaultFuchsiaResourceDialect,
1632                    val_ref,
1633                    decoder,
1634                    inner_offset,
1635                    inner_depth
1636                )?;
1637                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1638                {
1639                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1640                }
1641                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1642                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1643                }
1644            }
1645
1646            next_offset += envelope_size;
1647            _next_ordinal_to_read += 1;
1648            if next_offset >= end_offset {
1649                return Ok(());
1650            }
1651
1652            // Decode unknown envelopes for gaps in ordinals.
1653            while _next_ordinal_to_read < 2 {
1654                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1655                _next_ordinal_to_read += 1;
1656                next_offset += envelope_size;
1657            }
1658
1659            let next_out_of_line = decoder.next_out_of_line();
1660            let handles_before = decoder.remaining_handles();
1661            if let Some((inlined, num_bytes, num_handles)) =
1662                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1663            {
1664                let member_inline_size =
1665                    <Resources as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1666                if inlined != (member_inline_size <= 4) {
1667                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1668                }
1669                let inner_offset;
1670                let mut inner_depth = depth.clone();
1671                if inlined {
1672                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1673                    inner_offset = next_offset;
1674                } else {
1675                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1676                    inner_depth.increment()?;
1677                }
1678                let val_ref = self.resources.get_or_insert_with(|| {
1679                    fidl::new_empty!(Resources, fidl::encoding::DefaultFuchsiaResourceDialect)
1680                });
1681                fidl::decode!(
1682                    Resources,
1683                    fidl::encoding::DefaultFuchsiaResourceDialect,
1684                    val_ref,
1685                    decoder,
1686                    inner_offset,
1687                    inner_depth
1688                )?;
1689                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1690                {
1691                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1692                }
1693                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1694                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1695                }
1696            }
1697
1698            next_offset += envelope_size;
1699
1700            // Decode the remaining unknown envelopes.
1701            while next_offset < end_offset {
1702                _next_ordinal_to_read += 1;
1703                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1704                next_offset += envelope_size;
1705            }
1706
1707            Ok(())
1708        }
1709    }
1710
1711    impl fidl::encoding::ResourceTypeMarker for AttributionUpdate {
1712        type Borrowed<'a> = &'a mut Self;
1713        fn take_or_borrow<'a>(
1714            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1715        ) -> Self::Borrowed<'a> {
1716            value
1717        }
1718    }
1719
1720    unsafe impl fidl::encoding::TypeMarker for AttributionUpdate {
1721        type Owned = Self;
1722
1723        #[inline(always)]
1724        fn inline_align(_context: fidl::encoding::Context) -> usize {
1725            8
1726        }
1727
1728        #[inline(always)]
1729        fn inline_size(_context: fidl::encoding::Context) -> usize {
1730            16
1731        }
1732    }
1733
1734    unsafe impl
1735        fidl::encoding::Encode<AttributionUpdate, fidl::encoding::DefaultFuchsiaResourceDialect>
1736        for &mut AttributionUpdate
1737    {
1738        #[inline]
1739        unsafe fn encode(
1740            self,
1741            encoder: &mut fidl::encoding::Encoder<
1742                '_,
1743                fidl::encoding::DefaultFuchsiaResourceDialect,
1744            >,
1745            offset: usize,
1746            _depth: fidl::encoding::Depth,
1747        ) -> fidl::Result<()> {
1748            encoder.debug_check_bounds::<AttributionUpdate>(offset);
1749            encoder.write_num::<u64>(self.ordinal(), offset);
1750            match self {
1751                AttributionUpdate::Add(ref mut val) => fidl::encoding::encode_in_envelope::<
1752                    NewPrincipal,
1753                    fidl::encoding::DefaultFuchsiaResourceDialect,
1754                >(
1755                    <NewPrincipal as fidl::encoding::ResourceTypeMarker>::take_or_borrow(val),
1756                    encoder,
1757                    offset + 8,
1758                    _depth,
1759                ),
1760                AttributionUpdate::Update(ref mut val) => fidl::encoding::encode_in_envelope::<
1761                    UpdatedPrincipal,
1762                    fidl::encoding::DefaultFuchsiaResourceDialect,
1763                >(
1764                    <UpdatedPrincipal as fidl::encoding::ResourceTypeMarker>::take_or_borrow(val),
1765                    encoder,
1766                    offset + 8,
1767                    _depth,
1768                ),
1769                AttributionUpdate::Remove(ref val) => fidl::encoding::encode_in_envelope::<
1770                    u64,
1771                    fidl::encoding::DefaultFuchsiaResourceDialect,
1772                >(
1773                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(val),
1774                    encoder,
1775                    offset + 8,
1776                    _depth,
1777                ),
1778                AttributionUpdate::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
1779            }
1780        }
1781    }
1782
1783    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1784        for AttributionUpdate
1785    {
1786        #[inline(always)]
1787        fn new_empty() -> Self {
1788            Self::__SourceBreaking { unknown_ordinal: 0 }
1789        }
1790
1791        #[inline]
1792        unsafe fn decode(
1793            &mut self,
1794            decoder: &mut fidl::encoding::Decoder<
1795                '_,
1796                fidl::encoding::DefaultFuchsiaResourceDialect,
1797            >,
1798            offset: usize,
1799            mut depth: fidl::encoding::Depth,
1800        ) -> fidl::Result<()> {
1801            decoder.debug_check_bounds::<Self>(offset);
1802            #[allow(unused_variables)]
1803            let next_out_of_line = decoder.next_out_of_line();
1804            let handles_before = decoder.remaining_handles();
1805            let (ordinal, inlined, num_bytes, num_handles) =
1806                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
1807
1808            let member_inline_size = match ordinal {
1809                1 => <NewPrincipal as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1810                2 => <UpdatedPrincipal as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1811                3 => <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1812                0 => return Err(fidl::Error::UnknownUnionTag),
1813                _ => num_bytes as usize,
1814            };
1815
1816            if inlined != (member_inline_size <= 4) {
1817                return Err(fidl::Error::InvalidInlineBitInEnvelope);
1818            }
1819            let _inner_offset;
1820            if inlined {
1821                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
1822                _inner_offset = offset + 8;
1823            } else {
1824                depth.increment()?;
1825                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1826            }
1827            match ordinal {
1828                1 => {
1829                    #[allow(irrefutable_let_patterns)]
1830                    if let AttributionUpdate::Add(_) = self {
1831                        // Do nothing, read the value into the object
1832                    } else {
1833                        // Initialize `self` to the right variant
1834                        *self = AttributionUpdate::Add(fidl::new_empty!(
1835                            NewPrincipal,
1836                            fidl::encoding::DefaultFuchsiaResourceDialect
1837                        ));
1838                    }
1839                    #[allow(irrefutable_let_patterns)]
1840                    if let AttributionUpdate::Add(ref mut val) = self {
1841                        fidl::decode!(
1842                            NewPrincipal,
1843                            fidl::encoding::DefaultFuchsiaResourceDialect,
1844                            val,
1845                            decoder,
1846                            _inner_offset,
1847                            depth
1848                        )?;
1849                    } else {
1850                        unreachable!()
1851                    }
1852                }
1853                2 => {
1854                    #[allow(irrefutable_let_patterns)]
1855                    if let AttributionUpdate::Update(_) = self {
1856                        // Do nothing, read the value into the object
1857                    } else {
1858                        // Initialize `self` to the right variant
1859                        *self = AttributionUpdate::Update(fidl::new_empty!(
1860                            UpdatedPrincipal,
1861                            fidl::encoding::DefaultFuchsiaResourceDialect
1862                        ));
1863                    }
1864                    #[allow(irrefutable_let_patterns)]
1865                    if let AttributionUpdate::Update(ref mut val) = self {
1866                        fidl::decode!(
1867                            UpdatedPrincipal,
1868                            fidl::encoding::DefaultFuchsiaResourceDialect,
1869                            val,
1870                            decoder,
1871                            _inner_offset,
1872                            depth
1873                        )?;
1874                    } else {
1875                        unreachable!()
1876                    }
1877                }
1878                3 => {
1879                    #[allow(irrefutable_let_patterns)]
1880                    if let AttributionUpdate::Remove(_) = self {
1881                        // Do nothing, read the value into the object
1882                    } else {
1883                        // Initialize `self` to the right variant
1884                        *self = AttributionUpdate::Remove(fidl::new_empty!(
1885                            u64,
1886                            fidl::encoding::DefaultFuchsiaResourceDialect
1887                        ));
1888                    }
1889                    #[allow(irrefutable_let_patterns)]
1890                    if let AttributionUpdate::Remove(ref mut val) = self {
1891                        fidl::decode!(
1892                            u64,
1893                            fidl::encoding::DefaultFuchsiaResourceDialect,
1894                            val,
1895                            decoder,
1896                            _inner_offset,
1897                            depth
1898                        )?;
1899                    } else {
1900                        unreachable!()
1901                    }
1902                }
1903                #[allow(deprecated)]
1904                ordinal => {
1905                    for _ in 0..num_handles {
1906                        decoder.drop_next_handle()?;
1907                    }
1908                    *self = AttributionUpdate::__SourceBreaking { unknown_ordinal: ordinal };
1909                }
1910            }
1911            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
1912                return Err(fidl::Error::InvalidNumBytesInEnvelope);
1913            }
1914            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1915                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1916            }
1917            Ok(())
1918        }
1919    }
1920
1921    impl fidl::encoding::ResourceTypeMarker for Description {
1922        type Borrowed<'a> = &'a mut Self;
1923        fn take_or_borrow<'a>(
1924            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1925        ) -> Self::Borrowed<'a> {
1926            value
1927        }
1928    }
1929
1930    unsafe impl fidl::encoding::TypeMarker for Description {
1931        type Owned = Self;
1932
1933        #[inline(always)]
1934        fn inline_align(_context: fidl::encoding::Context) -> usize {
1935            8
1936        }
1937
1938        #[inline(always)]
1939        fn inline_size(_context: fidl::encoding::Context) -> usize {
1940            16
1941        }
1942    }
1943
1944    unsafe impl fidl::encoding::Encode<Description, fidl::encoding::DefaultFuchsiaResourceDialect>
1945        for &mut Description
1946    {
1947        #[inline]
1948        unsafe fn encode(
1949            self,
1950            encoder: &mut fidl::encoding::Encoder<
1951                '_,
1952                fidl::encoding::DefaultFuchsiaResourceDialect,
1953            >,
1954            offset: usize,
1955            _depth: fidl::encoding::Depth,
1956        ) -> fidl::Result<()> {
1957            encoder.debug_check_bounds::<Description>(offset);
1958            encoder.write_num::<u64>(self.ordinal(), offset);
1959            match self {
1960                Description::Component(ref mut val) => fidl::encoding::encode_in_envelope::<
1961                    fidl::encoding::HandleType<
1962                        fidl::Event,
1963                        { fidl::ObjectType::EVENT.into_raw() },
1964                        2147483648,
1965                    >,
1966                    fidl::encoding::DefaultFuchsiaResourceDialect,
1967                >(
1968                    <fidl::encoding::HandleType<
1969                        fidl::Event,
1970                        { fidl::ObjectType::EVENT.into_raw() },
1971                        2147483648,
1972                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1973                        val
1974                    ),
1975                    encoder,
1976                    offset + 8,
1977                    _depth,
1978                ),
1979                Description::Part(ref val) => fidl::encoding::encode_in_envelope::<
1980                    fidl::encoding::UnboundedString,
1981                    fidl::encoding::DefaultFuchsiaResourceDialect,
1982                >(
1983                    <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(
1984                        val,
1985                    ),
1986                    encoder,
1987                    offset + 8,
1988                    _depth,
1989                ),
1990                Description::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
1991            }
1992        }
1993    }
1994
1995    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Description {
1996        #[inline(always)]
1997        fn new_empty() -> Self {
1998            Self::__SourceBreaking { unknown_ordinal: 0 }
1999        }
2000
2001        #[inline]
2002        unsafe fn decode(
2003            &mut self,
2004            decoder: &mut fidl::encoding::Decoder<
2005                '_,
2006                fidl::encoding::DefaultFuchsiaResourceDialect,
2007            >,
2008            offset: usize,
2009            mut depth: fidl::encoding::Depth,
2010        ) -> fidl::Result<()> {
2011            decoder.debug_check_bounds::<Self>(offset);
2012            #[allow(unused_variables)]
2013            let next_out_of_line = decoder.next_out_of_line();
2014            let handles_before = decoder.remaining_handles();
2015            let (ordinal, inlined, num_bytes, num_handles) =
2016                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2017
2018            let member_inline_size = match ordinal {
2019                1 => <fidl::encoding::HandleType<
2020                    fidl::Event,
2021                    { fidl::ObjectType::EVENT.into_raw() },
2022                    2147483648,
2023                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2024                2 => <fidl::encoding::UnboundedString as fidl::encoding::TypeMarker>::inline_size(
2025                    decoder.context,
2026                ),
2027                0 => return Err(fidl::Error::UnknownUnionTag),
2028                _ => num_bytes as usize,
2029            };
2030
2031            if inlined != (member_inline_size <= 4) {
2032                return Err(fidl::Error::InvalidInlineBitInEnvelope);
2033            }
2034            let _inner_offset;
2035            if inlined {
2036                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2037                _inner_offset = offset + 8;
2038            } else {
2039                depth.increment()?;
2040                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2041            }
2042            match ordinal {
2043                1 => {
2044                    #[allow(irrefutable_let_patterns)]
2045                    if let Description::Component(_) = self {
2046                        // Do nothing, read the value into the object
2047                    } else {
2048                        // Initialize `self` to the right variant
2049                        *self = Description::Component(
2050                            fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
2051                        );
2052                    }
2053                    #[allow(irrefutable_let_patterns)]
2054                    if let Description::Component(ref mut val) = self {
2055                        fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val, decoder, _inner_offset, depth)?;
2056                    } else {
2057                        unreachable!()
2058                    }
2059                }
2060                2 => {
2061                    #[allow(irrefutable_let_patterns)]
2062                    if let Description::Part(_) = self {
2063                        // Do nothing, read the value into the object
2064                    } else {
2065                        // Initialize `self` to the right variant
2066                        *self = Description::Part(fidl::new_empty!(
2067                            fidl::encoding::UnboundedString,
2068                            fidl::encoding::DefaultFuchsiaResourceDialect
2069                        ));
2070                    }
2071                    #[allow(irrefutable_let_patterns)]
2072                    if let Description::Part(ref mut val) = self {
2073                        fidl::decode!(
2074                            fidl::encoding::UnboundedString,
2075                            fidl::encoding::DefaultFuchsiaResourceDialect,
2076                            val,
2077                            decoder,
2078                            _inner_offset,
2079                            depth
2080                        )?;
2081                    } else {
2082                        unreachable!()
2083                    }
2084                }
2085                #[allow(deprecated)]
2086                ordinal => {
2087                    for _ in 0..num_handles {
2088                        decoder.drop_next_handle()?;
2089                    }
2090                    *self = Description::__SourceBreaking { unknown_ordinal: ordinal };
2091                }
2092            }
2093            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2094                return Err(fidl::Error::InvalidNumBytesInEnvelope);
2095            }
2096            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2097                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2098            }
2099            Ok(())
2100        }
2101    }
2102
2103    impl fidl::encoding::ResourceTypeMarker for Resources {
2104        type Borrowed<'a> = &'a mut Self;
2105        fn take_or_borrow<'a>(
2106            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2107        ) -> Self::Borrowed<'a> {
2108            value
2109        }
2110    }
2111
2112    unsafe impl fidl::encoding::TypeMarker for Resources {
2113        type Owned = Self;
2114
2115        #[inline(always)]
2116        fn inline_align(_context: fidl::encoding::Context) -> usize {
2117            8
2118        }
2119
2120        #[inline(always)]
2121        fn inline_size(_context: fidl::encoding::Context) -> usize {
2122            16
2123        }
2124    }
2125
2126    unsafe impl fidl::encoding::Encode<Resources, fidl::encoding::DefaultFuchsiaResourceDialect>
2127        for &mut Resources
2128    {
2129        #[inline]
2130        unsafe fn encode(
2131            self,
2132            encoder: &mut fidl::encoding::Encoder<
2133                '_,
2134                fidl::encoding::DefaultFuchsiaResourceDialect,
2135            >,
2136            offset: usize,
2137            _depth: fidl::encoding::Depth,
2138        ) -> fidl::Result<()> {
2139            encoder.debug_check_bounds::<Resources>(offset);
2140            encoder.write_num::<u64>(self.ordinal(), offset);
2141            match self {
2142                Resources::Data(ref val) => fidl::encoding::encode_in_envelope::<
2143                    Data,
2144                    fidl::encoding::DefaultFuchsiaResourceDialect,
2145                >(
2146                    <Data as fidl::encoding::ValueTypeMarker>::borrow(val),
2147                    encoder,
2148                    offset + 8,
2149                    _depth,
2150                ),
2151                Resources::Buffer(ref mut val) => fidl::encoding::encode_in_envelope::<
2152                    fidl::encoding::HandleType<
2153                        fidl::Vmo,
2154                        { fidl::ObjectType::VMO.into_raw() },
2155                        2147483648,
2156                    >,
2157                    fidl::encoding::DefaultFuchsiaResourceDialect,
2158                >(
2159                    <fidl::encoding::HandleType<
2160                        fidl::Vmo,
2161                        { fidl::ObjectType::VMO.into_raw() },
2162                        2147483648,
2163                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2164                        val
2165                    ),
2166                    encoder,
2167                    offset + 8,
2168                    _depth,
2169                ),
2170                Resources::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
2171            }
2172        }
2173    }
2174
2175    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Resources {
2176        #[inline(always)]
2177        fn new_empty() -> Self {
2178            Self::__SourceBreaking { unknown_ordinal: 0 }
2179        }
2180
2181        #[inline]
2182        unsafe fn decode(
2183            &mut self,
2184            decoder: &mut fidl::encoding::Decoder<
2185                '_,
2186                fidl::encoding::DefaultFuchsiaResourceDialect,
2187            >,
2188            offset: usize,
2189            mut depth: fidl::encoding::Depth,
2190        ) -> fidl::Result<()> {
2191            decoder.debug_check_bounds::<Self>(offset);
2192            #[allow(unused_variables)]
2193            let next_out_of_line = decoder.next_out_of_line();
2194            let handles_before = decoder.remaining_handles();
2195            let (ordinal, inlined, num_bytes, num_handles) =
2196                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2197
2198            let member_inline_size = match ordinal {
2199                1 => <Data as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2200                2 => <fidl::encoding::HandleType<
2201                    fidl::Vmo,
2202                    { fidl::ObjectType::VMO.into_raw() },
2203                    2147483648,
2204                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2205                0 => return Err(fidl::Error::UnknownUnionTag),
2206                _ => num_bytes as usize,
2207            };
2208
2209            if inlined != (member_inline_size <= 4) {
2210                return Err(fidl::Error::InvalidInlineBitInEnvelope);
2211            }
2212            let _inner_offset;
2213            if inlined {
2214                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2215                _inner_offset = offset + 8;
2216            } else {
2217                depth.increment()?;
2218                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2219            }
2220            match ordinal {
2221                1 => {
2222                    #[allow(irrefutable_let_patterns)]
2223                    if let Resources::Data(_) = self {
2224                        // Do nothing, read the value into the object
2225                    } else {
2226                        // Initialize `self` to the right variant
2227                        *self = Resources::Data(fidl::new_empty!(
2228                            Data,
2229                            fidl::encoding::DefaultFuchsiaResourceDialect
2230                        ));
2231                    }
2232                    #[allow(irrefutable_let_patterns)]
2233                    if let Resources::Data(ref mut val) = self {
2234                        fidl::decode!(
2235                            Data,
2236                            fidl::encoding::DefaultFuchsiaResourceDialect,
2237                            val,
2238                            decoder,
2239                            _inner_offset,
2240                            depth
2241                        )?;
2242                    } else {
2243                        unreachable!()
2244                    }
2245                }
2246                2 => {
2247                    #[allow(irrefutable_let_patterns)]
2248                    if let Resources::Buffer(_) = self {
2249                        // Do nothing, read the value into the object
2250                    } else {
2251                        // Initialize `self` to the right variant
2252                        *self = Resources::Buffer(
2253                            fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
2254                        );
2255                    }
2256                    #[allow(irrefutable_let_patterns)]
2257                    if let Resources::Buffer(ref mut val) = self {
2258                        fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val, decoder, _inner_offset, depth)?;
2259                    } else {
2260                        unreachable!()
2261                    }
2262                }
2263                #[allow(deprecated)]
2264                ordinal => {
2265                    for _ in 0..num_handles {
2266                        decoder.drop_next_handle()?;
2267                    }
2268                    *self = Resources::__SourceBreaking { unknown_ordinal: ordinal };
2269                }
2270            }
2271            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2272                return Err(fidl::Error::InvalidNumBytesInEnvelope);
2273            }
2274            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2275                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2276            }
2277            Ok(())
2278        }
2279    }
2280}