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