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