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