Skip to main content

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