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_proxy_stress_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct StressorStuffSocketRequest {
16 pub socket: fidl::Socket,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20 for StressorStuffSocketRequest
21{
22}
23
24#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
25pub struct StressorMarker;
26
27impl fidl::endpoints::ProtocolMarker for StressorMarker {
28 type Proxy = StressorProxy;
29 type RequestStream = StressorRequestStream;
30 #[cfg(target_os = "fuchsia")]
31 type SynchronousProxy = StressorSynchronousProxy;
32
33 const DEBUG_NAME: &'static str = "test.proxy.stress.Stressor";
34}
35impl fidl::endpoints::DiscoverableProtocolMarker for StressorMarker {}
36
37pub trait StressorProxyInterface: Send + Sync {
38 type StuffSocketResponseFut: std::future::Future<Output = Result<u32, fidl::Error>> + Send;
39 fn r#stuff_socket(&self, socket: fidl::Socket) -> Self::StuffSocketResponseFut;
40 type EchoResponseFut: std::future::Future<Output = Result<String, fidl::Error>> + Send;
41 fn r#echo(&self, content: &str) -> Self::EchoResponseFut;
42}
43#[derive(Debug)]
44#[cfg(target_os = "fuchsia")]
45pub struct StressorSynchronousProxy {
46 client: fidl::client::sync::Client,
47}
48
49#[cfg(target_os = "fuchsia")]
50impl fidl::endpoints::SynchronousProxy for StressorSynchronousProxy {
51 type Proxy = StressorProxy;
52 type Protocol = StressorMarker;
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 StressorSynchronousProxy {
69 pub fn new(channel: fidl::Channel) -> Self {
70 let protocol_name = <StressorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
71 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
72 }
73
74 pub fn into_channel(self) -> fidl::Channel {
75 self.client.into_channel()
76 }
77
78 pub fn wait_for_event(
81 &self,
82 deadline: zx::MonotonicInstant,
83 ) -> Result<StressorEvent, fidl::Error> {
84 StressorEvent::decode(self.client.wait_for_event(deadline)?)
85 }
86
87 pub fn r#stuff_socket(
91 &self,
92 mut socket: fidl::Socket,
93 ___deadline: zx::MonotonicInstant,
94 ) -> Result<u32, fidl::Error> {
95 let _response =
96 self.client.send_query::<StressorStuffSocketRequest, StressorStuffSocketResponse>(
97 (socket,),
98 0x3270057179f1ae49,
99 fidl::encoding::DynamicFlags::empty(),
100 ___deadline,
101 )?;
102 Ok(_response.bytes_written)
103 }
104
105 pub fn r#echo(
106 &self,
107 mut content: &str,
108 ___deadline: zx::MonotonicInstant,
109 ) -> Result<String, fidl::Error> {
110 let _response = self.client.send_query::<StressorEchoRequest, StressorEchoResponse>(
111 (content,),
112 0x4463eecf18ad1bd1,
113 fidl::encoding::DynamicFlags::empty(),
114 ___deadline,
115 )?;
116 Ok(_response.content)
117 }
118}
119
120#[cfg(target_os = "fuchsia")]
121impl From<StressorSynchronousProxy> for zx::Handle {
122 fn from(value: StressorSynchronousProxy) -> Self {
123 value.into_channel().into()
124 }
125}
126
127#[cfg(target_os = "fuchsia")]
128impl From<fidl::Channel> for StressorSynchronousProxy {
129 fn from(value: fidl::Channel) -> Self {
130 Self::new(value)
131 }
132}
133
134#[derive(Debug, Clone)]
135pub struct StressorProxy {
136 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
137}
138
139impl fidl::endpoints::Proxy for StressorProxy {
140 type Protocol = StressorMarker;
141
142 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
143 Self::new(inner)
144 }
145
146 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
147 self.client.into_channel().map_err(|client| Self { client })
148 }
149
150 fn as_channel(&self) -> &::fidl::AsyncChannel {
151 self.client.as_channel()
152 }
153}
154
155impl StressorProxy {
156 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
158 let protocol_name = <StressorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
159 Self { client: fidl::client::Client::new(channel, protocol_name) }
160 }
161
162 pub fn take_event_stream(&self) -> StressorEventStream {
168 StressorEventStream { event_receiver: self.client.take_event_receiver() }
169 }
170
171 pub fn r#stuff_socket(
175 &self,
176 mut socket: fidl::Socket,
177 ) -> fidl::client::QueryResponseFut<u32, fidl::encoding::DefaultFuchsiaResourceDialect> {
178 StressorProxyInterface::r#stuff_socket(self, socket)
179 }
180
181 pub fn r#echo(
182 &self,
183 mut content: &str,
184 ) -> fidl::client::QueryResponseFut<String, fidl::encoding::DefaultFuchsiaResourceDialect> {
185 StressorProxyInterface::r#echo(self, content)
186 }
187}
188
189impl StressorProxyInterface for StressorProxy {
190 type StuffSocketResponseFut =
191 fidl::client::QueryResponseFut<u32, fidl::encoding::DefaultFuchsiaResourceDialect>;
192 fn r#stuff_socket(&self, mut socket: fidl::Socket) -> Self::StuffSocketResponseFut {
193 fn _decode(
194 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
195 ) -> Result<u32, fidl::Error> {
196 let _response = fidl::client::decode_transaction_body::<
197 StressorStuffSocketResponse,
198 fidl::encoding::DefaultFuchsiaResourceDialect,
199 0x3270057179f1ae49,
200 >(_buf?)?;
201 Ok(_response.bytes_written)
202 }
203 self.client.send_query_and_decode::<StressorStuffSocketRequest, u32>(
204 (socket,),
205 0x3270057179f1ae49,
206 fidl::encoding::DynamicFlags::empty(),
207 _decode,
208 )
209 }
210
211 type EchoResponseFut =
212 fidl::client::QueryResponseFut<String, fidl::encoding::DefaultFuchsiaResourceDialect>;
213 fn r#echo(&self, mut content: &str) -> Self::EchoResponseFut {
214 fn _decode(
215 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
216 ) -> Result<String, fidl::Error> {
217 let _response = fidl::client::decode_transaction_body::<
218 StressorEchoResponse,
219 fidl::encoding::DefaultFuchsiaResourceDialect,
220 0x4463eecf18ad1bd1,
221 >(_buf?)?;
222 Ok(_response.content)
223 }
224 self.client.send_query_and_decode::<StressorEchoRequest, String>(
225 (content,),
226 0x4463eecf18ad1bd1,
227 fidl::encoding::DynamicFlags::empty(),
228 _decode,
229 )
230 }
231}
232
233pub struct StressorEventStream {
234 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
235}
236
237impl std::marker::Unpin for StressorEventStream {}
238
239impl futures::stream::FusedStream for StressorEventStream {
240 fn is_terminated(&self) -> bool {
241 self.event_receiver.is_terminated()
242 }
243}
244
245impl futures::Stream for StressorEventStream {
246 type Item = Result<StressorEvent, fidl::Error>;
247
248 fn poll_next(
249 mut self: std::pin::Pin<&mut Self>,
250 cx: &mut std::task::Context<'_>,
251 ) -> std::task::Poll<Option<Self::Item>> {
252 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
253 &mut self.event_receiver,
254 cx
255 )?) {
256 Some(buf) => std::task::Poll::Ready(Some(StressorEvent::decode(buf))),
257 None => std::task::Poll::Ready(None),
258 }
259 }
260}
261
262#[derive(Debug)]
263pub enum StressorEvent {}
264
265impl StressorEvent {
266 fn decode(
268 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
269 ) -> Result<StressorEvent, fidl::Error> {
270 let (bytes, _handles) = buf.split_mut();
271 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
272 debug_assert_eq!(tx_header.tx_id, 0);
273 match tx_header.ordinal {
274 _ => Err(fidl::Error::UnknownOrdinal {
275 ordinal: tx_header.ordinal,
276 protocol_name: <StressorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
277 }),
278 }
279 }
280}
281
282pub struct StressorRequestStream {
284 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
285 is_terminated: bool,
286}
287
288impl std::marker::Unpin for StressorRequestStream {}
289
290impl futures::stream::FusedStream for StressorRequestStream {
291 fn is_terminated(&self) -> bool {
292 self.is_terminated
293 }
294}
295
296impl fidl::endpoints::RequestStream for StressorRequestStream {
297 type Protocol = StressorMarker;
298 type ControlHandle = StressorControlHandle;
299
300 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
301 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
302 }
303
304 fn control_handle(&self) -> Self::ControlHandle {
305 StressorControlHandle { inner: self.inner.clone() }
306 }
307
308 fn into_inner(
309 self,
310 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
311 {
312 (self.inner, self.is_terminated)
313 }
314
315 fn from_inner(
316 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
317 is_terminated: bool,
318 ) -> Self {
319 Self { inner, is_terminated }
320 }
321}
322
323impl futures::Stream for StressorRequestStream {
324 type Item = Result<StressorRequest, fidl::Error>;
325
326 fn poll_next(
327 mut self: std::pin::Pin<&mut Self>,
328 cx: &mut std::task::Context<'_>,
329 ) -> std::task::Poll<Option<Self::Item>> {
330 let this = &mut *self;
331 if this.inner.check_shutdown(cx) {
332 this.is_terminated = true;
333 return std::task::Poll::Ready(None);
334 }
335 if this.is_terminated {
336 panic!("polled StressorRequestStream after completion");
337 }
338 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
339 |bytes, handles| {
340 match this.inner.channel().read_etc(cx, bytes, handles) {
341 std::task::Poll::Ready(Ok(())) => {}
342 std::task::Poll::Pending => return std::task::Poll::Pending,
343 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
344 this.is_terminated = true;
345 return std::task::Poll::Ready(None);
346 }
347 std::task::Poll::Ready(Err(e)) => {
348 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
349 e.into(),
350 ))))
351 }
352 }
353
354 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
356
357 std::task::Poll::Ready(Some(match header.ordinal {
358 0x3270057179f1ae49 => {
359 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
360 let mut req = fidl::new_empty!(
361 StressorStuffSocketRequest,
362 fidl::encoding::DefaultFuchsiaResourceDialect
363 );
364 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StressorStuffSocketRequest>(&header, _body_bytes, handles, &mut req)?;
365 let control_handle = StressorControlHandle { inner: this.inner.clone() };
366 Ok(StressorRequest::StuffSocket {
367 socket: req.socket,
368
369 responder: StressorStuffSocketResponder {
370 control_handle: std::mem::ManuallyDrop::new(control_handle),
371 tx_id: header.tx_id,
372 },
373 })
374 }
375 0x4463eecf18ad1bd1 => {
376 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
377 let mut req = fidl::new_empty!(
378 StressorEchoRequest,
379 fidl::encoding::DefaultFuchsiaResourceDialect
380 );
381 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StressorEchoRequest>(&header, _body_bytes, handles, &mut req)?;
382 let control_handle = StressorControlHandle { inner: this.inner.clone() };
383 Ok(StressorRequest::Echo {
384 content: req.content,
385
386 responder: StressorEchoResponder {
387 control_handle: std::mem::ManuallyDrop::new(control_handle),
388 tx_id: header.tx_id,
389 },
390 })
391 }
392 _ => Err(fidl::Error::UnknownOrdinal {
393 ordinal: header.ordinal,
394 protocol_name:
395 <StressorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
396 }),
397 }))
398 },
399 )
400 }
401}
402
403#[derive(Debug)]
404pub enum StressorRequest {
405 StuffSocket {
409 socket: fidl::Socket,
410 responder: StressorStuffSocketResponder,
411 },
412 Echo {
413 content: String,
414 responder: StressorEchoResponder,
415 },
416}
417
418impl StressorRequest {
419 #[allow(irrefutable_let_patterns)]
420 pub fn into_stuff_socket(self) -> Option<(fidl::Socket, StressorStuffSocketResponder)> {
421 if let StressorRequest::StuffSocket { socket, responder } = self {
422 Some((socket, responder))
423 } else {
424 None
425 }
426 }
427
428 #[allow(irrefutable_let_patterns)]
429 pub fn into_echo(self) -> Option<(String, StressorEchoResponder)> {
430 if let StressorRequest::Echo { content, responder } = self {
431 Some((content, responder))
432 } else {
433 None
434 }
435 }
436
437 pub fn method_name(&self) -> &'static str {
439 match *self {
440 StressorRequest::StuffSocket { .. } => "stuff_socket",
441 StressorRequest::Echo { .. } => "echo",
442 }
443 }
444}
445
446#[derive(Debug, Clone)]
447pub struct StressorControlHandle {
448 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
449}
450
451impl fidl::endpoints::ControlHandle for StressorControlHandle {
452 fn shutdown(&self) {
453 self.inner.shutdown()
454 }
455 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
456 self.inner.shutdown_with_epitaph(status)
457 }
458
459 fn is_closed(&self) -> bool {
460 self.inner.channel().is_closed()
461 }
462 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
463 self.inner.channel().on_closed()
464 }
465
466 #[cfg(target_os = "fuchsia")]
467 fn signal_peer(
468 &self,
469 clear_mask: zx::Signals,
470 set_mask: zx::Signals,
471 ) -> Result<(), zx_status::Status> {
472 use fidl::Peered;
473 self.inner.channel().signal_peer(clear_mask, set_mask)
474 }
475}
476
477impl StressorControlHandle {}
478
479#[must_use = "FIDL methods require a response to be sent"]
480#[derive(Debug)]
481pub struct StressorStuffSocketResponder {
482 control_handle: std::mem::ManuallyDrop<StressorControlHandle>,
483 tx_id: u32,
484}
485
486impl std::ops::Drop for StressorStuffSocketResponder {
490 fn drop(&mut self) {
491 self.control_handle.shutdown();
492 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
494 }
495}
496
497impl fidl::endpoints::Responder for StressorStuffSocketResponder {
498 type ControlHandle = StressorControlHandle;
499
500 fn control_handle(&self) -> &StressorControlHandle {
501 &self.control_handle
502 }
503
504 fn drop_without_shutdown(mut self) {
505 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
507 std::mem::forget(self);
509 }
510}
511
512impl StressorStuffSocketResponder {
513 pub fn send(self, mut bytes_written: u32) -> Result<(), fidl::Error> {
517 let _result = self.send_raw(bytes_written);
518 if _result.is_err() {
519 self.control_handle.shutdown();
520 }
521 self.drop_without_shutdown();
522 _result
523 }
524
525 pub fn send_no_shutdown_on_err(self, mut bytes_written: u32) -> Result<(), fidl::Error> {
527 let _result = self.send_raw(bytes_written);
528 self.drop_without_shutdown();
529 _result
530 }
531
532 fn send_raw(&self, mut bytes_written: u32) -> Result<(), fidl::Error> {
533 self.control_handle.inner.send::<StressorStuffSocketResponse>(
534 (bytes_written,),
535 self.tx_id,
536 0x3270057179f1ae49,
537 fidl::encoding::DynamicFlags::empty(),
538 )
539 }
540}
541
542#[must_use = "FIDL methods require a response to be sent"]
543#[derive(Debug)]
544pub struct StressorEchoResponder {
545 control_handle: std::mem::ManuallyDrop<StressorControlHandle>,
546 tx_id: u32,
547}
548
549impl std::ops::Drop for StressorEchoResponder {
553 fn drop(&mut self) {
554 self.control_handle.shutdown();
555 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
557 }
558}
559
560impl fidl::endpoints::Responder for StressorEchoResponder {
561 type ControlHandle = StressorControlHandle;
562
563 fn control_handle(&self) -> &StressorControlHandle {
564 &self.control_handle
565 }
566
567 fn drop_without_shutdown(mut self) {
568 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
570 std::mem::forget(self);
572 }
573}
574
575impl StressorEchoResponder {
576 pub fn send(self, mut content: &str) -> Result<(), fidl::Error> {
580 let _result = self.send_raw(content);
581 if _result.is_err() {
582 self.control_handle.shutdown();
583 }
584 self.drop_without_shutdown();
585 _result
586 }
587
588 pub fn send_no_shutdown_on_err(self, mut content: &str) -> Result<(), fidl::Error> {
590 let _result = self.send_raw(content);
591 self.drop_without_shutdown();
592 _result
593 }
594
595 fn send_raw(&self, mut content: &str) -> Result<(), fidl::Error> {
596 self.control_handle.inner.send::<StressorEchoResponse>(
597 (content,),
598 self.tx_id,
599 0x4463eecf18ad1bd1,
600 fidl::encoding::DynamicFlags::empty(),
601 )
602 }
603}
604
605mod internal {
606 use super::*;
607
608 impl fidl::encoding::ResourceTypeMarker for StressorStuffSocketRequest {
609 type Borrowed<'a> = &'a mut Self;
610 fn take_or_borrow<'a>(
611 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
612 ) -> Self::Borrowed<'a> {
613 value
614 }
615 }
616
617 unsafe impl fidl::encoding::TypeMarker for StressorStuffSocketRequest {
618 type Owned = Self;
619
620 #[inline(always)]
621 fn inline_align(_context: fidl::encoding::Context) -> usize {
622 4
623 }
624
625 #[inline(always)]
626 fn inline_size(_context: fidl::encoding::Context) -> usize {
627 4
628 }
629 }
630
631 unsafe impl
632 fidl::encoding::Encode<
633 StressorStuffSocketRequest,
634 fidl::encoding::DefaultFuchsiaResourceDialect,
635 > for &mut StressorStuffSocketRequest
636 {
637 #[inline]
638 unsafe fn encode(
639 self,
640 encoder: &mut fidl::encoding::Encoder<
641 '_,
642 fidl::encoding::DefaultFuchsiaResourceDialect,
643 >,
644 offset: usize,
645 _depth: fidl::encoding::Depth,
646 ) -> fidl::Result<()> {
647 encoder.debug_check_bounds::<StressorStuffSocketRequest>(offset);
648 fidl::encoding::Encode::<
650 StressorStuffSocketRequest,
651 fidl::encoding::DefaultFuchsiaResourceDialect,
652 >::encode(
653 (<fidl::encoding::HandleType<
654 fidl::Socket,
655 { fidl::ObjectType::SOCKET.into_raw() },
656 2147483648,
657 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
658 &mut self.socket
659 ),),
660 encoder,
661 offset,
662 _depth,
663 )
664 }
665 }
666 unsafe impl<
667 T0: fidl::encoding::Encode<
668 fidl::encoding::HandleType<
669 fidl::Socket,
670 { fidl::ObjectType::SOCKET.into_raw() },
671 2147483648,
672 >,
673 fidl::encoding::DefaultFuchsiaResourceDialect,
674 >,
675 >
676 fidl::encoding::Encode<
677 StressorStuffSocketRequest,
678 fidl::encoding::DefaultFuchsiaResourceDialect,
679 > for (T0,)
680 {
681 #[inline]
682 unsafe fn encode(
683 self,
684 encoder: &mut fidl::encoding::Encoder<
685 '_,
686 fidl::encoding::DefaultFuchsiaResourceDialect,
687 >,
688 offset: usize,
689 depth: fidl::encoding::Depth,
690 ) -> fidl::Result<()> {
691 encoder.debug_check_bounds::<StressorStuffSocketRequest>(offset);
692 self.0.encode(encoder, offset + 0, depth)?;
696 Ok(())
697 }
698 }
699
700 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
701 for StressorStuffSocketRequest
702 {
703 #[inline(always)]
704 fn new_empty() -> Self {
705 Self {
706 socket: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
707 }
708 }
709
710 #[inline]
711 unsafe fn decode(
712 &mut self,
713 decoder: &mut fidl::encoding::Decoder<
714 '_,
715 fidl::encoding::DefaultFuchsiaResourceDialect,
716 >,
717 offset: usize,
718 _depth: fidl::encoding::Depth,
719 ) -> fidl::Result<()> {
720 decoder.debug_check_bounds::<Self>(offset);
721 fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.socket, decoder, offset + 0, _depth)?;
723 Ok(())
724 }
725 }
726}