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 RoleManagerSetRoleRequest {
16    pub target: Option<RoleTarget>,
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> for RoleManagerSetRoleRequest {}
24
25#[derive(Debug, Default, PartialEq)]
26pub struct RoleManagerSetRoleResponse {
27    pub output_parameters: Option<Vec<Parameter>>,
28    #[doc(hidden)]
29    pub __source_breaking: fidl::marker::SourceBreaking,
30}
31
32impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
33    for RoleManagerSetRoleResponse
34{
35}
36
37/// A Zircon object to which a profile can be applied.
38/// Currently, only threads and vmars are supported.
39#[derive(Debug)]
40pub enum RoleTarget {
41    Thread(fidl::Thread),
42    Vmar(fidl::Vmar),
43    #[doc(hidden)]
44    __SourceBreaking {
45        unknown_ordinal: u64,
46    },
47}
48
49/// Pattern that matches an unknown `RoleTarget` member.
50#[macro_export]
51macro_rules! RoleTargetUnknown {
52    () => {
53        _
54    };
55}
56
57// Custom PartialEq so that unknown variants are not equal to themselves.
58impl PartialEq for RoleTarget {
59    fn eq(&self, other: &Self) -> bool {
60        match (self, other) {
61            (Self::Thread(x), Self::Thread(y)) => *x == *y,
62            (Self::Vmar(x), Self::Vmar(y)) => *x == *y,
63            _ => false,
64        }
65    }
66}
67
68impl RoleTarget {
69    #[inline]
70    pub fn ordinal(&self) -> u64 {
71        match *self {
72            Self::Thread(_) => 1,
73            Self::Vmar(_) => 2,
74            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
75        }
76    }
77
78    #[inline]
79    pub fn unknown_variant_for_testing() -> Self {
80        Self::__SourceBreaking { unknown_ordinal: 0 }
81    }
82
83    #[inline]
84    pub fn is_unknown(&self) -> bool {
85        match self {
86            Self::__SourceBreaking { .. } => true,
87            _ => false,
88        }
89    }
90}
91
92impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for RoleTarget {}
93
94#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
95pub struct RoleManagerMarker;
96
97impl fidl::endpoints::ProtocolMarker for RoleManagerMarker {
98    type Proxy = RoleManagerProxy;
99    type RequestStream = RoleManagerRequestStream;
100    #[cfg(target_os = "fuchsia")]
101    type SynchronousProxy = RoleManagerSynchronousProxy;
102
103    const DEBUG_NAME: &'static str = "fuchsia.scheduler.RoleManager";
104}
105impl fidl::endpoints::DiscoverableProtocolMarker for RoleManagerMarker {}
106pub type RoleManagerSetRoleResult = Result<RoleManagerSetRoleResponse, i32>;
107
108pub trait RoleManagerProxyInterface: Send + Sync {
109    type SetRoleResponseFut: std::future::Future<Output = Result<RoleManagerSetRoleResult, fidl::Error>>
110        + Send;
111    fn r#set_role(&self, payload: RoleManagerSetRoleRequest) -> Self::SetRoleResponseFut;
112}
113#[derive(Debug)]
114#[cfg(target_os = "fuchsia")]
115pub struct RoleManagerSynchronousProxy {
116    client: fidl::client::sync::Client,
117}
118
119#[cfg(target_os = "fuchsia")]
120impl fidl::endpoints::SynchronousProxy for RoleManagerSynchronousProxy {
121    type Proxy = RoleManagerProxy;
122    type Protocol = RoleManagerMarker;
123
124    fn from_channel(inner: fidl::Channel) -> Self {
125        Self::new(inner)
126    }
127
128    fn into_channel(self) -> fidl::Channel {
129        self.client.into_channel()
130    }
131
132    fn as_channel(&self) -> &fidl::Channel {
133        self.client.as_channel()
134    }
135}
136
137#[cfg(target_os = "fuchsia")]
138impl RoleManagerSynchronousProxy {
139    pub fn new(channel: fidl::Channel) -> Self {
140        let protocol_name = <RoleManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
141        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
142    }
143
144    pub fn into_channel(self) -> fidl::Channel {
145        self.client.into_channel()
146    }
147
148    /// Waits until an event arrives and returns it. It is safe for other
149    /// threads to make concurrent requests while waiting for an event.
150    pub fn wait_for_event(
151        &self,
152        deadline: zx::MonotonicInstant,
153    ) -> Result<RoleManagerEvent, fidl::Error> {
154        RoleManagerEvent::decode(self.client.wait_for_event(deadline)?)
155    }
156
157    /// Sets the given object's performance parameters based on the requested
158    /// role. The exact parameters of the role are system dependent and may
159    /// vary based on device-specific tuning and/or runtime system goals.
160    ///
161    /// + request `target` is a handle to a zircon object to which a profile
162    ///     can be applied.
163    /// + request `role` is the name of the role to apply to the target.
164    /// + request `input_parameters` is a vector of key/value pairs used to
165    ///     distinguish between multiple variants of the same role.
166    /// - response `output_parameters` is a vector of key/value pairs that
167    ///     roles can be configured to emit.
168    /// * error a zx_status value indicating success or failure.
169    pub fn r#set_role(
170        &self,
171        mut payload: RoleManagerSetRoleRequest,
172        ___deadline: zx::MonotonicInstant,
173    ) -> Result<RoleManagerSetRoleResult, fidl::Error> {
174        let _response = self.client.send_query::<
175            RoleManagerSetRoleRequest,
176            fidl::encoding::FlexibleResultType<RoleManagerSetRoleResponse, i32>,
177        >(
178            &mut payload,
179            0x617dd765af923edc,
180            fidl::encoding::DynamicFlags::FLEXIBLE,
181            ___deadline,
182        )?
183        .into_result::<RoleManagerMarker>("set_role")?;
184        Ok(_response.map(|x| x))
185    }
186}
187
188#[cfg(target_os = "fuchsia")]
189impl From<RoleManagerSynchronousProxy> for zx::NullableHandle {
190    fn from(value: RoleManagerSynchronousProxy) -> Self {
191        value.into_channel().into()
192    }
193}
194
195#[cfg(target_os = "fuchsia")]
196impl From<fidl::Channel> for RoleManagerSynchronousProxy {
197    fn from(value: fidl::Channel) -> Self {
198        Self::new(value)
199    }
200}
201
202#[cfg(target_os = "fuchsia")]
203impl fidl::endpoints::FromClient for RoleManagerSynchronousProxy {
204    type Protocol = RoleManagerMarker;
205
206    fn from_client(value: fidl::endpoints::ClientEnd<RoleManagerMarker>) -> Self {
207        Self::new(value.into_channel())
208    }
209}
210
211#[derive(Debug, Clone)]
212pub struct RoleManagerProxy {
213    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
214}
215
216impl fidl::endpoints::Proxy for RoleManagerProxy {
217    type Protocol = RoleManagerMarker;
218
219    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
220        Self::new(inner)
221    }
222
223    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
224        self.client.into_channel().map_err(|client| Self { client })
225    }
226
227    fn as_channel(&self) -> &::fidl::AsyncChannel {
228        self.client.as_channel()
229    }
230}
231
232impl RoleManagerProxy {
233    /// Create a new Proxy for fuchsia.scheduler/RoleManager.
234    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
235        let protocol_name = <RoleManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
236        Self { client: fidl::client::Client::new(channel, protocol_name) }
237    }
238
239    /// Get a Stream of events from the remote end of the protocol.
240    ///
241    /// # Panics
242    ///
243    /// Panics if the event stream was already taken.
244    pub fn take_event_stream(&self) -> RoleManagerEventStream {
245        RoleManagerEventStream { event_receiver: self.client.take_event_receiver() }
246    }
247
248    /// Sets the given object's performance parameters based on the requested
249    /// role. The exact parameters of the role are system dependent and may
250    /// vary based on device-specific tuning and/or runtime system goals.
251    ///
252    /// + request `target` is a handle to a zircon object to which a profile
253    ///     can be applied.
254    /// + request `role` is the name of the role to apply to the target.
255    /// + request `input_parameters` is a vector of key/value pairs used to
256    ///     distinguish between multiple variants of the same role.
257    /// - response `output_parameters` is a vector of key/value pairs that
258    ///     roles can be configured to emit.
259    /// * error a zx_status value indicating success or failure.
260    pub fn r#set_role(
261        &self,
262        mut payload: RoleManagerSetRoleRequest,
263    ) -> fidl::client::QueryResponseFut<
264        RoleManagerSetRoleResult,
265        fidl::encoding::DefaultFuchsiaResourceDialect,
266    > {
267        RoleManagerProxyInterface::r#set_role(self, payload)
268    }
269}
270
271impl RoleManagerProxyInterface for RoleManagerProxy {
272    type SetRoleResponseFut = fidl::client::QueryResponseFut<
273        RoleManagerSetRoleResult,
274        fidl::encoding::DefaultFuchsiaResourceDialect,
275    >;
276    fn r#set_role(&self, mut payload: RoleManagerSetRoleRequest) -> Self::SetRoleResponseFut {
277        fn _decode(
278            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
279        ) -> Result<RoleManagerSetRoleResult, fidl::Error> {
280            let _response = fidl::client::decode_transaction_body::<
281                fidl::encoding::FlexibleResultType<RoleManagerSetRoleResponse, i32>,
282                fidl::encoding::DefaultFuchsiaResourceDialect,
283                0x617dd765af923edc,
284            >(_buf?)?
285            .into_result::<RoleManagerMarker>("set_role")?;
286            Ok(_response.map(|x| x))
287        }
288        self.client.send_query_and_decode::<RoleManagerSetRoleRequest, RoleManagerSetRoleResult>(
289            &mut payload,
290            0x617dd765af923edc,
291            fidl::encoding::DynamicFlags::FLEXIBLE,
292            _decode,
293        )
294    }
295}
296
297pub struct RoleManagerEventStream {
298    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
299}
300
301impl std::marker::Unpin for RoleManagerEventStream {}
302
303impl futures::stream::FusedStream for RoleManagerEventStream {
304    fn is_terminated(&self) -> bool {
305        self.event_receiver.is_terminated()
306    }
307}
308
309impl futures::Stream for RoleManagerEventStream {
310    type Item = Result<RoleManagerEvent, fidl::Error>;
311
312    fn poll_next(
313        mut self: std::pin::Pin<&mut Self>,
314        cx: &mut std::task::Context<'_>,
315    ) -> std::task::Poll<Option<Self::Item>> {
316        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
317            &mut self.event_receiver,
318            cx
319        )?) {
320            Some(buf) => std::task::Poll::Ready(Some(RoleManagerEvent::decode(buf))),
321            None => std::task::Poll::Ready(None),
322        }
323    }
324}
325
326#[derive(Debug)]
327pub enum RoleManagerEvent {
328    #[non_exhaustive]
329    _UnknownEvent {
330        /// Ordinal of the event that was sent.
331        ordinal: u64,
332    },
333}
334
335impl RoleManagerEvent {
336    /// Decodes a message buffer as a [`RoleManagerEvent`].
337    fn decode(
338        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
339    ) -> Result<RoleManagerEvent, fidl::Error> {
340        let (bytes, _handles) = buf.split_mut();
341        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
342        debug_assert_eq!(tx_header.tx_id, 0);
343        match tx_header.ordinal {
344            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
345                Ok(RoleManagerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
346            }
347            _ => Err(fidl::Error::UnknownOrdinal {
348                ordinal: tx_header.ordinal,
349                protocol_name: <RoleManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
350            }),
351        }
352    }
353}
354
355/// A Stream of incoming requests for fuchsia.scheduler/RoleManager.
356pub struct RoleManagerRequestStream {
357    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
358    is_terminated: bool,
359}
360
361impl std::marker::Unpin for RoleManagerRequestStream {}
362
363impl futures::stream::FusedStream for RoleManagerRequestStream {
364    fn is_terminated(&self) -> bool {
365        self.is_terminated
366    }
367}
368
369impl fidl::endpoints::RequestStream for RoleManagerRequestStream {
370    type Protocol = RoleManagerMarker;
371    type ControlHandle = RoleManagerControlHandle;
372
373    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
374        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
375    }
376
377    fn control_handle(&self) -> Self::ControlHandle {
378        RoleManagerControlHandle { inner: self.inner.clone() }
379    }
380
381    fn into_inner(
382        self,
383    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
384    {
385        (self.inner, self.is_terminated)
386    }
387
388    fn from_inner(
389        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
390        is_terminated: bool,
391    ) -> Self {
392        Self { inner, is_terminated }
393    }
394}
395
396impl futures::Stream for RoleManagerRequestStream {
397    type Item = Result<RoleManagerRequest, fidl::Error>;
398
399    fn poll_next(
400        mut self: std::pin::Pin<&mut Self>,
401        cx: &mut std::task::Context<'_>,
402    ) -> std::task::Poll<Option<Self::Item>> {
403        let this = &mut *self;
404        if this.inner.check_shutdown(cx) {
405            this.is_terminated = true;
406            return std::task::Poll::Ready(None);
407        }
408        if this.is_terminated {
409            panic!("polled RoleManagerRequestStream after completion");
410        }
411        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
412            |bytes, handles| {
413                match this.inner.channel().read_etc(cx, bytes, handles) {
414                    std::task::Poll::Ready(Ok(())) => {}
415                    std::task::Poll::Pending => return std::task::Poll::Pending,
416                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
417                        this.is_terminated = true;
418                        return std::task::Poll::Ready(None);
419                    }
420                    std::task::Poll::Ready(Err(e)) => {
421                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
422                            e.into(),
423                        ))));
424                    }
425                }
426
427                // A message has been received from the channel
428                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
429
430                std::task::Poll::Ready(Some(match header.ordinal {
431                    0x617dd765af923edc => {
432                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
433                        let mut req = fidl::new_empty!(
434                            RoleManagerSetRoleRequest,
435                            fidl::encoding::DefaultFuchsiaResourceDialect
436                        );
437                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RoleManagerSetRoleRequest>(&header, _body_bytes, handles, &mut req)?;
438                        let control_handle = RoleManagerControlHandle { inner: this.inner.clone() };
439                        Ok(RoleManagerRequest::SetRole {
440                            payload: req,
441                            responder: RoleManagerSetRoleResponder {
442                                control_handle: std::mem::ManuallyDrop::new(control_handle),
443                                tx_id: header.tx_id,
444                            },
445                        })
446                    }
447                    _ if header.tx_id == 0
448                        && header
449                            .dynamic_flags()
450                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
451                    {
452                        Ok(RoleManagerRequest::_UnknownMethod {
453                            ordinal: header.ordinal,
454                            control_handle: RoleManagerControlHandle { inner: this.inner.clone() },
455                            method_type: fidl::MethodType::OneWay,
456                        })
457                    }
458                    _ if header
459                        .dynamic_flags()
460                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
461                    {
462                        this.inner.send_framework_err(
463                            fidl::encoding::FrameworkErr::UnknownMethod,
464                            header.tx_id,
465                            header.ordinal,
466                            header.dynamic_flags(),
467                            (bytes, handles),
468                        )?;
469                        Ok(RoleManagerRequest::_UnknownMethod {
470                            ordinal: header.ordinal,
471                            control_handle: RoleManagerControlHandle { inner: this.inner.clone() },
472                            method_type: fidl::MethodType::TwoWay,
473                        })
474                    }
475                    _ => Err(fidl::Error::UnknownOrdinal {
476                        ordinal: header.ordinal,
477                        protocol_name:
478                            <RoleManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
479                    }),
480                }))
481            },
482        )
483    }
484}
485
486/// Allows callers to modify the runtime profiles of zircon objects.
487#[derive(Debug)]
488pub enum RoleManagerRequest {
489    /// Sets the given object's performance parameters based on the requested
490    /// role. The exact parameters of the role are system dependent and may
491    /// vary based on device-specific tuning and/or runtime system goals.
492    ///
493    /// + request `target` is a handle to a zircon object to which a profile
494    ///     can be applied.
495    /// + request `role` is the name of the role to apply to the target.
496    /// + request `input_parameters` is a vector of key/value pairs used to
497    ///     distinguish between multiple variants of the same role.
498    /// - response `output_parameters` is a vector of key/value pairs that
499    ///     roles can be configured to emit.
500    /// * error a zx_status value indicating success or failure.
501    SetRole { payload: RoleManagerSetRoleRequest, responder: RoleManagerSetRoleResponder },
502    /// An interaction was received which does not match any known method.
503    #[non_exhaustive]
504    _UnknownMethod {
505        /// Ordinal of the method that was called.
506        ordinal: u64,
507        control_handle: RoleManagerControlHandle,
508        method_type: fidl::MethodType,
509    },
510}
511
512impl RoleManagerRequest {
513    #[allow(irrefutable_let_patterns)]
514    pub fn into_set_role(self) -> Option<(RoleManagerSetRoleRequest, RoleManagerSetRoleResponder)> {
515        if let RoleManagerRequest::SetRole { payload, responder } = self {
516            Some((payload, responder))
517        } else {
518            None
519        }
520    }
521
522    /// Name of the method defined in FIDL
523    pub fn method_name(&self) -> &'static str {
524        match *self {
525            RoleManagerRequest::SetRole { .. } => "set_role",
526            RoleManagerRequest::_UnknownMethod {
527                method_type: fidl::MethodType::OneWay, ..
528            } => "unknown one-way method",
529            RoleManagerRequest::_UnknownMethod {
530                method_type: fidl::MethodType::TwoWay, ..
531            } => "unknown two-way method",
532        }
533    }
534}
535
536#[derive(Debug, Clone)]
537pub struct RoleManagerControlHandle {
538    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
539}
540
541impl fidl::endpoints::ControlHandle for RoleManagerControlHandle {
542    fn shutdown(&self) {
543        self.inner.shutdown()
544    }
545
546    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
547        self.inner.shutdown_with_epitaph(status)
548    }
549
550    fn is_closed(&self) -> bool {
551        self.inner.channel().is_closed()
552    }
553    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
554        self.inner.channel().on_closed()
555    }
556
557    #[cfg(target_os = "fuchsia")]
558    fn signal_peer(
559        &self,
560        clear_mask: zx::Signals,
561        set_mask: zx::Signals,
562    ) -> Result<(), zx_status::Status> {
563        use fidl::Peered;
564        self.inner.channel().signal_peer(clear_mask, set_mask)
565    }
566}
567
568impl RoleManagerControlHandle {}
569
570#[must_use = "FIDL methods require a response to be sent"]
571#[derive(Debug)]
572pub struct RoleManagerSetRoleResponder {
573    control_handle: std::mem::ManuallyDrop<RoleManagerControlHandle>,
574    tx_id: u32,
575}
576
577/// Set the the channel to be shutdown (see [`RoleManagerControlHandle::shutdown`])
578/// if the responder is dropped without sending a response, so that the client
579/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
580impl std::ops::Drop for RoleManagerSetRoleResponder {
581    fn drop(&mut self) {
582        self.control_handle.shutdown();
583        // Safety: drops once, never accessed again
584        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
585    }
586}
587
588impl fidl::endpoints::Responder for RoleManagerSetRoleResponder {
589    type ControlHandle = RoleManagerControlHandle;
590
591    fn control_handle(&self) -> &RoleManagerControlHandle {
592        &self.control_handle
593    }
594
595    fn drop_without_shutdown(mut self) {
596        // Safety: drops once, never accessed again due to mem::forget
597        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
598        // Prevent Drop from running (which would shut down the channel)
599        std::mem::forget(self);
600    }
601}
602
603impl RoleManagerSetRoleResponder {
604    /// Sends a response to the FIDL transaction.
605    ///
606    /// Sets the channel to shutdown if an error occurs.
607    pub fn send(
608        self,
609        mut result: Result<RoleManagerSetRoleResponse, i32>,
610    ) -> Result<(), fidl::Error> {
611        let _result = self.send_raw(result);
612        if _result.is_err() {
613            self.control_handle.shutdown();
614        }
615        self.drop_without_shutdown();
616        _result
617    }
618
619    /// Similar to "send" but does not shutdown the channel if an error occurs.
620    pub fn send_no_shutdown_on_err(
621        self,
622        mut result: Result<RoleManagerSetRoleResponse, i32>,
623    ) -> Result<(), fidl::Error> {
624        let _result = self.send_raw(result);
625        self.drop_without_shutdown();
626        _result
627    }
628
629    fn send_raw(
630        &self,
631        mut result: Result<RoleManagerSetRoleResponse, i32>,
632    ) -> Result<(), fidl::Error> {
633        self.control_handle
634            .inner
635            .send::<fidl::encoding::FlexibleResultType<RoleManagerSetRoleResponse, i32>>(
636                fidl::encoding::FlexibleResult::new(result.as_mut().map_err(|e| *e)),
637                self.tx_id,
638                0x617dd765af923edc,
639                fidl::encoding::DynamicFlags::FLEXIBLE,
640            )
641    }
642}
643
644mod internal {
645    use super::*;
646
647    impl RoleManagerSetRoleRequest {
648        #[inline(always)]
649        fn max_ordinal_present(&self) -> u64 {
650            if let Some(_) = self.input_parameters {
651                return 3;
652            }
653            if let Some(_) = self.role {
654                return 2;
655            }
656            if let Some(_) = self.target {
657                return 1;
658            }
659            0
660        }
661    }
662
663    impl fidl::encoding::ResourceTypeMarker for RoleManagerSetRoleRequest {
664        type Borrowed<'a> = &'a mut Self;
665        fn take_or_borrow<'a>(
666            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
667        ) -> Self::Borrowed<'a> {
668            value
669        }
670    }
671
672    unsafe impl fidl::encoding::TypeMarker for RoleManagerSetRoleRequest {
673        type Owned = Self;
674
675        #[inline(always)]
676        fn inline_align(_context: fidl::encoding::Context) -> usize {
677            8
678        }
679
680        #[inline(always)]
681        fn inline_size(_context: fidl::encoding::Context) -> usize {
682            16
683        }
684    }
685
686    unsafe impl
687        fidl::encoding::Encode<
688            RoleManagerSetRoleRequest,
689            fidl::encoding::DefaultFuchsiaResourceDialect,
690        > for &mut RoleManagerSetRoleRequest
691    {
692        unsafe fn encode(
693            self,
694            encoder: &mut fidl::encoding::Encoder<
695                '_,
696                fidl::encoding::DefaultFuchsiaResourceDialect,
697            >,
698            offset: usize,
699            mut depth: fidl::encoding::Depth,
700        ) -> fidl::Result<()> {
701            encoder.debug_check_bounds::<RoleManagerSetRoleRequest>(offset);
702            // Vector header
703            let max_ordinal: u64 = self.max_ordinal_present();
704            encoder.write_num(max_ordinal, offset);
705            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
706            // Calling encoder.out_of_line_offset(0) is not allowed.
707            if max_ordinal == 0 {
708                return Ok(());
709            }
710            depth.increment()?;
711            let envelope_size = 8;
712            let bytes_len = max_ordinal as usize * envelope_size;
713            #[allow(unused_variables)]
714            let offset = encoder.out_of_line_offset(bytes_len);
715            let mut _prev_end_offset: usize = 0;
716            if 1 > max_ordinal {
717                return Ok(());
718            }
719
720            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
721            // are envelope_size bytes.
722            let cur_offset: usize = (1 - 1) * envelope_size;
723
724            // Zero reserved fields.
725            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
726
727            // Safety:
728            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
729            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
730            //   envelope_size bytes, there is always sufficient room.
731            fidl::encoding::encode_in_envelope_optional::<
732                RoleTarget,
733                fidl::encoding::DefaultFuchsiaResourceDialect,
734            >(
735                self.target
736                    .as_mut()
737                    .map(<RoleTarget as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
738                encoder,
739                offset + cur_offset,
740                depth,
741            )?;
742
743            _prev_end_offset = cur_offset + envelope_size;
744            if 2 > max_ordinal {
745                return Ok(());
746            }
747
748            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
749            // are envelope_size bytes.
750            let cur_offset: usize = (2 - 1) * envelope_size;
751
752            // Zero reserved fields.
753            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
754
755            // Safety:
756            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
757            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
758            //   envelope_size bytes, there is always sufficient room.
759            fidl::encoding::encode_in_envelope_optional::<
760                RoleName,
761                fidl::encoding::DefaultFuchsiaResourceDialect,
762            >(
763                self.role.as_ref().map(<RoleName as fidl::encoding::ValueTypeMarker>::borrow),
764                encoder,
765                offset + cur_offset,
766                depth,
767            )?;
768
769            _prev_end_offset = cur_offset + envelope_size;
770            if 3 > max_ordinal {
771                return Ok(());
772            }
773
774            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
775            // are envelope_size bytes.
776            let cur_offset: usize = (3 - 1) * envelope_size;
777
778            // Zero reserved fields.
779            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
780
781            // Safety:
782            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
783            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
784            //   envelope_size bytes, there is always sufficient room.
785            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<Parameter, 512>, fidl::encoding::DefaultFuchsiaResourceDialect>(
786            self.input_parameters.as_ref().map(<fidl::encoding::Vector<Parameter, 512> as fidl::encoding::ValueTypeMarker>::borrow),
787            encoder, offset + cur_offset, depth
788        )?;
789
790            _prev_end_offset = cur_offset + envelope_size;
791
792            Ok(())
793        }
794    }
795
796    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
797        for RoleManagerSetRoleRequest
798    {
799        #[inline(always)]
800        fn new_empty() -> Self {
801            Self::default()
802        }
803
804        unsafe fn decode(
805            &mut self,
806            decoder: &mut fidl::encoding::Decoder<
807                '_,
808                fidl::encoding::DefaultFuchsiaResourceDialect,
809            >,
810            offset: usize,
811            mut depth: fidl::encoding::Depth,
812        ) -> fidl::Result<()> {
813            decoder.debug_check_bounds::<Self>(offset);
814            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
815                None => return Err(fidl::Error::NotNullable),
816                Some(len) => len,
817            };
818            // Calling decoder.out_of_line_offset(0) is not allowed.
819            if len == 0 {
820                return Ok(());
821            };
822            depth.increment()?;
823            let envelope_size = 8;
824            let bytes_len = len * envelope_size;
825            let offset = decoder.out_of_line_offset(bytes_len)?;
826            // Decode the envelope for each type.
827            let mut _next_ordinal_to_read = 0;
828            let mut next_offset = offset;
829            let end_offset = offset + bytes_len;
830            _next_ordinal_to_read += 1;
831            if next_offset >= end_offset {
832                return Ok(());
833            }
834
835            // Decode unknown envelopes for gaps in ordinals.
836            while _next_ordinal_to_read < 1 {
837                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
838                _next_ordinal_to_read += 1;
839                next_offset += envelope_size;
840            }
841
842            let next_out_of_line = decoder.next_out_of_line();
843            let handles_before = decoder.remaining_handles();
844            if let Some((inlined, num_bytes, num_handles)) =
845                fidl::encoding::decode_envelope_header(decoder, next_offset)?
846            {
847                let member_inline_size =
848                    <RoleTarget as fidl::encoding::TypeMarker>::inline_size(decoder.context);
849                if inlined != (member_inline_size <= 4) {
850                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
851                }
852                let inner_offset;
853                let mut inner_depth = depth.clone();
854                if inlined {
855                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
856                    inner_offset = next_offset;
857                } else {
858                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
859                    inner_depth.increment()?;
860                }
861                let val_ref = self.target.get_or_insert_with(|| {
862                    fidl::new_empty!(RoleTarget, fidl::encoding::DefaultFuchsiaResourceDialect)
863                });
864                fidl::decode!(
865                    RoleTarget,
866                    fidl::encoding::DefaultFuchsiaResourceDialect,
867                    val_ref,
868                    decoder,
869                    inner_offset,
870                    inner_depth
871                )?;
872                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
873                {
874                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
875                }
876                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
877                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
878                }
879            }
880
881            next_offset += envelope_size;
882            _next_ordinal_to_read += 1;
883            if next_offset >= end_offset {
884                return Ok(());
885            }
886
887            // Decode unknown envelopes for gaps in ordinals.
888            while _next_ordinal_to_read < 2 {
889                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
890                _next_ordinal_to_read += 1;
891                next_offset += envelope_size;
892            }
893
894            let next_out_of_line = decoder.next_out_of_line();
895            let handles_before = decoder.remaining_handles();
896            if let Some((inlined, num_bytes, num_handles)) =
897                fidl::encoding::decode_envelope_header(decoder, next_offset)?
898            {
899                let member_inline_size =
900                    <RoleName as fidl::encoding::TypeMarker>::inline_size(decoder.context);
901                if inlined != (member_inline_size <= 4) {
902                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
903                }
904                let inner_offset;
905                let mut inner_depth = depth.clone();
906                if inlined {
907                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
908                    inner_offset = next_offset;
909                } else {
910                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
911                    inner_depth.increment()?;
912                }
913                let val_ref = self.role.get_or_insert_with(|| {
914                    fidl::new_empty!(RoleName, fidl::encoding::DefaultFuchsiaResourceDialect)
915                });
916                fidl::decode!(
917                    RoleName,
918                    fidl::encoding::DefaultFuchsiaResourceDialect,
919                    val_ref,
920                    decoder,
921                    inner_offset,
922                    inner_depth
923                )?;
924                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
925                {
926                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
927                }
928                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
929                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
930                }
931            }
932
933            next_offset += envelope_size;
934            _next_ordinal_to_read += 1;
935            if next_offset >= end_offset {
936                return Ok(());
937            }
938
939            // Decode unknown envelopes for gaps in ordinals.
940            while _next_ordinal_to_read < 3 {
941                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
942                _next_ordinal_to_read += 1;
943                next_offset += envelope_size;
944            }
945
946            let next_out_of_line = decoder.next_out_of_line();
947            let handles_before = decoder.remaining_handles();
948            if let Some((inlined, num_bytes, num_handles)) =
949                fidl::encoding::decode_envelope_header(decoder, next_offset)?
950            {
951                let member_inline_size = <fidl::encoding::Vector<Parameter, 512> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
952                if inlined != (member_inline_size <= 4) {
953                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
954                }
955                let inner_offset;
956                let mut inner_depth = depth.clone();
957                if inlined {
958                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
959                    inner_offset = next_offset;
960                } else {
961                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
962                    inner_depth.increment()?;
963                }
964                let val_ref =
965                self.input_parameters.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<Parameter, 512>, fidl::encoding::DefaultFuchsiaResourceDialect));
966                fidl::decode!(fidl::encoding::Vector<Parameter, 512>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
967                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
968                {
969                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
970                }
971                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
972                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
973                }
974            }
975
976            next_offset += envelope_size;
977
978            // Decode the remaining unknown envelopes.
979            while next_offset < end_offset {
980                _next_ordinal_to_read += 1;
981                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
982                next_offset += envelope_size;
983            }
984
985            Ok(())
986        }
987    }
988
989    impl RoleManagerSetRoleResponse {
990        #[inline(always)]
991        fn max_ordinal_present(&self) -> u64 {
992            if let Some(_) = self.output_parameters {
993                return 1;
994            }
995            0
996        }
997    }
998
999    impl fidl::encoding::ResourceTypeMarker for RoleManagerSetRoleResponse {
1000        type Borrowed<'a> = &'a mut Self;
1001        fn take_or_borrow<'a>(
1002            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1003        ) -> Self::Borrowed<'a> {
1004            value
1005        }
1006    }
1007
1008    unsafe impl fidl::encoding::TypeMarker for RoleManagerSetRoleResponse {
1009        type Owned = Self;
1010
1011        #[inline(always)]
1012        fn inline_align(_context: fidl::encoding::Context) -> usize {
1013            8
1014        }
1015
1016        #[inline(always)]
1017        fn inline_size(_context: fidl::encoding::Context) -> usize {
1018            16
1019        }
1020    }
1021
1022    unsafe impl
1023        fidl::encoding::Encode<
1024            RoleManagerSetRoleResponse,
1025            fidl::encoding::DefaultFuchsiaResourceDialect,
1026        > for &mut RoleManagerSetRoleResponse
1027    {
1028        unsafe fn encode(
1029            self,
1030            encoder: &mut fidl::encoding::Encoder<
1031                '_,
1032                fidl::encoding::DefaultFuchsiaResourceDialect,
1033            >,
1034            offset: usize,
1035            mut depth: fidl::encoding::Depth,
1036        ) -> fidl::Result<()> {
1037            encoder.debug_check_bounds::<RoleManagerSetRoleResponse>(offset);
1038            // Vector header
1039            let max_ordinal: u64 = self.max_ordinal_present();
1040            encoder.write_num(max_ordinal, offset);
1041            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1042            // Calling encoder.out_of_line_offset(0) is not allowed.
1043            if max_ordinal == 0 {
1044                return Ok(());
1045            }
1046            depth.increment()?;
1047            let envelope_size = 8;
1048            let bytes_len = max_ordinal as usize * envelope_size;
1049            #[allow(unused_variables)]
1050            let offset = encoder.out_of_line_offset(bytes_len);
1051            let mut _prev_end_offset: usize = 0;
1052            if 1 > max_ordinal {
1053                return Ok(());
1054            }
1055
1056            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1057            // are envelope_size bytes.
1058            let cur_offset: usize = (1 - 1) * envelope_size;
1059
1060            // Zero reserved fields.
1061            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1062
1063            // Safety:
1064            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1065            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1066            //   envelope_size bytes, there is always sufficient room.
1067            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<Parameter, 512>, fidl::encoding::DefaultFuchsiaResourceDialect>(
1068            self.output_parameters.as_ref().map(<fidl::encoding::Vector<Parameter, 512> as fidl::encoding::ValueTypeMarker>::borrow),
1069            encoder, offset + cur_offset, depth
1070        )?;
1071
1072            _prev_end_offset = cur_offset + envelope_size;
1073
1074            Ok(())
1075        }
1076    }
1077
1078    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1079        for RoleManagerSetRoleResponse
1080    {
1081        #[inline(always)]
1082        fn new_empty() -> Self {
1083            Self::default()
1084        }
1085
1086        unsafe fn decode(
1087            &mut self,
1088            decoder: &mut fidl::encoding::Decoder<
1089                '_,
1090                fidl::encoding::DefaultFuchsiaResourceDialect,
1091            >,
1092            offset: usize,
1093            mut depth: fidl::encoding::Depth,
1094        ) -> fidl::Result<()> {
1095            decoder.debug_check_bounds::<Self>(offset);
1096            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1097                None => return Err(fidl::Error::NotNullable),
1098                Some(len) => len,
1099            };
1100            // Calling decoder.out_of_line_offset(0) is not allowed.
1101            if len == 0 {
1102                return Ok(());
1103            };
1104            depth.increment()?;
1105            let envelope_size = 8;
1106            let bytes_len = len * envelope_size;
1107            let offset = decoder.out_of_line_offset(bytes_len)?;
1108            // Decode the envelope for each type.
1109            let mut _next_ordinal_to_read = 0;
1110            let mut next_offset = offset;
1111            let end_offset = offset + bytes_len;
1112            _next_ordinal_to_read += 1;
1113            if next_offset >= end_offset {
1114                return Ok(());
1115            }
1116
1117            // Decode unknown envelopes for gaps in ordinals.
1118            while _next_ordinal_to_read < 1 {
1119                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1120                _next_ordinal_to_read += 1;
1121                next_offset += envelope_size;
1122            }
1123
1124            let next_out_of_line = decoder.next_out_of_line();
1125            let handles_before = decoder.remaining_handles();
1126            if let Some((inlined, num_bytes, num_handles)) =
1127                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1128            {
1129                let member_inline_size = <fidl::encoding::Vector<Parameter, 512> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1130                if inlined != (member_inline_size <= 4) {
1131                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1132                }
1133                let inner_offset;
1134                let mut inner_depth = depth.clone();
1135                if inlined {
1136                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1137                    inner_offset = next_offset;
1138                } else {
1139                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1140                    inner_depth.increment()?;
1141                }
1142                let val_ref =
1143                self.output_parameters.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<Parameter, 512>, fidl::encoding::DefaultFuchsiaResourceDialect));
1144                fidl::decode!(fidl::encoding::Vector<Parameter, 512>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
1145                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1146                {
1147                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1148                }
1149                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1150                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1151                }
1152            }
1153
1154            next_offset += envelope_size;
1155
1156            // Decode the remaining unknown envelopes.
1157            while next_offset < end_offset {
1158                _next_ordinal_to_read += 1;
1159                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1160                next_offset += envelope_size;
1161            }
1162
1163            Ok(())
1164        }
1165    }
1166
1167    impl fidl::encoding::ResourceTypeMarker for RoleTarget {
1168        type Borrowed<'a> = &'a mut Self;
1169        fn take_or_borrow<'a>(
1170            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1171        ) -> Self::Borrowed<'a> {
1172            value
1173        }
1174    }
1175
1176    unsafe impl fidl::encoding::TypeMarker for RoleTarget {
1177        type Owned = Self;
1178
1179        #[inline(always)]
1180        fn inline_align(_context: fidl::encoding::Context) -> usize {
1181            8
1182        }
1183
1184        #[inline(always)]
1185        fn inline_size(_context: fidl::encoding::Context) -> usize {
1186            16
1187        }
1188    }
1189
1190    unsafe impl fidl::encoding::Encode<RoleTarget, fidl::encoding::DefaultFuchsiaResourceDialect>
1191        for &mut RoleTarget
1192    {
1193        #[inline]
1194        unsafe fn encode(
1195            self,
1196            encoder: &mut fidl::encoding::Encoder<
1197                '_,
1198                fidl::encoding::DefaultFuchsiaResourceDialect,
1199            >,
1200            offset: usize,
1201            _depth: fidl::encoding::Depth,
1202        ) -> fidl::Result<()> {
1203            encoder.debug_check_bounds::<RoleTarget>(offset);
1204            encoder.write_num::<u64>(self.ordinal(), offset);
1205            match self {
1206                RoleTarget::Thread(ref mut val) => fidl::encoding::encode_in_envelope::<
1207                    fidl::encoding::HandleType<
1208                        fidl::Thread,
1209                        { fidl::ObjectType::THREAD.into_raw() },
1210                        2147483648,
1211                    >,
1212                    fidl::encoding::DefaultFuchsiaResourceDialect,
1213                >(
1214                    <fidl::encoding::HandleType<
1215                        fidl::Thread,
1216                        { fidl::ObjectType::THREAD.into_raw() },
1217                        2147483648,
1218                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1219                        val
1220                    ),
1221                    encoder,
1222                    offset + 8,
1223                    _depth,
1224                ),
1225                RoleTarget::Vmar(ref mut val) => fidl::encoding::encode_in_envelope::<
1226                    fidl::encoding::HandleType<
1227                        fidl::Vmar,
1228                        { fidl::ObjectType::VMAR.into_raw() },
1229                        2147483648,
1230                    >,
1231                    fidl::encoding::DefaultFuchsiaResourceDialect,
1232                >(
1233                    <fidl::encoding::HandleType<
1234                        fidl::Vmar,
1235                        { fidl::ObjectType::VMAR.into_raw() },
1236                        2147483648,
1237                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1238                        val
1239                    ),
1240                    encoder,
1241                    offset + 8,
1242                    _depth,
1243                ),
1244                RoleTarget::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
1245            }
1246        }
1247    }
1248
1249    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for RoleTarget {
1250        #[inline(always)]
1251        fn new_empty() -> Self {
1252            Self::__SourceBreaking { unknown_ordinal: 0 }
1253        }
1254
1255        #[inline]
1256        unsafe fn decode(
1257            &mut self,
1258            decoder: &mut fidl::encoding::Decoder<
1259                '_,
1260                fidl::encoding::DefaultFuchsiaResourceDialect,
1261            >,
1262            offset: usize,
1263            mut depth: fidl::encoding::Depth,
1264        ) -> fidl::Result<()> {
1265            decoder.debug_check_bounds::<Self>(offset);
1266            #[allow(unused_variables)]
1267            let next_out_of_line = decoder.next_out_of_line();
1268            let handles_before = decoder.remaining_handles();
1269            let (ordinal, inlined, num_bytes, num_handles) =
1270                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
1271
1272            let member_inline_size = match ordinal {
1273                1 => <fidl::encoding::HandleType<
1274                    fidl::Thread,
1275                    { fidl::ObjectType::THREAD.into_raw() },
1276                    2147483648,
1277                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1278                2 => <fidl::encoding::HandleType<
1279                    fidl::Vmar,
1280                    { fidl::ObjectType::VMAR.into_raw() },
1281                    2147483648,
1282                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1283                0 => return Err(fidl::Error::UnknownUnionTag),
1284                _ => num_bytes as usize,
1285            };
1286
1287            if inlined != (member_inline_size <= 4) {
1288                return Err(fidl::Error::InvalidInlineBitInEnvelope);
1289            }
1290            let _inner_offset;
1291            if inlined {
1292                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
1293                _inner_offset = offset + 8;
1294            } else {
1295                depth.increment()?;
1296                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1297            }
1298            match ordinal {
1299                1 => {
1300                    #[allow(irrefutable_let_patterns)]
1301                    if let RoleTarget::Thread(_) = self {
1302                        // Do nothing, read the value into the object
1303                    } else {
1304                        // Initialize `self` to the right variant
1305                        *self = RoleTarget::Thread(
1306                            fidl::new_empty!(fidl::encoding::HandleType<fidl::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
1307                        );
1308                    }
1309                    #[allow(irrefutable_let_patterns)]
1310                    if let RoleTarget::Thread(ref mut val) = self {
1311                        fidl::decode!(fidl::encoding::HandleType<fidl::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val, decoder, _inner_offset, depth)?;
1312                    } else {
1313                        unreachable!()
1314                    }
1315                }
1316                2 => {
1317                    #[allow(irrefutable_let_patterns)]
1318                    if let RoleTarget::Vmar(_) = self {
1319                        // Do nothing, read the value into the object
1320                    } else {
1321                        // Initialize `self` to the right variant
1322                        *self = RoleTarget::Vmar(
1323                            fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
1324                        );
1325                    }
1326                    #[allow(irrefutable_let_patterns)]
1327                    if let RoleTarget::Vmar(ref mut val) = self {
1328                        fidl::decode!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val, decoder, _inner_offset, depth)?;
1329                    } else {
1330                        unreachable!()
1331                    }
1332                }
1333                #[allow(deprecated)]
1334                ordinal => {
1335                    for _ in 0..num_handles {
1336                        decoder.drop_next_handle()?;
1337                    }
1338                    *self = RoleTarget::__SourceBreaking { unknown_ordinal: ordinal };
1339                }
1340            }
1341            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
1342                return Err(fidl::Error::InvalidNumBytesInEnvelope);
1343            }
1344            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1345                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1346            }
1347            Ok(())
1348        }
1349    }
1350}