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_hardware_sensors_realm_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct RealmFactoryCreateRealmRequest {
16 pub dictionary: fidl::endpoints::ServerEnd<fidl_fuchsia_component_sandbox::DictionaryMarker>,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20 for RealmFactoryCreateRealmRequest
21{
22}
23
24#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
25pub struct RealmFactoryMarker;
26
27impl fidl::endpoints::ProtocolMarker for RealmFactoryMarker {
28 type Proxy = RealmFactoryProxy;
29 type RequestStream = RealmFactoryRequestStream;
30 #[cfg(target_os = "fuchsia")]
31 type SynchronousProxy = RealmFactorySynchronousProxy;
32
33 const DEBUG_NAME: &'static str = "fuchsia.hardware.sensors.realm.RealmFactory";
34}
35impl fidl::endpoints::DiscoverableProtocolMarker for RealmFactoryMarker {}
36pub type RealmFactoryCreateRealmResult = Result<(), fidl_fuchsia_testing_harness::OperationError>;
37
38pub trait RealmFactoryProxyInterface: Send + Sync {
39 type CreateRealmResponseFut: std::future::Future<Output = Result<RealmFactoryCreateRealmResult, fidl::Error>>
40 + Send;
41 fn r#create_realm(
42 &self,
43 dictionary: fidl::endpoints::ServerEnd<fidl_fuchsia_component_sandbox::DictionaryMarker>,
44 ) -> Self::CreateRealmResponseFut;
45}
46#[derive(Debug)]
47#[cfg(target_os = "fuchsia")]
48pub struct RealmFactorySynchronousProxy {
49 client: fidl::client::sync::Client,
50}
51
52#[cfg(target_os = "fuchsia")]
53impl fidl::endpoints::SynchronousProxy for RealmFactorySynchronousProxy {
54 type Proxy = RealmFactoryProxy;
55 type Protocol = RealmFactoryMarker;
56
57 fn from_channel(inner: fidl::Channel) -> Self {
58 Self::new(inner)
59 }
60
61 fn into_channel(self) -> fidl::Channel {
62 self.client.into_channel()
63 }
64
65 fn as_channel(&self) -> &fidl::Channel {
66 self.client.as_channel()
67 }
68}
69
70#[cfg(target_os = "fuchsia")]
71impl RealmFactorySynchronousProxy {
72 pub fn new(channel: fidl::Channel) -> Self {
73 let protocol_name = <RealmFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
74 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
75 }
76
77 pub fn into_channel(self) -> fidl::Channel {
78 self.client.into_channel()
79 }
80
81 pub fn wait_for_event(
84 &self,
85 deadline: zx::MonotonicInstant,
86 ) -> Result<RealmFactoryEvent, fidl::Error> {
87 RealmFactoryEvent::decode(self.client.wait_for_event(deadline)?)
88 }
89
90 pub fn r#create_realm(
91 &self,
92 mut dictionary: fidl::endpoints::ServerEnd<
93 fidl_fuchsia_component_sandbox::DictionaryMarker,
94 >,
95 ___deadline: zx::MonotonicInstant,
96 ) -> Result<RealmFactoryCreateRealmResult, fidl::Error> {
97 let _response = self
98 .client
99 .send_query::<RealmFactoryCreateRealmRequest, fidl::encoding::FlexibleResultType<
100 fidl::encoding::EmptyStruct,
101 fidl_fuchsia_testing_harness::OperationError,
102 >>(
103 (dictionary,),
104 0x5d8cdc39529d388d,
105 fidl::encoding::DynamicFlags::FLEXIBLE,
106 ___deadline,
107 )?
108 .into_result::<RealmFactoryMarker>("create_realm")?;
109 Ok(_response.map(|x| x))
110 }
111}
112
113#[derive(Debug, Clone)]
114pub struct RealmFactoryProxy {
115 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
116}
117
118impl fidl::endpoints::Proxy for RealmFactoryProxy {
119 type Protocol = RealmFactoryMarker;
120
121 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
122 Self::new(inner)
123 }
124
125 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
126 self.client.into_channel().map_err(|client| Self { client })
127 }
128
129 fn as_channel(&self) -> &::fidl::AsyncChannel {
130 self.client.as_channel()
131 }
132}
133
134impl RealmFactoryProxy {
135 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
137 let protocol_name = <RealmFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
138 Self { client: fidl::client::Client::new(channel, protocol_name) }
139 }
140
141 pub fn take_event_stream(&self) -> RealmFactoryEventStream {
147 RealmFactoryEventStream { event_receiver: self.client.take_event_receiver() }
148 }
149
150 pub fn r#create_realm(
151 &self,
152 mut dictionary: fidl::endpoints::ServerEnd<
153 fidl_fuchsia_component_sandbox::DictionaryMarker,
154 >,
155 ) -> fidl::client::QueryResponseFut<
156 RealmFactoryCreateRealmResult,
157 fidl::encoding::DefaultFuchsiaResourceDialect,
158 > {
159 RealmFactoryProxyInterface::r#create_realm(self, dictionary)
160 }
161}
162
163impl RealmFactoryProxyInterface for RealmFactoryProxy {
164 type CreateRealmResponseFut = fidl::client::QueryResponseFut<
165 RealmFactoryCreateRealmResult,
166 fidl::encoding::DefaultFuchsiaResourceDialect,
167 >;
168 fn r#create_realm(
169 &self,
170 mut dictionary: fidl::endpoints::ServerEnd<
171 fidl_fuchsia_component_sandbox::DictionaryMarker,
172 >,
173 ) -> Self::CreateRealmResponseFut {
174 fn _decode(
175 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
176 ) -> Result<RealmFactoryCreateRealmResult, fidl::Error> {
177 let _response = fidl::client::decode_transaction_body::<
178 fidl::encoding::FlexibleResultType<
179 fidl::encoding::EmptyStruct,
180 fidl_fuchsia_testing_harness::OperationError,
181 >,
182 fidl::encoding::DefaultFuchsiaResourceDialect,
183 0x5d8cdc39529d388d,
184 >(_buf?)?
185 .into_result::<RealmFactoryMarker>("create_realm")?;
186 Ok(_response.map(|x| x))
187 }
188 self.client
189 .send_query_and_decode::<RealmFactoryCreateRealmRequest, RealmFactoryCreateRealmResult>(
190 (dictionary,),
191 0x5d8cdc39529d388d,
192 fidl::encoding::DynamicFlags::FLEXIBLE,
193 _decode,
194 )
195 }
196}
197
198pub struct RealmFactoryEventStream {
199 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
200}
201
202impl std::marker::Unpin for RealmFactoryEventStream {}
203
204impl futures::stream::FusedStream for RealmFactoryEventStream {
205 fn is_terminated(&self) -> bool {
206 self.event_receiver.is_terminated()
207 }
208}
209
210impl futures::Stream for RealmFactoryEventStream {
211 type Item = Result<RealmFactoryEvent, fidl::Error>;
212
213 fn poll_next(
214 mut self: std::pin::Pin<&mut Self>,
215 cx: &mut std::task::Context<'_>,
216 ) -> std::task::Poll<Option<Self::Item>> {
217 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
218 &mut self.event_receiver,
219 cx
220 )?) {
221 Some(buf) => std::task::Poll::Ready(Some(RealmFactoryEvent::decode(buf))),
222 None => std::task::Poll::Ready(None),
223 }
224 }
225}
226
227#[derive(Debug)]
228pub enum RealmFactoryEvent {
229 #[non_exhaustive]
230 _UnknownEvent {
231 ordinal: u64,
233 },
234}
235
236impl RealmFactoryEvent {
237 fn decode(
239 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
240 ) -> Result<RealmFactoryEvent, fidl::Error> {
241 let (bytes, _handles) = buf.split_mut();
242 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
243 debug_assert_eq!(tx_header.tx_id, 0);
244 match tx_header.ordinal {
245 _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
246 Ok(RealmFactoryEvent::_UnknownEvent { ordinal: tx_header.ordinal })
247 }
248 _ => Err(fidl::Error::UnknownOrdinal {
249 ordinal: tx_header.ordinal,
250 protocol_name: <RealmFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
251 }),
252 }
253 }
254}
255
256pub struct RealmFactoryRequestStream {
258 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
259 is_terminated: bool,
260}
261
262impl std::marker::Unpin for RealmFactoryRequestStream {}
263
264impl futures::stream::FusedStream for RealmFactoryRequestStream {
265 fn is_terminated(&self) -> bool {
266 self.is_terminated
267 }
268}
269
270impl fidl::endpoints::RequestStream for RealmFactoryRequestStream {
271 type Protocol = RealmFactoryMarker;
272 type ControlHandle = RealmFactoryControlHandle;
273
274 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
275 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
276 }
277
278 fn control_handle(&self) -> Self::ControlHandle {
279 RealmFactoryControlHandle { inner: self.inner.clone() }
280 }
281
282 fn into_inner(
283 self,
284 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
285 {
286 (self.inner, self.is_terminated)
287 }
288
289 fn from_inner(
290 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
291 is_terminated: bool,
292 ) -> Self {
293 Self { inner, is_terminated }
294 }
295}
296
297impl futures::Stream for RealmFactoryRequestStream {
298 type Item = Result<RealmFactoryRequest, fidl::Error>;
299
300 fn poll_next(
301 mut self: std::pin::Pin<&mut Self>,
302 cx: &mut std::task::Context<'_>,
303 ) -> std::task::Poll<Option<Self::Item>> {
304 let this = &mut *self;
305 if this.inner.check_shutdown(cx) {
306 this.is_terminated = true;
307 return std::task::Poll::Ready(None);
308 }
309 if this.is_terminated {
310 panic!("polled RealmFactoryRequestStream after completion");
311 }
312 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
313 |bytes, handles| {
314 match this.inner.channel().read_etc(cx, bytes, handles) {
315 std::task::Poll::Ready(Ok(())) => {}
316 std::task::Poll::Pending => return std::task::Poll::Pending,
317 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
318 this.is_terminated = true;
319 return std::task::Poll::Ready(None);
320 }
321 std::task::Poll::Ready(Err(e)) => {
322 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
323 e.into(),
324 ))))
325 }
326 }
327
328 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
330
331 std::task::Poll::Ready(Some(match header.ordinal {
332 0x5d8cdc39529d388d => {
333 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
334 let mut req = fidl::new_empty!(
335 RealmFactoryCreateRealmRequest,
336 fidl::encoding::DefaultFuchsiaResourceDialect
337 );
338 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RealmFactoryCreateRealmRequest>(&header, _body_bytes, handles, &mut req)?;
339 let control_handle =
340 RealmFactoryControlHandle { inner: this.inner.clone() };
341 Ok(RealmFactoryRequest::CreateRealm {
342 dictionary: req.dictionary,
343
344 responder: RealmFactoryCreateRealmResponder {
345 control_handle: std::mem::ManuallyDrop::new(control_handle),
346 tx_id: header.tx_id,
347 },
348 })
349 }
350 _ if header.tx_id == 0
351 && header
352 .dynamic_flags()
353 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
354 {
355 Ok(RealmFactoryRequest::_UnknownMethod {
356 ordinal: header.ordinal,
357 control_handle: RealmFactoryControlHandle { inner: this.inner.clone() },
358 method_type: fidl::MethodType::OneWay,
359 })
360 }
361 _ if header
362 .dynamic_flags()
363 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
364 {
365 this.inner.send_framework_err(
366 fidl::encoding::FrameworkErr::UnknownMethod,
367 header.tx_id,
368 header.ordinal,
369 header.dynamic_flags(),
370 (bytes, handles),
371 )?;
372 Ok(RealmFactoryRequest::_UnknownMethod {
373 ordinal: header.ordinal,
374 control_handle: RealmFactoryControlHandle { inner: this.inner.clone() },
375 method_type: fidl::MethodType::TwoWay,
376 })
377 }
378 _ => Err(fidl::Error::UnknownOrdinal {
379 ordinal: header.ordinal,
380 protocol_name:
381 <RealmFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
382 }),
383 }))
384 },
385 )
386 }
387}
388
389#[derive(Debug)]
390pub enum RealmFactoryRequest {
391 CreateRealm {
392 dictionary: fidl::endpoints::ServerEnd<fidl_fuchsia_component_sandbox::DictionaryMarker>,
393 responder: RealmFactoryCreateRealmResponder,
394 },
395 #[non_exhaustive]
397 _UnknownMethod {
398 ordinal: u64,
400 control_handle: RealmFactoryControlHandle,
401 method_type: fidl::MethodType,
402 },
403}
404
405impl RealmFactoryRequest {
406 #[allow(irrefutable_let_patterns)]
407 pub fn into_create_realm(
408 self,
409 ) -> Option<(
410 fidl::endpoints::ServerEnd<fidl_fuchsia_component_sandbox::DictionaryMarker>,
411 RealmFactoryCreateRealmResponder,
412 )> {
413 if let RealmFactoryRequest::CreateRealm { dictionary, responder } = self {
414 Some((dictionary, responder))
415 } else {
416 None
417 }
418 }
419
420 pub fn method_name(&self) -> &'static str {
422 match *self {
423 RealmFactoryRequest::CreateRealm { .. } => "create_realm",
424 RealmFactoryRequest::_UnknownMethod {
425 method_type: fidl::MethodType::OneWay, ..
426 } => "unknown one-way method",
427 RealmFactoryRequest::_UnknownMethod {
428 method_type: fidl::MethodType::TwoWay, ..
429 } => "unknown two-way method",
430 }
431 }
432}
433
434#[derive(Debug, Clone)]
435pub struct RealmFactoryControlHandle {
436 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
437}
438
439impl fidl::endpoints::ControlHandle for RealmFactoryControlHandle {
440 fn shutdown(&self) {
441 self.inner.shutdown()
442 }
443 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
444 self.inner.shutdown_with_epitaph(status)
445 }
446
447 fn is_closed(&self) -> bool {
448 self.inner.channel().is_closed()
449 }
450 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
451 self.inner.channel().on_closed()
452 }
453
454 #[cfg(target_os = "fuchsia")]
455 fn signal_peer(
456 &self,
457 clear_mask: zx::Signals,
458 set_mask: zx::Signals,
459 ) -> Result<(), zx_status::Status> {
460 use fidl::Peered;
461 self.inner.channel().signal_peer(clear_mask, set_mask)
462 }
463}
464
465impl RealmFactoryControlHandle {}
466
467#[must_use = "FIDL methods require a response to be sent"]
468#[derive(Debug)]
469pub struct RealmFactoryCreateRealmResponder {
470 control_handle: std::mem::ManuallyDrop<RealmFactoryControlHandle>,
471 tx_id: u32,
472}
473
474impl std::ops::Drop for RealmFactoryCreateRealmResponder {
478 fn drop(&mut self) {
479 self.control_handle.shutdown();
480 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
482 }
483}
484
485impl fidl::endpoints::Responder for RealmFactoryCreateRealmResponder {
486 type ControlHandle = RealmFactoryControlHandle;
487
488 fn control_handle(&self) -> &RealmFactoryControlHandle {
489 &self.control_handle
490 }
491
492 fn drop_without_shutdown(mut self) {
493 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
495 std::mem::forget(self);
497 }
498}
499
500impl RealmFactoryCreateRealmResponder {
501 pub fn send(
505 self,
506 mut result: Result<(), fidl_fuchsia_testing_harness::OperationError>,
507 ) -> Result<(), fidl::Error> {
508 let _result = self.send_raw(result);
509 if _result.is_err() {
510 self.control_handle.shutdown();
511 }
512 self.drop_without_shutdown();
513 _result
514 }
515
516 pub fn send_no_shutdown_on_err(
518 self,
519 mut result: Result<(), fidl_fuchsia_testing_harness::OperationError>,
520 ) -> Result<(), fidl::Error> {
521 let _result = self.send_raw(result);
522 self.drop_without_shutdown();
523 _result
524 }
525
526 fn send_raw(
527 &self,
528 mut result: Result<(), fidl_fuchsia_testing_harness::OperationError>,
529 ) -> Result<(), fidl::Error> {
530 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
531 fidl::encoding::EmptyStruct,
532 fidl_fuchsia_testing_harness::OperationError,
533 >>(
534 fidl::encoding::FlexibleResult::new(result),
535 self.tx_id,
536 0x5d8cdc39529d388d,
537 fidl::encoding::DynamicFlags::FLEXIBLE,
538 )
539 }
540}
541
542mod internal {
543 use super::*;
544
545 impl fidl::encoding::ResourceTypeMarker for RealmFactoryCreateRealmRequest {
546 type Borrowed<'a> = &'a mut Self;
547 fn take_or_borrow<'a>(
548 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
549 ) -> Self::Borrowed<'a> {
550 value
551 }
552 }
553
554 unsafe impl fidl::encoding::TypeMarker for RealmFactoryCreateRealmRequest {
555 type Owned = Self;
556
557 #[inline(always)]
558 fn inline_align(_context: fidl::encoding::Context) -> usize {
559 4
560 }
561
562 #[inline(always)]
563 fn inline_size(_context: fidl::encoding::Context) -> usize {
564 4
565 }
566 }
567
568 unsafe impl
569 fidl::encoding::Encode<
570 RealmFactoryCreateRealmRequest,
571 fidl::encoding::DefaultFuchsiaResourceDialect,
572 > for &mut RealmFactoryCreateRealmRequest
573 {
574 #[inline]
575 unsafe fn encode(
576 self,
577 encoder: &mut fidl::encoding::Encoder<
578 '_,
579 fidl::encoding::DefaultFuchsiaResourceDialect,
580 >,
581 offset: usize,
582 _depth: fidl::encoding::Depth,
583 ) -> fidl::Result<()> {
584 encoder.debug_check_bounds::<RealmFactoryCreateRealmRequest>(offset);
585 fidl::encoding::Encode::<
587 RealmFactoryCreateRealmRequest,
588 fidl::encoding::DefaultFuchsiaResourceDialect,
589 >::encode(
590 (<fidl::encoding::Endpoint<
591 fidl::endpoints::ServerEnd<fidl_fuchsia_component_sandbox::DictionaryMarker>,
592 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
593 &mut self.dictionary
594 ),),
595 encoder,
596 offset,
597 _depth,
598 )
599 }
600 }
601 unsafe impl<
602 T0: fidl::encoding::Encode<
603 fidl::encoding::Endpoint<
604 fidl::endpoints::ServerEnd<fidl_fuchsia_component_sandbox::DictionaryMarker>,
605 >,
606 fidl::encoding::DefaultFuchsiaResourceDialect,
607 >,
608 >
609 fidl::encoding::Encode<
610 RealmFactoryCreateRealmRequest,
611 fidl::encoding::DefaultFuchsiaResourceDialect,
612 > for (T0,)
613 {
614 #[inline]
615 unsafe fn encode(
616 self,
617 encoder: &mut fidl::encoding::Encoder<
618 '_,
619 fidl::encoding::DefaultFuchsiaResourceDialect,
620 >,
621 offset: usize,
622 depth: fidl::encoding::Depth,
623 ) -> fidl::Result<()> {
624 encoder.debug_check_bounds::<RealmFactoryCreateRealmRequest>(offset);
625 self.0.encode(encoder, offset + 0, depth)?;
629 Ok(())
630 }
631 }
632
633 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
634 for RealmFactoryCreateRealmRequest
635 {
636 #[inline(always)]
637 fn new_empty() -> Self {
638 Self {
639 dictionary: fidl::new_empty!(
640 fidl::encoding::Endpoint<
641 fidl::endpoints::ServerEnd<
642 fidl_fuchsia_component_sandbox::DictionaryMarker,
643 >,
644 >,
645 fidl::encoding::DefaultFuchsiaResourceDialect
646 ),
647 }
648 }
649
650 #[inline]
651 unsafe fn decode(
652 &mut self,
653 decoder: &mut fidl::encoding::Decoder<
654 '_,
655 fidl::encoding::DefaultFuchsiaResourceDialect,
656 >,
657 offset: usize,
658 _depth: fidl::encoding::Depth,
659 ) -> fidl::Result<()> {
660 decoder.debug_check_bounds::<Self>(offset);
661 fidl::decode!(
663 fidl::encoding::Endpoint<
664 fidl::endpoints::ServerEnd<fidl_fuchsia_component_sandbox::DictionaryMarker>,
665 >,
666 fidl::encoding::DefaultFuchsiaResourceDialect,
667 &mut self.dictionary,
668 decoder,
669 offset + 0,
670 _depth
671 )?;
672 Ok(())
673 }
674 }
675}