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