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::Handle {
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    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
546        self.inner.shutdown_with_epitaph(status)
547    }
548
549    fn is_closed(&self) -> bool {
550        self.inner.channel().is_closed()
551    }
552    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
553        self.inner.channel().on_closed()
554    }
555
556    #[cfg(target_os = "fuchsia")]
557    fn signal_peer(
558        &self,
559        clear_mask: zx::Signals,
560        set_mask: zx::Signals,
561    ) -> Result<(), zx_status::Status> {
562        use fidl::Peered;
563        self.inner.channel().signal_peer(clear_mask, set_mask)
564    }
565}
566
567impl RoleManagerControlHandle {}
568
569#[must_use = "FIDL methods require a response to be sent"]
570#[derive(Debug)]
571pub struct RoleManagerSetRoleResponder {
572    control_handle: std::mem::ManuallyDrop<RoleManagerControlHandle>,
573    tx_id: u32,
574}
575
576/// Set the the channel to be shutdown (see [`RoleManagerControlHandle::shutdown`])
577/// if the responder is dropped without sending a response, so that the client
578/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
579impl std::ops::Drop for RoleManagerSetRoleResponder {
580    fn drop(&mut self) {
581        self.control_handle.shutdown();
582        // Safety: drops once, never accessed again
583        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
584    }
585}
586
587impl fidl::endpoints::Responder for RoleManagerSetRoleResponder {
588    type ControlHandle = RoleManagerControlHandle;
589
590    fn control_handle(&self) -> &RoleManagerControlHandle {
591        &self.control_handle
592    }
593
594    fn drop_without_shutdown(mut self) {
595        // Safety: drops once, never accessed again due to mem::forget
596        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
597        // Prevent Drop from running (which would shut down the channel)
598        std::mem::forget(self);
599    }
600}
601
602impl RoleManagerSetRoleResponder {
603    /// Sends a response to the FIDL transaction.
604    ///
605    /// Sets the channel to shutdown if an error occurs.
606    pub fn send(
607        self,
608        mut result: Result<RoleManagerSetRoleResponse, i32>,
609    ) -> Result<(), fidl::Error> {
610        let _result = self.send_raw(result);
611        if _result.is_err() {
612            self.control_handle.shutdown();
613        }
614        self.drop_without_shutdown();
615        _result
616    }
617
618    /// Similar to "send" but does not shutdown the channel if an error occurs.
619    pub fn send_no_shutdown_on_err(
620        self,
621        mut result: Result<RoleManagerSetRoleResponse, i32>,
622    ) -> Result<(), fidl::Error> {
623        let _result = self.send_raw(result);
624        self.drop_without_shutdown();
625        _result
626    }
627
628    fn send_raw(
629        &self,
630        mut result: Result<RoleManagerSetRoleResponse, i32>,
631    ) -> Result<(), fidl::Error> {
632        self.control_handle
633            .inner
634            .send::<fidl::encoding::FlexibleResultType<RoleManagerSetRoleResponse, i32>>(
635                fidl::encoding::FlexibleResult::new(result.as_mut().map_err(|e| *e)),
636                self.tx_id,
637                0x617dd765af923edc,
638                fidl::encoding::DynamicFlags::FLEXIBLE,
639            )
640    }
641}
642
643mod internal {
644    use super::*;
645
646    impl RoleManagerSetRoleRequest {
647        #[inline(always)]
648        fn max_ordinal_present(&self) -> u64 {
649            if let Some(_) = self.input_parameters {
650                return 3;
651            }
652            if let Some(_) = self.role {
653                return 2;
654            }
655            if let Some(_) = self.target {
656                return 1;
657            }
658            0
659        }
660    }
661
662    impl fidl::encoding::ResourceTypeMarker for RoleManagerSetRoleRequest {
663        type Borrowed<'a> = &'a mut Self;
664        fn take_or_borrow<'a>(
665            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
666        ) -> Self::Borrowed<'a> {
667            value
668        }
669    }
670
671    unsafe impl fidl::encoding::TypeMarker for RoleManagerSetRoleRequest {
672        type Owned = Self;
673
674        #[inline(always)]
675        fn inline_align(_context: fidl::encoding::Context) -> usize {
676            8
677        }
678
679        #[inline(always)]
680        fn inline_size(_context: fidl::encoding::Context) -> usize {
681            16
682        }
683    }
684
685    unsafe impl
686        fidl::encoding::Encode<
687            RoleManagerSetRoleRequest,
688            fidl::encoding::DefaultFuchsiaResourceDialect,
689        > for &mut RoleManagerSetRoleRequest
690    {
691        unsafe fn encode(
692            self,
693            encoder: &mut fidl::encoding::Encoder<
694                '_,
695                fidl::encoding::DefaultFuchsiaResourceDialect,
696            >,
697            offset: usize,
698            mut depth: fidl::encoding::Depth,
699        ) -> fidl::Result<()> {
700            encoder.debug_check_bounds::<RoleManagerSetRoleRequest>(offset);
701            // Vector header
702            let max_ordinal: u64 = self.max_ordinal_present();
703            encoder.write_num(max_ordinal, offset);
704            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
705            // Calling encoder.out_of_line_offset(0) is not allowed.
706            if max_ordinal == 0 {
707                return Ok(());
708            }
709            depth.increment()?;
710            let envelope_size = 8;
711            let bytes_len = max_ordinal as usize * envelope_size;
712            #[allow(unused_variables)]
713            let offset = encoder.out_of_line_offset(bytes_len);
714            let mut _prev_end_offset: usize = 0;
715            if 1 > max_ordinal {
716                return Ok(());
717            }
718
719            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
720            // are envelope_size bytes.
721            let cur_offset: usize = (1 - 1) * envelope_size;
722
723            // Zero reserved fields.
724            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
725
726            // Safety:
727            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
728            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
729            //   envelope_size bytes, there is always sufficient room.
730            fidl::encoding::encode_in_envelope_optional::<
731                RoleTarget,
732                fidl::encoding::DefaultFuchsiaResourceDialect,
733            >(
734                self.target
735                    .as_mut()
736                    .map(<RoleTarget as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
737                encoder,
738                offset + cur_offset,
739                depth,
740            )?;
741
742            _prev_end_offset = cur_offset + envelope_size;
743            if 2 > max_ordinal {
744                return Ok(());
745            }
746
747            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
748            // are envelope_size bytes.
749            let cur_offset: usize = (2 - 1) * envelope_size;
750
751            // Zero reserved fields.
752            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
753
754            // Safety:
755            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
756            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
757            //   envelope_size bytes, there is always sufficient room.
758            fidl::encoding::encode_in_envelope_optional::<
759                RoleName,
760                fidl::encoding::DefaultFuchsiaResourceDialect,
761            >(
762                self.role.as_ref().map(<RoleName as fidl::encoding::ValueTypeMarker>::borrow),
763                encoder,
764                offset + cur_offset,
765                depth,
766            )?;
767
768            _prev_end_offset = cur_offset + envelope_size;
769            if 3 > max_ordinal {
770                return Ok(());
771            }
772
773            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
774            // are envelope_size bytes.
775            let cur_offset: usize = (3 - 1) * envelope_size;
776
777            // Zero reserved fields.
778            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
779
780            // Safety:
781            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
782            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
783            //   envelope_size bytes, there is always sufficient room.
784            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<Parameter, 512>, fidl::encoding::DefaultFuchsiaResourceDialect>(
785            self.input_parameters.as_ref().map(<fidl::encoding::Vector<Parameter, 512> as fidl::encoding::ValueTypeMarker>::borrow),
786            encoder, offset + cur_offset, depth
787        )?;
788
789            _prev_end_offset = cur_offset + envelope_size;
790
791            Ok(())
792        }
793    }
794
795    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
796        for RoleManagerSetRoleRequest
797    {
798        #[inline(always)]
799        fn new_empty() -> Self {
800            Self::default()
801        }
802
803        unsafe fn decode(
804            &mut self,
805            decoder: &mut fidl::encoding::Decoder<
806                '_,
807                fidl::encoding::DefaultFuchsiaResourceDialect,
808            >,
809            offset: usize,
810            mut depth: fidl::encoding::Depth,
811        ) -> fidl::Result<()> {
812            decoder.debug_check_bounds::<Self>(offset);
813            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
814                None => return Err(fidl::Error::NotNullable),
815                Some(len) => len,
816            };
817            // Calling decoder.out_of_line_offset(0) is not allowed.
818            if len == 0 {
819                return Ok(());
820            };
821            depth.increment()?;
822            let envelope_size = 8;
823            let bytes_len = len * envelope_size;
824            let offset = decoder.out_of_line_offset(bytes_len)?;
825            // Decode the envelope for each type.
826            let mut _next_ordinal_to_read = 0;
827            let mut next_offset = offset;
828            let end_offset = offset + bytes_len;
829            _next_ordinal_to_read += 1;
830            if next_offset >= end_offset {
831                return Ok(());
832            }
833
834            // Decode unknown envelopes for gaps in ordinals.
835            while _next_ordinal_to_read < 1 {
836                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
837                _next_ordinal_to_read += 1;
838                next_offset += envelope_size;
839            }
840
841            let next_out_of_line = decoder.next_out_of_line();
842            let handles_before = decoder.remaining_handles();
843            if let Some((inlined, num_bytes, num_handles)) =
844                fidl::encoding::decode_envelope_header(decoder, next_offset)?
845            {
846                let member_inline_size =
847                    <RoleTarget as fidl::encoding::TypeMarker>::inline_size(decoder.context);
848                if inlined != (member_inline_size <= 4) {
849                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
850                }
851                let inner_offset;
852                let mut inner_depth = depth.clone();
853                if inlined {
854                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
855                    inner_offset = next_offset;
856                } else {
857                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
858                    inner_depth.increment()?;
859                }
860                let val_ref = self.target.get_or_insert_with(|| {
861                    fidl::new_empty!(RoleTarget, fidl::encoding::DefaultFuchsiaResourceDialect)
862                });
863                fidl::decode!(
864                    RoleTarget,
865                    fidl::encoding::DefaultFuchsiaResourceDialect,
866                    val_ref,
867                    decoder,
868                    inner_offset,
869                    inner_depth
870                )?;
871                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
872                {
873                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
874                }
875                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
876                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
877                }
878            }
879
880            next_offset += envelope_size;
881            _next_ordinal_to_read += 1;
882            if next_offset >= end_offset {
883                return Ok(());
884            }
885
886            // Decode unknown envelopes for gaps in ordinals.
887            while _next_ordinal_to_read < 2 {
888                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
889                _next_ordinal_to_read += 1;
890                next_offset += envelope_size;
891            }
892
893            let next_out_of_line = decoder.next_out_of_line();
894            let handles_before = decoder.remaining_handles();
895            if let Some((inlined, num_bytes, num_handles)) =
896                fidl::encoding::decode_envelope_header(decoder, next_offset)?
897            {
898                let member_inline_size =
899                    <RoleName as fidl::encoding::TypeMarker>::inline_size(decoder.context);
900                if inlined != (member_inline_size <= 4) {
901                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
902                }
903                let inner_offset;
904                let mut inner_depth = depth.clone();
905                if inlined {
906                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
907                    inner_offset = next_offset;
908                } else {
909                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
910                    inner_depth.increment()?;
911                }
912                let val_ref = self.role.get_or_insert_with(|| {
913                    fidl::new_empty!(RoleName, fidl::encoding::DefaultFuchsiaResourceDialect)
914                });
915                fidl::decode!(
916                    RoleName,
917                    fidl::encoding::DefaultFuchsiaResourceDialect,
918                    val_ref,
919                    decoder,
920                    inner_offset,
921                    inner_depth
922                )?;
923                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
924                {
925                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
926                }
927                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
928                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
929                }
930            }
931
932            next_offset += envelope_size;
933            _next_ordinal_to_read += 1;
934            if next_offset >= end_offset {
935                return Ok(());
936            }
937
938            // Decode unknown envelopes for gaps in ordinals.
939            while _next_ordinal_to_read < 3 {
940                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
941                _next_ordinal_to_read += 1;
942                next_offset += envelope_size;
943            }
944
945            let next_out_of_line = decoder.next_out_of_line();
946            let handles_before = decoder.remaining_handles();
947            if let Some((inlined, num_bytes, num_handles)) =
948                fidl::encoding::decode_envelope_header(decoder, next_offset)?
949            {
950                let member_inline_size = <fidl::encoding::Vector<Parameter, 512> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
951                if inlined != (member_inline_size <= 4) {
952                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
953                }
954                let inner_offset;
955                let mut inner_depth = depth.clone();
956                if inlined {
957                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
958                    inner_offset = next_offset;
959                } else {
960                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
961                    inner_depth.increment()?;
962                }
963                let val_ref =
964                self.input_parameters.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<Parameter, 512>, fidl::encoding::DefaultFuchsiaResourceDialect));
965                fidl::decode!(fidl::encoding::Vector<Parameter, 512>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
966                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
967                {
968                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
969                }
970                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
971                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
972                }
973            }
974
975            next_offset += envelope_size;
976
977            // Decode the remaining unknown envelopes.
978            while next_offset < end_offset {
979                _next_ordinal_to_read += 1;
980                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
981                next_offset += envelope_size;
982            }
983
984            Ok(())
985        }
986    }
987
988    impl RoleManagerSetRoleResponse {
989        #[inline(always)]
990        fn max_ordinal_present(&self) -> u64 {
991            if let Some(_) = self.output_parameters {
992                return 1;
993            }
994            0
995        }
996    }
997
998    impl fidl::encoding::ResourceTypeMarker for RoleManagerSetRoleResponse {
999        type Borrowed<'a> = &'a mut Self;
1000        fn take_or_borrow<'a>(
1001            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1002        ) -> Self::Borrowed<'a> {
1003            value
1004        }
1005    }
1006
1007    unsafe impl fidl::encoding::TypeMarker for RoleManagerSetRoleResponse {
1008        type Owned = Self;
1009
1010        #[inline(always)]
1011        fn inline_align(_context: fidl::encoding::Context) -> usize {
1012            8
1013        }
1014
1015        #[inline(always)]
1016        fn inline_size(_context: fidl::encoding::Context) -> usize {
1017            16
1018        }
1019    }
1020
1021    unsafe impl
1022        fidl::encoding::Encode<
1023            RoleManagerSetRoleResponse,
1024            fidl::encoding::DefaultFuchsiaResourceDialect,
1025        > for &mut RoleManagerSetRoleResponse
1026    {
1027        unsafe fn encode(
1028            self,
1029            encoder: &mut fidl::encoding::Encoder<
1030                '_,
1031                fidl::encoding::DefaultFuchsiaResourceDialect,
1032            >,
1033            offset: usize,
1034            mut depth: fidl::encoding::Depth,
1035        ) -> fidl::Result<()> {
1036            encoder.debug_check_bounds::<RoleManagerSetRoleResponse>(offset);
1037            // Vector header
1038            let max_ordinal: u64 = self.max_ordinal_present();
1039            encoder.write_num(max_ordinal, offset);
1040            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1041            // Calling encoder.out_of_line_offset(0) is not allowed.
1042            if max_ordinal == 0 {
1043                return Ok(());
1044            }
1045            depth.increment()?;
1046            let envelope_size = 8;
1047            let bytes_len = max_ordinal as usize * envelope_size;
1048            #[allow(unused_variables)]
1049            let offset = encoder.out_of_line_offset(bytes_len);
1050            let mut _prev_end_offset: usize = 0;
1051            if 1 > max_ordinal {
1052                return Ok(());
1053            }
1054
1055            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1056            // are envelope_size bytes.
1057            let cur_offset: usize = (1 - 1) * envelope_size;
1058
1059            // Zero reserved fields.
1060            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1061
1062            // Safety:
1063            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1064            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1065            //   envelope_size bytes, there is always sufficient room.
1066            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<Parameter, 512>, fidl::encoding::DefaultFuchsiaResourceDialect>(
1067            self.output_parameters.as_ref().map(<fidl::encoding::Vector<Parameter, 512> as fidl::encoding::ValueTypeMarker>::borrow),
1068            encoder, offset + cur_offset, depth
1069        )?;
1070
1071            _prev_end_offset = cur_offset + envelope_size;
1072
1073            Ok(())
1074        }
1075    }
1076
1077    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1078        for RoleManagerSetRoleResponse
1079    {
1080        #[inline(always)]
1081        fn new_empty() -> Self {
1082            Self::default()
1083        }
1084
1085        unsafe fn decode(
1086            &mut self,
1087            decoder: &mut fidl::encoding::Decoder<
1088                '_,
1089                fidl::encoding::DefaultFuchsiaResourceDialect,
1090            >,
1091            offset: usize,
1092            mut depth: fidl::encoding::Depth,
1093        ) -> fidl::Result<()> {
1094            decoder.debug_check_bounds::<Self>(offset);
1095            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1096                None => return Err(fidl::Error::NotNullable),
1097                Some(len) => len,
1098            };
1099            // Calling decoder.out_of_line_offset(0) is not allowed.
1100            if len == 0 {
1101                return Ok(());
1102            };
1103            depth.increment()?;
1104            let envelope_size = 8;
1105            let bytes_len = len * envelope_size;
1106            let offset = decoder.out_of_line_offset(bytes_len)?;
1107            // Decode the envelope for each type.
1108            let mut _next_ordinal_to_read = 0;
1109            let mut next_offset = offset;
1110            let end_offset = offset + bytes_len;
1111            _next_ordinal_to_read += 1;
1112            if next_offset >= end_offset {
1113                return Ok(());
1114            }
1115
1116            // Decode unknown envelopes for gaps in ordinals.
1117            while _next_ordinal_to_read < 1 {
1118                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1119                _next_ordinal_to_read += 1;
1120                next_offset += envelope_size;
1121            }
1122
1123            let next_out_of_line = decoder.next_out_of_line();
1124            let handles_before = decoder.remaining_handles();
1125            if let Some((inlined, num_bytes, num_handles)) =
1126                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1127            {
1128                let member_inline_size = <fidl::encoding::Vector<Parameter, 512> 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 =
1142                self.output_parameters.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<Parameter, 512>, fidl::encoding::DefaultFuchsiaResourceDialect));
1143                fidl::decode!(fidl::encoding::Vector<Parameter, 512>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
1144                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1145                {
1146                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1147                }
1148                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1149                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1150                }
1151            }
1152
1153            next_offset += envelope_size;
1154
1155            // Decode the remaining unknown envelopes.
1156            while next_offset < end_offset {
1157                _next_ordinal_to_read += 1;
1158                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1159                next_offset += envelope_size;
1160            }
1161
1162            Ok(())
1163        }
1164    }
1165
1166    impl fidl::encoding::ResourceTypeMarker for RoleTarget {
1167        type Borrowed<'a> = &'a mut Self;
1168        fn take_or_borrow<'a>(
1169            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1170        ) -> Self::Borrowed<'a> {
1171            value
1172        }
1173    }
1174
1175    unsafe impl fidl::encoding::TypeMarker for RoleTarget {
1176        type Owned = Self;
1177
1178        #[inline(always)]
1179        fn inline_align(_context: fidl::encoding::Context) -> usize {
1180            8
1181        }
1182
1183        #[inline(always)]
1184        fn inline_size(_context: fidl::encoding::Context) -> usize {
1185            16
1186        }
1187    }
1188
1189    unsafe impl fidl::encoding::Encode<RoleTarget, fidl::encoding::DefaultFuchsiaResourceDialect>
1190        for &mut RoleTarget
1191    {
1192        #[inline]
1193        unsafe fn encode(
1194            self,
1195            encoder: &mut fidl::encoding::Encoder<
1196                '_,
1197                fidl::encoding::DefaultFuchsiaResourceDialect,
1198            >,
1199            offset: usize,
1200            _depth: fidl::encoding::Depth,
1201        ) -> fidl::Result<()> {
1202            encoder.debug_check_bounds::<RoleTarget>(offset);
1203            encoder.write_num::<u64>(self.ordinal(), offset);
1204            match self {
1205                RoleTarget::Thread(ref mut val) => fidl::encoding::encode_in_envelope::<
1206                    fidl::encoding::HandleType<
1207                        fidl::Thread,
1208                        { fidl::ObjectType::THREAD.into_raw() },
1209                        2147483648,
1210                    >,
1211                    fidl::encoding::DefaultFuchsiaResourceDialect,
1212                >(
1213                    <fidl::encoding::HandleType<
1214                        fidl::Thread,
1215                        { fidl::ObjectType::THREAD.into_raw() },
1216                        2147483648,
1217                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1218                        val
1219                    ),
1220                    encoder,
1221                    offset + 8,
1222                    _depth,
1223                ),
1224                RoleTarget::Vmar(ref mut val) => fidl::encoding::encode_in_envelope::<
1225                    fidl::encoding::HandleType<
1226                        fidl::Vmar,
1227                        { fidl::ObjectType::VMAR.into_raw() },
1228                        2147483648,
1229                    >,
1230                    fidl::encoding::DefaultFuchsiaResourceDialect,
1231                >(
1232                    <fidl::encoding::HandleType<
1233                        fidl::Vmar,
1234                        { fidl::ObjectType::VMAR.into_raw() },
1235                        2147483648,
1236                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1237                        val
1238                    ),
1239                    encoder,
1240                    offset + 8,
1241                    _depth,
1242                ),
1243                RoleTarget::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
1244            }
1245        }
1246    }
1247
1248    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for RoleTarget {
1249        #[inline(always)]
1250        fn new_empty() -> Self {
1251            Self::__SourceBreaking { unknown_ordinal: 0 }
1252        }
1253
1254        #[inline]
1255        unsafe fn decode(
1256            &mut self,
1257            decoder: &mut fidl::encoding::Decoder<
1258                '_,
1259                fidl::encoding::DefaultFuchsiaResourceDialect,
1260            >,
1261            offset: usize,
1262            mut depth: fidl::encoding::Depth,
1263        ) -> fidl::Result<()> {
1264            decoder.debug_check_bounds::<Self>(offset);
1265            #[allow(unused_variables)]
1266            let next_out_of_line = decoder.next_out_of_line();
1267            let handles_before = decoder.remaining_handles();
1268            let (ordinal, inlined, num_bytes, num_handles) =
1269                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
1270
1271            let member_inline_size = match ordinal {
1272                1 => <fidl::encoding::HandleType<
1273                    fidl::Thread,
1274                    { fidl::ObjectType::THREAD.into_raw() },
1275                    2147483648,
1276                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1277                2 => <fidl::encoding::HandleType<
1278                    fidl::Vmar,
1279                    { fidl::ObjectType::VMAR.into_raw() },
1280                    2147483648,
1281                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1282                0 => return Err(fidl::Error::UnknownUnionTag),
1283                _ => num_bytes as usize,
1284            };
1285
1286            if inlined != (member_inline_size <= 4) {
1287                return Err(fidl::Error::InvalidInlineBitInEnvelope);
1288            }
1289            let _inner_offset;
1290            if inlined {
1291                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
1292                _inner_offset = offset + 8;
1293            } else {
1294                depth.increment()?;
1295                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1296            }
1297            match ordinal {
1298                1 => {
1299                    #[allow(irrefutable_let_patterns)]
1300                    if let RoleTarget::Thread(_) = self {
1301                        // Do nothing, read the value into the object
1302                    } else {
1303                        // Initialize `self` to the right variant
1304                        *self = RoleTarget::Thread(
1305                            fidl::new_empty!(fidl::encoding::HandleType<fidl::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
1306                        );
1307                    }
1308                    #[allow(irrefutable_let_patterns)]
1309                    if let RoleTarget::Thread(ref mut val) = self {
1310                        fidl::decode!(fidl::encoding::HandleType<fidl::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val, decoder, _inner_offset, depth)?;
1311                    } else {
1312                        unreachable!()
1313                    }
1314                }
1315                2 => {
1316                    #[allow(irrefutable_let_patterns)]
1317                    if let RoleTarget::Vmar(_) = self {
1318                        // Do nothing, read the value into the object
1319                    } else {
1320                        // Initialize `self` to the right variant
1321                        *self = RoleTarget::Vmar(
1322                            fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
1323                        );
1324                    }
1325                    #[allow(irrefutable_let_patterns)]
1326                    if let RoleTarget::Vmar(ref mut val) = self {
1327                        fidl::decode!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val, decoder, _inner_offset, depth)?;
1328                    } else {
1329                        unreachable!()
1330                    }
1331                }
1332                #[allow(deprecated)]
1333                ordinal => {
1334                    for _ in 0..num_handles {
1335                        decoder.drop_next_handle()?;
1336                    }
1337                    *self = RoleTarget::__SourceBreaking { unknown_ordinal: ordinal };
1338                }
1339            }
1340            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
1341                return Err(fidl::Error::InvalidNumBytesInEnvelope);
1342            }
1343            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1344                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1345            }
1346            Ok(())
1347        }
1348    }
1349}