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