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_test_componentmanager_stresstests__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct ChildRealmMarker;
16
17impl fidl::endpoints::ProtocolMarker for ChildRealmMarker {
18 type Proxy = ChildRealmProxy;
19 type RequestStream = ChildRealmRequestStream;
20 #[cfg(target_os = "fuchsia")]
21 type SynchronousProxy = ChildRealmSynchronousProxy;
22
23 const DEBUG_NAME: &'static str = "test.componentmanager.stresstests.ChildRealm";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for ChildRealmMarker {}
26
27pub trait ChildRealmProxyInterface: Send + Sync {
28 fn r#stop(&self) -> Result<(), fidl::Error>;
29 type StopChildrenResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
30 fn r#stop_children(&self) -> Self::StopChildrenResponseFut;
31 type CreateChildrenResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
32 fn r#create_children(
33 &self,
34 direct_children: u16,
35 tree_height: u16,
36 ) -> Self::CreateChildrenResponseFut;
37}
38#[derive(Debug)]
39#[cfg(target_os = "fuchsia")]
40pub struct ChildRealmSynchronousProxy {
41 client: fidl::client::sync::Client,
42}
43
44#[cfg(target_os = "fuchsia")]
45impl fidl::endpoints::SynchronousProxy for ChildRealmSynchronousProxy {
46 type Proxy = ChildRealmProxy;
47 type Protocol = ChildRealmMarker;
48
49 fn from_channel(inner: fidl::Channel) -> Self {
50 Self::new(inner)
51 }
52
53 fn into_channel(self) -> fidl::Channel {
54 self.client.into_channel()
55 }
56
57 fn as_channel(&self) -> &fidl::Channel {
58 self.client.as_channel()
59 }
60}
61
62#[cfg(target_os = "fuchsia")]
63impl ChildRealmSynchronousProxy {
64 pub fn new(channel: fidl::Channel) -> Self {
65 let protocol_name = <ChildRealmMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
66 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
67 }
68
69 pub fn into_channel(self) -> fidl::Channel {
70 self.client.into_channel()
71 }
72
73 pub fn wait_for_event(
76 &self,
77 deadline: zx::MonotonicInstant,
78 ) -> Result<ChildRealmEvent, fidl::Error> {
79 ChildRealmEvent::decode(self.client.wait_for_event(deadline)?)
80 }
81
82 pub fn r#stop(&self) -> Result<(), fidl::Error> {
84 self.client.send::<fidl::encoding::EmptyPayload>(
85 (),
86 0x36c34aa66f2a56ab,
87 fidl::encoding::DynamicFlags::empty(),
88 )
89 }
90
91 pub fn r#stop_children(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
92 let _response =
93 self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
94 (),
95 0x61c8762c3aa05df7,
96 fidl::encoding::DynamicFlags::empty(),
97 ___deadline,
98 )?;
99 Ok(_response)
100 }
101
102 pub fn r#create_children(
107 &self,
108 mut direct_children: u16,
109 mut tree_height: u16,
110 ___deadline: zx::MonotonicInstant,
111 ) -> Result<(), fidl::Error> {
112 let _response = self
113 .client
114 .send_query::<ChildRealmCreateChildrenRequest, fidl::encoding::EmptyPayload>(
115 (direct_children, tree_height),
116 0x37a93e012377095c,
117 fidl::encoding::DynamicFlags::empty(),
118 ___deadline,
119 )?;
120 Ok(_response)
121 }
122}
123
124#[cfg(target_os = "fuchsia")]
125impl From<ChildRealmSynchronousProxy> for zx::Handle {
126 fn from(value: ChildRealmSynchronousProxy) -> Self {
127 value.into_channel().into()
128 }
129}
130
131#[cfg(target_os = "fuchsia")]
132impl From<fidl::Channel> for ChildRealmSynchronousProxy {
133 fn from(value: fidl::Channel) -> Self {
134 Self::new(value)
135 }
136}
137
138#[cfg(target_os = "fuchsia")]
139impl fidl::endpoints::FromClient for ChildRealmSynchronousProxy {
140 type Protocol = ChildRealmMarker;
141
142 fn from_client(value: fidl::endpoints::ClientEnd<ChildRealmMarker>) -> Self {
143 Self::new(value.into_channel())
144 }
145}
146
147#[derive(Debug, Clone)]
148pub struct ChildRealmProxy {
149 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
150}
151
152impl fidl::endpoints::Proxy for ChildRealmProxy {
153 type Protocol = ChildRealmMarker;
154
155 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
156 Self::new(inner)
157 }
158
159 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
160 self.client.into_channel().map_err(|client| Self { client })
161 }
162
163 fn as_channel(&self) -> &::fidl::AsyncChannel {
164 self.client.as_channel()
165 }
166}
167
168impl ChildRealmProxy {
169 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
171 let protocol_name = <ChildRealmMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
172 Self { client: fidl::client::Client::new(channel, protocol_name) }
173 }
174
175 pub fn take_event_stream(&self) -> ChildRealmEventStream {
181 ChildRealmEventStream { event_receiver: self.client.take_event_receiver() }
182 }
183
184 pub fn r#stop(&self) -> Result<(), fidl::Error> {
186 ChildRealmProxyInterface::r#stop(self)
187 }
188
189 pub fn r#stop_children(
190 &self,
191 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
192 ChildRealmProxyInterface::r#stop_children(self)
193 }
194
195 pub fn r#create_children(
200 &self,
201 mut direct_children: u16,
202 mut tree_height: u16,
203 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
204 ChildRealmProxyInterface::r#create_children(self, direct_children, tree_height)
205 }
206}
207
208impl ChildRealmProxyInterface for ChildRealmProxy {
209 fn r#stop(&self) -> Result<(), fidl::Error> {
210 self.client.send::<fidl::encoding::EmptyPayload>(
211 (),
212 0x36c34aa66f2a56ab,
213 fidl::encoding::DynamicFlags::empty(),
214 )
215 }
216
217 type StopChildrenResponseFut =
218 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
219 fn r#stop_children(&self) -> Self::StopChildrenResponseFut {
220 fn _decode(
221 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
222 ) -> Result<(), fidl::Error> {
223 let _response = fidl::client::decode_transaction_body::<
224 fidl::encoding::EmptyPayload,
225 fidl::encoding::DefaultFuchsiaResourceDialect,
226 0x61c8762c3aa05df7,
227 >(_buf?)?;
228 Ok(_response)
229 }
230 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
231 (),
232 0x61c8762c3aa05df7,
233 fidl::encoding::DynamicFlags::empty(),
234 _decode,
235 )
236 }
237
238 type CreateChildrenResponseFut =
239 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
240 fn r#create_children(
241 &self,
242 mut direct_children: u16,
243 mut tree_height: u16,
244 ) -> Self::CreateChildrenResponseFut {
245 fn _decode(
246 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
247 ) -> Result<(), fidl::Error> {
248 let _response = fidl::client::decode_transaction_body::<
249 fidl::encoding::EmptyPayload,
250 fidl::encoding::DefaultFuchsiaResourceDialect,
251 0x37a93e012377095c,
252 >(_buf?)?;
253 Ok(_response)
254 }
255 self.client.send_query_and_decode::<ChildRealmCreateChildrenRequest, ()>(
256 (direct_children, tree_height),
257 0x37a93e012377095c,
258 fidl::encoding::DynamicFlags::empty(),
259 _decode,
260 )
261 }
262}
263
264pub struct ChildRealmEventStream {
265 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
266}
267
268impl std::marker::Unpin for ChildRealmEventStream {}
269
270impl futures::stream::FusedStream for ChildRealmEventStream {
271 fn is_terminated(&self) -> bool {
272 self.event_receiver.is_terminated()
273 }
274}
275
276impl futures::Stream for ChildRealmEventStream {
277 type Item = Result<ChildRealmEvent, fidl::Error>;
278
279 fn poll_next(
280 mut self: std::pin::Pin<&mut Self>,
281 cx: &mut std::task::Context<'_>,
282 ) -> std::task::Poll<Option<Self::Item>> {
283 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
284 &mut self.event_receiver,
285 cx
286 )?) {
287 Some(buf) => std::task::Poll::Ready(Some(ChildRealmEvent::decode(buf))),
288 None => std::task::Poll::Ready(None),
289 }
290 }
291}
292
293#[derive(Debug)]
294pub enum ChildRealmEvent {
295 OnConnected {},
296}
297
298impl ChildRealmEvent {
299 #[allow(irrefutable_let_patterns)]
300 pub fn into_on_connected(self) -> Option<()> {
301 if let ChildRealmEvent::OnConnected {} = self { Some(()) } else { None }
302 }
303
304 fn decode(
306 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
307 ) -> Result<ChildRealmEvent, fidl::Error> {
308 let (bytes, _handles) = buf.split_mut();
309 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
310 debug_assert_eq!(tx_header.tx_id, 0);
311 match tx_header.ordinal {
312 0x68a2f3384c114a61 => {
313 let mut out = fidl::new_empty!(
314 fidl::encoding::EmptyPayload,
315 fidl::encoding::DefaultFuchsiaResourceDialect
316 );
317 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
318 Ok((ChildRealmEvent::OnConnected {}))
319 }
320 _ => Err(fidl::Error::UnknownOrdinal {
321 ordinal: tx_header.ordinal,
322 protocol_name: <ChildRealmMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
323 }),
324 }
325 }
326}
327
328pub struct ChildRealmRequestStream {
330 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
331 is_terminated: bool,
332}
333
334impl std::marker::Unpin for ChildRealmRequestStream {}
335
336impl futures::stream::FusedStream for ChildRealmRequestStream {
337 fn is_terminated(&self) -> bool {
338 self.is_terminated
339 }
340}
341
342impl fidl::endpoints::RequestStream for ChildRealmRequestStream {
343 type Protocol = ChildRealmMarker;
344 type ControlHandle = ChildRealmControlHandle;
345
346 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
347 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
348 }
349
350 fn control_handle(&self) -> Self::ControlHandle {
351 ChildRealmControlHandle { inner: self.inner.clone() }
352 }
353
354 fn into_inner(
355 self,
356 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
357 {
358 (self.inner, self.is_terminated)
359 }
360
361 fn from_inner(
362 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
363 is_terminated: bool,
364 ) -> Self {
365 Self { inner, is_terminated }
366 }
367}
368
369impl futures::Stream for ChildRealmRequestStream {
370 type Item = Result<ChildRealmRequest, fidl::Error>;
371
372 fn poll_next(
373 mut self: std::pin::Pin<&mut Self>,
374 cx: &mut std::task::Context<'_>,
375 ) -> std::task::Poll<Option<Self::Item>> {
376 let this = &mut *self;
377 if this.inner.check_shutdown(cx) {
378 this.is_terminated = true;
379 return std::task::Poll::Ready(None);
380 }
381 if this.is_terminated {
382 panic!("polled ChildRealmRequestStream after completion");
383 }
384 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
385 |bytes, handles| {
386 match this.inner.channel().read_etc(cx, bytes, handles) {
387 std::task::Poll::Ready(Ok(())) => {}
388 std::task::Poll::Pending => return std::task::Poll::Pending,
389 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
390 this.is_terminated = true;
391 return std::task::Poll::Ready(None);
392 }
393 std::task::Poll::Ready(Err(e)) => {
394 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
395 e.into(),
396 ))));
397 }
398 }
399
400 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
402
403 std::task::Poll::Ready(Some(match header.ordinal {
404 0x36c34aa66f2a56ab => {
405 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
406 let mut req = fidl::new_empty!(
407 fidl::encoding::EmptyPayload,
408 fidl::encoding::DefaultFuchsiaResourceDialect
409 );
410 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
411 let control_handle = ChildRealmControlHandle { inner: this.inner.clone() };
412 Ok(ChildRealmRequest::Stop { control_handle })
413 }
414 0x61c8762c3aa05df7 => {
415 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
416 let mut req = fidl::new_empty!(
417 fidl::encoding::EmptyPayload,
418 fidl::encoding::DefaultFuchsiaResourceDialect
419 );
420 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
421 let control_handle = ChildRealmControlHandle { inner: this.inner.clone() };
422 Ok(ChildRealmRequest::StopChildren {
423 responder: ChildRealmStopChildrenResponder {
424 control_handle: std::mem::ManuallyDrop::new(control_handle),
425 tx_id: header.tx_id,
426 },
427 })
428 }
429 0x37a93e012377095c => {
430 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
431 let mut req = fidl::new_empty!(
432 ChildRealmCreateChildrenRequest,
433 fidl::encoding::DefaultFuchsiaResourceDialect
434 );
435 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChildRealmCreateChildrenRequest>(&header, _body_bytes, handles, &mut req)?;
436 let control_handle = ChildRealmControlHandle { inner: this.inner.clone() };
437 Ok(ChildRealmRequest::CreateChildren {
438 direct_children: req.direct_children,
439 tree_height: req.tree_height,
440
441 responder: ChildRealmCreateChildrenResponder {
442 control_handle: std::mem::ManuallyDrop::new(control_handle),
443 tx_id: header.tx_id,
444 },
445 })
446 }
447 _ => Err(fidl::Error::UnknownOrdinal {
448 ordinal: header.ordinal,
449 protocol_name:
450 <ChildRealmMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
451 }),
452 }))
453 },
454 )
455 }
456}
457
458#[derive(Debug)]
460pub enum ChildRealmRequest {
461 Stop {
463 control_handle: ChildRealmControlHandle,
464 },
465 StopChildren {
466 responder: ChildRealmStopChildrenResponder,
467 },
468 CreateChildren {
473 direct_children: u16,
474 tree_height: u16,
475 responder: ChildRealmCreateChildrenResponder,
476 },
477}
478
479impl ChildRealmRequest {
480 #[allow(irrefutable_let_patterns)]
481 pub fn into_stop(self) -> Option<(ChildRealmControlHandle)> {
482 if let ChildRealmRequest::Stop { control_handle } = self {
483 Some((control_handle))
484 } else {
485 None
486 }
487 }
488
489 #[allow(irrefutable_let_patterns)]
490 pub fn into_stop_children(self) -> Option<(ChildRealmStopChildrenResponder)> {
491 if let ChildRealmRequest::StopChildren { responder } = self {
492 Some((responder))
493 } else {
494 None
495 }
496 }
497
498 #[allow(irrefutable_let_patterns)]
499 pub fn into_create_children(self) -> Option<(u16, u16, ChildRealmCreateChildrenResponder)> {
500 if let ChildRealmRequest::CreateChildren { direct_children, tree_height, responder } = self
501 {
502 Some((direct_children, tree_height, responder))
503 } else {
504 None
505 }
506 }
507
508 pub fn method_name(&self) -> &'static str {
510 match *self {
511 ChildRealmRequest::Stop { .. } => "stop",
512 ChildRealmRequest::StopChildren { .. } => "stop_children",
513 ChildRealmRequest::CreateChildren { .. } => "create_children",
514 }
515 }
516}
517
518#[derive(Debug, Clone)]
519pub struct ChildRealmControlHandle {
520 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
521}
522
523impl fidl::endpoints::ControlHandle for ChildRealmControlHandle {
524 fn shutdown(&self) {
525 self.inner.shutdown()
526 }
527 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
528 self.inner.shutdown_with_epitaph(status)
529 }
530
531 fn is_closed(&self) -> bool {
532 self.inner.channel().is_closed()
533 }
534 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
535 self.inner.channel().on_closed()
536 }
537
538 #[cfg(target_os = "fuchsia")]
539 fn signal_peer(
540 &self,
541 clear_mask: zx::Signals,
542 set_mask: zx::Signals,
543 ) -> Result<(), zx_status::Status> {
544 use fidl::Peered;
545 self.inner.channel().signal_peer(clear_mask, set_mask)
546 }
547}
548
549impl ChildRealmControlHandle {
550 pub fn send_on_connected(&self) -> Result<(), fidl::Error> {
551 self.inner.send::<fidl::encoding::EmptyPayload>(
552 (),
553 0,
554 0x68a2f3384c114a61,
555 fidl::encoding::DynamicFlags::empty(),
556 )
557 }
558}
559
560#[must_use = "FIDL methods require a response to be sent"]
561#[derive(Debug)]
562pub struct ChildRealmStopChildrenResponder {
563 control_handle: std::mem::ManuallyDrop<ChildRealmControlHandle>,
564 tx_id: u32,
565}
566
567impl std::ops::Drop for ChildRealmStopChildrenResponder {
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 ChildRealmStopChildrenResponder {
579 type ControlHandle = ChildRealmControlHandle;
580
581 fn control_handle(&self) -> &ChildRealmControlHandle {
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 ChildRealmStopChildrenResponder {
594 pub fn send(self) -> Result<(), fidl::Error> {
598 let _result = self.send_raw();
599 if _result.is_err() {
600 self.control_handle.shutdown();
601 }
602 self.drop_without_shutdown();
603 _result
604 }
605
606 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
608 let _result = self.send_raw();
609 self.drop_without_shutdown();
610 _result
611 }
612
613 fn send_raw(&self) -> Result<(), fidl::Error> {
614 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
615 (),
616 self.tx_id,
617 0x61c8762c3aa05df7,
618 fidl::encoding::DynamicFlags::empty(),
619 )
620 }
621}
622
623#[must_use = "FIDL methods require a response to be sent"]
624#[derive(Debug)]
625pub struct ChildRealmCreateChildrenResponder {
626 control_handle: std::mem::ManuallyDrop<ChildRealmControlHandle>,
627 tx_id: u32,
628}
629
630impl std::ops::Drop for ChildRealmCreateChildrenResponder {
634 fn drop(&mut self) {
635 self.control_handle.shutdown();
636 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
638 }
639}
640
641impl fidl::endpoints::Responder for ChildRealmCreateChildrenResponder {
642 type ControlHandle = ChildRealmControlHandle;
643
644 fn control_handle(&self) -> &ChildRealmControlHandle {
645 &self.control_handle
646 }
647
648 fn drop_without_shutdown(mut self) {
649 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
651 std::mem::forget(self);
653 }
654}
655
656impl ChildRealmCreateChildrenResponder {
657 pub fn send(self) -> Result<(), fidl::Error> {
661 let _result = self.send_raw();
662 if _result.is_err() {
663 self.control_handle.shutdown();
664 }
665 self.drop_without_shutdown();
666 _result
667 }
668
669 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
671 let _result = self.send_raw();
672 self.drop_without_shutdown();
673 _result
674 }
675
676 fn send_raw(&self) -> Result<(), fidl::Error> {
677 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
678 (),
679 self.tx_id,
680 0x37a93e012377095c,
681 fidl::encoding::DynamicFlags::empty(),
682 )
683 }
684}
685
686mod internal {
687 use super::*;
688}