fidl_fuchsia_stresstest/
fidl_fuchsia_stresstest.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![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_stresstest__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct ActorGetActionsResponse {
16    pub iterator: fidl::endpoints::ClientEnd<ActionIteratorMarker>,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ActorGetActionsResponse {}
20
21#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
22pub struct ActionIteratorMarker;
23
24impl fidl::endpoints::ProtocolMarker for ActionIteratorMarker {
25    type Proxy = ActionIteratorProxy;
26    type RequestStream = ActionIteratorRequestStream;
27    #[cfg(target_os = "fuchsia")]
28    type SynchronousProxy = ActionIteratorSynchronousProxy;
29
30    const DEBUG_NAME: &'static str = "(anonymous) ActionIterator";
31}
32
33pub trait ActionIteratorProxyInterface: Send + Sync {
34    type GetNextResponseFut: std::future::Future<Output = Result<Vec<Action>, fidl::Error>> + Send;
35    fn r#get_next(&self) -> Self::GetNextResponseFut;
36}
37#[derive(Debug)]
38#[cfg(target_os = "fuchsia")]
39pub struct ActionIteratorSynchronousProxy {
40    client: fidl::client::sync::Client,
41}
42
43#[cfg(target_os = "fuchsia")]
44impl fidl::endpoints::SynchronousProxy for ActionIteratorSynchronousProxy {
45    type Proxy = ActionIteratorProxy;
46    type Protocol = ActionIteratorMarker;
47
48    fn from_channel(inner: fidl::Channel) -> Self {
49        Self::new(inner)
50    }
51
52    fn into_channel(self) -> fidl::Channel {
53        self.client.into_channel()
54    }
55
56    fn as_channel(&self) -> &fidl::Channel {
57        self.client.as_channel()
58    }
59}
60
61#[cfg(target_os = "fuchsia")]
62impl ActionIteratorSynchronousProxy {
63    pub fn new(channel: fidl::Channel) -> Self {
64        let protocol_name = <ActionIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
65        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
66    }
67
68    pub fn into_channel(self) -> fidl::Channel {
69        self.client.into_channel()
70    }
71
72    /// Waits until an event arrives and returns it. It is safe for other
73    /// threads to make concurrent requests while waiting for an event.
74    pub fn wait_for_event(
75        &self,
76        deadline: zx::MonotonicInstant,
77    ) -> Result<ActionIteratorEvent, fidl::Error> {
78        ActionIteratorEvent::decode(self.client.wait_for_event(deadline)?)
79    }
80
81    /// Returns the next batch of actions. When all actions have been read, an empty
82    /// vector will be returned.
83    pub fn r#get_next(
84        &self,
85        ___deadline: zx::MonotonicInstant,
86    ) -> Result<Vec<Action>, fidl::Error> {
87        let _response =
88            self.client.send_query::<fidl::encoding::EmptyPayload, ActionIteratorGetNextResponse>(
89                (),
90                0x3a6cfa20518e766a,
91                fidl::encoding::DynamicFlags::empty(),
92                ___deadline,
93            )?;
94        Ok(_response.actions)
95    }
96}
97
98#[cfg(target_os = "fuchsia")]
99impl From<ActionIteratorSynchronousProxy> for zx::Handle {
100    fn from(value: ActionIteratorSynchronousProxy) -> Self {
101        value.into_channel().into()
102    }
103}
104
105#[cfg(target_os = "fuchsia")]
106impl From<fidl::Channel> for ActionIteratorSynchronousProxy {
107    fn from(value: fidl::Channel) -> Self {
108        Self::new(value)
109    }
110}
111
112#[cfg(target_os = "fuchsia")]
113impl fidl::endpoints::FromClient for ActionIteratorSynchronousProxy {
114    type Protocol = ActionIteratorMarker;
115
116    fn from_client(value: fidl::endpoints::ClientEnd<ActionIteratorMarker>) -> Self {
117        Self::new(value.into_channel())
118    }
119}
120
121#[derive(Debug, Clone)]
122pub struct ActionIteratorProxy {
123    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
124}
125
126impl fidl::endpoints::Proxy for ActionIteratorProxy {
127    type Protocol = ActionIteratorMarker;
128
129    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
130        Self::new(inner)
131    }
132
133    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
134        self.client.into_channel().map_err(|client| Self { client })
135    }
136
137    fn as_channel(&self) -> &::fidl::AsyncChannel {
138        self.client.as_channel()
139    }
140}
141
142impl ActionIteratorProxy {
143    /// Create a new Proxy for fuchsia.stresstest/ActionIterator.
144    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
145        let protocol_name = <ActionIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
146        Self { client: fidl::client::Client::new(channel, protocol_name) }
147    }
148
149    /// Get a Stream of events from the remote end of the protocol.
150    ///
151    /// # Panics
152    ///
153    /// Panics if the event stream was already taken.
154    pub fn take_event_stream(&self) -> ActionIteratorEventStream {
155        ActionIteratorEventStream { event_receiver: self.client.take_event_receiver() }
156    }
157
158    /// Returns the next batch of actions. When all actions have been read, an empty
159    /// vector will be returned.
160    pub fn r#get_next(
161        &self,
162    ) -> fidl::client::QueryResponseFut<Vec<Action>, fidl::encoding::DefaultFuchsiaResourceDialect>
163    {
164        ActionIteratorProxyInterface::r#get_next(self)
165    }
166}
167
168impl ActionIteratorProxyInterface for ActionIteratorProxy {
169    type GetNextResponseFut =
170        fidl::client::QueryResponseFut<Vec<Action>, fidl::encoding::DefaultFuchsiaResourceDialect>;
171    fn r#get_next(&self) -> Self::GetNextResponseFut {
172        fn _decode(
173            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
174        ) -> Result<Vec<Action>, fidl::Error> {
175            let _response = fidl::client::decode_transaction_body::<
176                ActionIteratorGetNextResponse,
177                fidl::encoding::DefaultFuchsiaResourceDialect,
178                0x3a6cfa20518e766a,
179            >(_buf?)?;
180            Ok(_response.actions)
181        }
182        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<Action>>(
183            (),
184            0x3a6cfa20518e766a,
185            fidl::encoding::DynamicFlags::empty(),
186            _decode,
187        )
188    }
189}
190
191pub struct ActionIteratorEventStream {
192    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
193}
194
195impl std::marker::Unpin for ActionIteratorEventStream {}
196
197impl futures::stream::FusedStream for ActionIteratorEventStream {
198    fn is_terminated(&self) -> bool {
199        self.event_receiver.is_terminated()
200    }
201}
202
203impl futures::Stream for ActionIteratorEventStream {
204    type Item = Result<ActionIteratorEvent, fidl::Error>;
205
206    fn poll_next(
207        mut self: std::pin::Pin<&mut Self>,
208        cx: &mut std::task::Context<'_>,
209    ) -> std::task::Poll<Option<Self::Item>> {
210        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
211            &mut self.event_receiver,
212            cx
213        )?) {
214            Some(buf) => std::task::Poll::Ready(Some(ActionIteratorEvent::decode(buf))),
215            None => std::task::Poll::Ready(None),
216        }
217    }
218}
219
220#[derive(Debug)]
221pub enum ActionIteratorEvent {}
222
223impl ActionIteratorEvent {
224    /// Decodes a message buffer as a [`ActionIteratorEvent`].
225    fn decode(
226        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
227    ) -> Result<ActionIteratorEvent, fidl::Error> {
228        let (bytes, _handles) = buf.split_mut();
229        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
230        debug_assert_eq!(tx_header.tx_id, 0);
231        match tx_header.ordinal {
232            _ => Err(fidl::Error::UnknownOrdinal {
233                ordinal: tx_header.ordinal,
234                protocol_name:
235                    <ActionIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
236            }),
237        }
238    }
239}
240
241/// A Stream of incoming requests for fuchsia.stresstest/ActionIterator.
242pub struct ActionIteratorRequestStream {
243    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
244    is_terminated: bool,
245}
246
247impl std::marker::Unpin for ActionIteratorRequestStream {}
248
249impl futures::stream::FusedStream for ActionIteratorRequestStream {
250    fn is_terminated(&self) -> bool {
251        self.is_terminated
252    }
253}
254
255impl fidl::endpoints::RequestStream for ActionIteratorRequestStream {
256    type Protocol = ActionIteratorMarker;
257    type ControlHandle = ActionIteratorControlHandle;
258
259    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
260        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
261    }
262
263    fn control_handle(&self) -> Self::ControlHandle {
264        ActionIteratorControlHandle { inner: self.inner.clone() }
265    }
266
267    fn into_inner(
268        self,
269    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
270    {
271        (self.inner, self.is_terminated)
272    }
273
274    fn from_inner(
275        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
276        is_terminated: bool,
277    ) -> Self {
278        Self { inner, is_terminated }
279    }
280}
281
282impl futures::Stream for ActionIteratorRequestStream {
283    type Item = Result<ActionIteratorRequest, fidl::Error>;
284
285    fn poll_next(
286        mut self: std::pin::Pin<&mut Self>,
287        cx: &mut std::task::Context<'_>,
288    ) -> std::task::Poll<Option<Self::Item>> {
289        let this = &mut *self;
290        if this.inner.check_shutdown(cx) {
291            this.is_terminated = true;
292            return std::task::Poll::Ready(None);
293        }
294        if this.is_terminated {
295            panic!("polled ActionIteratorRequestStream after completion");
296        }
297        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
298            |bytes, handles| {
299                match this.inner.channel().read_etc(cx, bytes, handles) {
300                    std::task::Poll::Ready(Ok(())) => {}
301                    std::task::Poll::Pending => return std::task::Poll::Pending,
302                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
303                        this.is_terminated = true;
304                        return std::task::Poll::Ready(None);
305                    }
306                    std::task::Poll::Ready(Err(e)) => {
307                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
308                            e.into(),
309                        ))))
310                    }
311                }
312
313                // A message has been received from the channel
314                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
315
316                std::task::Poll::Ready(Some(match header.ordinal {
317                    0x3a6cfa20518e766a => {
318                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
319                        let mut req = fidl::new_empty!(
320                            fidl::encoding::EmptyPayload,
321                            fidl::encoding::DefaultFuchsiaResourceDialect
322                        );
323                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
324                        let control_handle =
325                            ActionIteratorControlHandle { inner: this.inner.clone() };
326                        Ok(ActionIteratorRequest::GetNext {
327                            responder: ActionIteratorGetNextResponder {
328                                control_handle: std::mem::ManuallyDrop::new(control_handle),
329                                tx_id: header.tx_id,
330                            },
331                        })
332                    }
333                    _ => Err(fidl::Error::UnknownOrdinal {
334                        ordinal: header.ordinal,
335                        protocol_name:
336                            <ActionIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
337                    }),
338                }))
339            },
340        )
341    }
342}
343
344/// Iterator for listing available actions.
345#[derive(Debug)]
346pub enum ActionIteratorRequest {
347    /// Returns the next batch of actions. When all actions have been read, an empty
348    /// vector will be returned.
349    GetNext { responder: ActionIteratorGetNextResponder },
350}
351
352impl ActionIteratorRequest {
353    #[allow(irrefutable_let_patterns)]
354    pub fn into_get_next(self) -> Option<(ActionIteratorGetNextResponder)> {
355        if let ActionIteratorRequest::GetNext { responder } = self {
356            Some((responder))
357        } else {
358            None
359        }
360    }
361
362    /// Name of the method defined in FIDL
363    pub fn method_name(&self) -> &'static str {
364        match *self {
365            ActionIteratorRequest::GetNext { .. } => "get_next",
366        }
367    }
368}
369
370#[derive(Debug, Clone)]
371pub struct ActionIteratorControlHandle {
372    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
373}
374
375impl fidl::endpoints::ControlHandle for ActionIteratorControlHandle {
376    fn shutdown(&self) {
377        self.inner.shutdown()
378    }
379    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
380        self.inner.shutdown_with_epitaph(status)
381    }
382
383    fn is_closed(&self) -> bool {
384        self.inner.channel().is_closed()
385    }
386    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
387        self.inner.channel().on_closed()
388    }
389
390    #[cfg(target_os = "fuchsia")]
391    fn signal_peer(
392        &self,
393        clear_mask: zx::Signals,
394        set_mask: zx::Signals,
395    ) -> Result<(), zx_status::Status> {
396        use fidl::Peered;
397        self.inner.channel().signal_peer(clear_mask, set_mask)
398    }
399}
400
401impl ActionIteratorControlHandle {}
402
403#[must_use = "FIDL methods require a response to be sent"]
404#[derive(Debug)]
405pub struct ActionIteratorGetNextResponder {
406    control_handle: std::mem::ManuallyDrop<ActionIteratorControlHandle>,
407    tx_id: u32,
408}
409
410/// Set the the channel to be shutdown (see [`ActionIteratorControlHandle::shutdown`])
411/// if the responder is dropped without sending a response, so that the client
412/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
413impl std::ops::Drop for ActionIteratorGetNextResponder {
414    fn drop(&mut self) {
415        self.control_handle.shutdown();
416        // Safety: drops once, never accessed again
417        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
418    }
419}
420
421impl fidl::endpoints::Responder for ActionIteratorGetNextResponder {
422    type ControlHandle = ActionIteratorControlHandle;
423
424    fn control_handle(&self) -> &ActionIteratorControlHandle {
425        &self.control_handle
426    }
427
428    fn drop_without_shutdown(mut self) {
429        // Safety: drops once, never accessed again due to mem::forget
430        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
431        // Prevent Drop from running (which would shut down the channel)
432        std::mem::forget(self);
433    }
434}
435
436impl ActionIteratorGetNextResponder {
437    /// Sends a response to the FIDL transaction.
438    ///
439    /// Sets the channel to shutdown if an error occurs.
440    pub fn send(self, mut actions: &[Action]) -> Result<(), fidl::Error> {
441        let _result = self.send_raw(actions);
442        if _result.is_err() {
443            self.control_handle.shutdown();
444        }
445        self.drop_without_shutdown();
446        _result
447    }
448
449    /// Similar to "send" but does not shutdown the channel if an error occurs.
450    pub fn send_no_shutdown_on_err(self, mut actions: &[Action]) -> Result<(), fidl::Error> {
451        let _result = self.send_raw(actions);
452        self.drop_without_shutdown();
453        _result
454    }
455
456    fn send_raw(&self, mut actions: &[Action]) -> Result<(), fidl::Error> {
457        self.control_handle.inner.send::<ActionIteratorGetNextResponse>(
458            (actions,),
459            self.tx_id,
460            0x3a6cfa20518e766a,
461            fidl::encoding::DynamicFlags::empty(),
462        )
463    }
464}
465
466#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
467pub struct ActorMarker;
468
469impl fidl::endpoints::ProtocolMarker for ActorMarker {
470    type Proxy = ActorProxy;
471    type RequestStream = ActorRequestStream;
472    #[cfg(target_os = "fuchsia")]
473    type SynchronousProxy = ActorSynchronousProxy;
474
475    const DEBUG_NAME: &'static str = "fuchsia.stresstest.Actor";
476}
477impl fidl::endpoints::DiscoverableProtocolMarker for ActorMarker {}
478
479pub trait ActorProxyInterface: Send + Sync {
480    type GetActionsResponseFut: std::future::Future<
481            Output = Result<fidl::endpoints::ClientEnd<ActionIteratorMarker>, fidl::Error>,
482        > + Send;
483    fn r#get_actions(&self) -> Self::GetActionsResponseFut;
484    type RunResponseFut: std::future::Future<Output = Result<Option<Box<Error>>, fidl::Error>>
485        + Send;
486    fn r#run(&self, action_name: &str, seed: u64) -> Self::RunResponseFut;
487}
488#[derive(Debug)]
489#[cfg(target_os = "fuchsia")]
490pub struct ActorSynchronousProxy {
491    client: fidl::client::sync::Client,
492}
493
494#[cfg(target_os = "fuchsia")]
495impl fidl::endpoints::SynchronousProxy for ActorSynchronousProxy {
496    type Proxy = ActorProxy;
497    type Protocol = ActorMarker;
498
499    fn from_channel(inner: fidl::Channel) -> Self {
500        Self::new(inner)
501    }
502
503    fn into_channel(self) -> fidl::Channel {
504        self.client.into_channel()
505    }
506
507    fn as_channel(&self) -> &fidl::Channel {
508        self.client.as_channel()
509    }
510}
511
512#[cfg(target_os = "fuchsia")]
513impl ActorSynchronousProxy {
514    pub fn new(channel: fidl::Channel) -> Self {
515        let protocol_name = <ActorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
516        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
517    }
518
519    pub fn into_channel(self) -> fidl::Channel {
520        self.client.into_channel()
521    }
522
523    /// Waits until an event arrives and returns it. It is safe for other
524    /// threads to make concurrent requests while waiting for an event.
525    pub fn wait_for_event(
526        &self,
527        deadline: zx::MonotonicInstant,
528    ) -> Result<ActorEvent, fidl::Error> {
529        ActorEvent::decode(self.client.wait_for_event(deadline)?)
530    }
531
532    /// Enumerate the actions available in this actor.
533    pub fn r#get_actions(
534        &self,
535        ___deadline: zx::MonotonicInstant,
536    ) -> Result<fidl::endpoints::ClientEnd<ActionIteratorMarker>, fidl::Error> {
537        let _response =
538            self.client.send_query::<fidl::encoding::EmptyPayload, ActorGetActionsResponse>(
539                (),
540                0x21b890f66d9d9cff,
541                fidl::encoding::DynamicFlags::empty(),
542                ___deadline,
543            )?;
544        Ok(_response.iterator)
545    }
546
547    /// Runs a single action with a given seed. Returns when the action has completed.
548    /// If the action failed, the corresponding error message is returned.
549    pub fn r#run(
550        &self,
551        mut action_name: &str,
552        mut seed: u64,
553        ___deadline: zx::MonotonicInstant,
554    ) -> Result<Option<Box<Error>>, fidl::Error> {
555        let _response = self.client.send_query::<ActorRunRequest, ActorRunResponse>(
556            (action_name, seed),
557            0x28a8ff83256eef02,
558            fidl::encoding::DynamicFlags::empty(),
559            ___deadline,
560        )?;
561        Ok(_response.error)
562    }
563}
564
565#[cfg(target_os = "fuchsia")]
566impl From<ActorSynchronousProxy> for zx::Handle {
567    fn from(value: ActorSynchronousProxy) -> Self {
568        value.into_channel().into()
569    }
570}
571
572#[cfg(target_os = "fuchsia")]
573impl From<fidl::Channel> for ActorSynchronousProxy {
574    fn from(value: fidl::Channel) -> Self {
575        Self::new(value)
576    }
577}
578
579#[cfg(target_os = "fuchsia")]
580impl fidl::endpoints::FromClient for ActorSynchronousProxy {
581    type Protocol = ActorMarker;
582
583    fn from_client(value: fidl::endpoints::ClientEnd<ActorMarker>) -> Self {
584        Self::new(value.into_channel())
585    }
586}
587
588#[derive(Debug, Clone)]
589pub struct ActorProxy {
590    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
591}
592
593impl fidl::endpoints::Proxy for ActorProxy {
594    type Protocol = ActorMarker;
595
596    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
597        Self::new(inner)
598    }
599
600    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
601        self.client.into_channel().map_err(|client| Self { client })
602    }
603
604    fn as_channel(&self) -> &::fidl::AsyncChannel {
605        self.client.as_channel()
606    }
607}
608
609impl ActorProxy {
610    /// Create a new Proxy for fuchsia.stresstest/Actor.
611    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
612        let protocol_name = <ActorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
613        Self { client: fidl::client::Client::new(channel, protocol_name) }
614    }
615
616    /// Get a Stream of events from the remote end of the protocol.
617    ///
618    /// # Panics
619    ///
620    /// Panics if the event stream was already taken.
621    pub fn take_event_stream(&self) -> ActorEventStream {
622        ActorEventStream { event_receiver: self.client.take_event_receiver() }
623    }
624
625    /// Enumerate the actions available in this actor.
626    pub fn r#get_actions(
627        &self,
628    ) -> fidl::client::QueryResponseFut<
629        fidl::endpoints::ClientEnd<ActionIteratorMarker>,
630        fidl::encoding::DefaultFuchsiaResourceDialect,
631    > {
632        ActorProxyInterface::r#get_actions(self)
633    }
634
635    /// Runs a single action with a given seed. Returns when the action has completed.
636    /// If the action failed, the corresponding error message is returned.
637    pub fn r#run(
638        &self,
639        mut action_name: &str,
640        mut seed: u64,
641    ) -> fidl::client::QueryResponseFut<
642        Option<Box<Error>>,
643        fidl::encoding::DefaultFuchsiaResourceDialect,
644    > {
645        ActorProxyInterface::r#run(self, action_name, seed)
646    }
647}
648
649impl ActorProxyInterface for ActorProxy {
650    type GetActionsResponseFut = fidl::client::QueryResponseFut<
651        fidl::endpoints::ClientEnd<ActionIteratorMarker>,
652        fidl::encoding::DefaultFuchsiaResourceDialect,
653    >;
654    fn r#get_actions(&self) -> Self::GetActionsResponseFut {
655        fn _decode(
656            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
657        ) -> Result<fidl::endpoints::ClientEnd<ActionIteratorMarker>, fidl::Error> {
658            let _response = fidl::client::decode_transaction_body::<
659                ActorGetActionsResponse,
660                fidl::encoding::DefaultFuchsiaResourceDialect,
661                0x21b890f66d9d9cff,
662            >(_buf?)?;
663            Ok(_response.iterator)
664        }
665        self.client.send_query_and_decode::<
666            fidl::encoding::EmptyPayload,
667            fidl::endpoints::ClientEnd<ActionIteratorMarker>,
668        >(
669            (),
670            0x21b890f66d9d9cff,
671            fidl::encoding::DynamicFlags::empty(),
672            _decode,
673        )
674    }
675
676    type RunResponseFut = fidl::client::QueryResponseFut<
677        Option<Box<Error>>,
678        fidl::encoding::DefaultFuchsiaResourceDialect,
679    >;
680    fn r#run(&self, mut action_name: &str, mut seed: u64) -> Self::RunResponseFut {
681        fn _decode(
682            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
683        ) -> Result<Option<Box<Error>>, fidl::Error> {
684            let _response = fidl::client::decode_transaction_body::<
685                ActorRunResponse,
686                fidl::encoding::DefaultFuchsiaResourceDialect,
687                0x28a8ff83256eef02,
688            >(_buf?)?;
689            Ok(_response.error)
690        }
691        self.client.send_query_and_decode::<ActorRunRequest, Option<Box<Error>>>(
692            (action_name, seed),
693            0x28a8ff83256eef02,
694            fidl::encoding::DynamicFlags::empty(),
695            _decode,
696        )
697    }
698}
699
700pub struct ActorEventStream {
701    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
702}
703
704impl std::marker::Unpin for ActorEventStream {}
705
706impl futures::stream::FusedStream for ActorEventStream {
707    fn is_terminated(&self) -> bool {
708        self.event_receiver.is_terminated()
709    }
710}
711
712impl futures::Stream for ActorEventStream {
713    type Item = Result<ActorEvent, fidl::Error>;
714
715    fn poll_next(
716        mut self: std::pin::Pin<&mut Self>,
717        cx: &mut std::task::Context<'_>,
718    ) -> std::task::Poll<Option<Self::Item>> {
719        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
720            &mut self.event_receiver,
721            cx
722        )?) {
723            Some(buf) => std::task::Poll::Ready(Some(ActorEvent::decode(buf))),
724            None => std::task::Poll::Ready(None),
725        }
726    }
727}
728
729#[derive(Debug)]
730pub enum ActorEvent {}
731
732impl ActorEvent {
733    /// Decodes a message buffer as a [`ActorEvent`].
734    fn decode(
735        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
736    ) -> Result<ActorEvent, fidl::Error> {
737        let (bytes, _handles) = buf.split_mut();
738        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
739        debug_assert_eq!(tx_header.tx_id, 0);
740        match tx_header.ordinal {
741            _ => Err(fidl::Error::UnknownOrdinal {
742                ordinal: tx_header.ordinal,
743                protocol_name: <ActorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
744            }),
745        }
746    }
747}
748
749/// A Stream of incoming requests for fuchsia.stresstest/Actor.
750pub struct ActorRequestStream {
751    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
752    is_terminated: bool,
753}
754
755impl std::marker::Unpin for ActorRequestStream {}
756
757impl futures::stream::FusedStream for ActorRequestStream {
758    fn is_terminated(&self) -> bool {
759        self.is_terminated
760    }
761}
762
763impl fidl::endpoints::RequestStream for ActorRequestStream {
764    type Protocol = ActorMarker;
765    type ControlHandle = ActorControlHandle;
766
767    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
768        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
769    }
770
771    fn control_handle(&self) -> Self::ControlHandle {
772        ActorControlHandle { inner: self.inner.clone() }
773    }
774
775    fn into_inner(
776        self,
777    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
778    {
779        (self.inner, self.is_terminated)
780    }
781
782    fn from_inner(
783        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
784        is_terminated: bool,
785    ) -> Self {
786        Self { inner, is_terminated }
787    }
788}
789
790impl futures::Stream for ActorRequestStream {
791    type Item = Result<ActorRequest, fidl::Error>;
792
793    fn poll_next(
794        mut self: std::pin::Pin<&mut Self>,
795        cx: &mut std::task::Context<'_>,
796    ) -> std::task::Poll<Option<Self::Item>> {
797        let this = &mut *self;
798        if this.inner.check_shutdown(cx) {
799            this.is_terminated = true;
800            return std::task::Poll::Ready(None);
801        }
802        if this.is_terminated {
803            panic!("polled ActorRequestStream after completion");
804        }
805        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
806            |bytes, handles| {
807                match this.inner.channel().read_etc(cx, bytes, handles) {
808                    std::task::Poll::Ready(Ok(())) => {}
809                    std::task::Poll::Pending => return std::task::Poll::Pending,
810                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
811                        this.is_terminated = true;
812                        return std::task::Poll::Ready(None);
813                    }
814                    std::task::Poll::Ready(Err(e)) => {
815                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
816                            e.into(),
817                        ))))
818                    }
819                }
820
821                // A message has been received from the channel
822                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
823
824                std::task::Poll::Ready(Some(match header.ordinal {
825                    0x21b890f66d9d9cff => {
826                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
827                        let mut req = fidl::new_empty!(
828                            fidl::encoding::EmptyPayload,
829                            fidl::encoding::DefaultFuchsiaResourceDialect
830                        );
831                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
832                        let control_handle = ActorControlHandle { inner: this.inner.clone() };
833                        Ok(ActorRequest::GetActions {
834                            responder: ActorGetActionsResponder {
835                                control_handle: std::mem::ManuallyDrop::new(control_handle),
836                                tx_id: header.tx_id,
837                            },
838                        })
839                    }
840                    0x28a8ff83256eef02 => {
841                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
842                        let mut req = fidl::new_empty!(
843                            ActorRunRequest,
844                            fidl::encoding::DefaultFuchsiaResourceDialect
845                        );
846                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ActorRunRequest>(&header, _body_bytes, handles, &mut req)?;
847                        let control_handle = ActorControlHandle { inner: this.inner.clone() };
848                        Ok(ActorRequest::Run {
849                            action_name: req.action_name,
850                            seed: req.seed,
851
852                            responder: ActorRunResponder {
853                                control_handle: std::mem::ManuallyDrop::new(control_handle),
854                                tx_id: header.tx_id,
855                            },
856                        })
857                    }
858                    _ => Err(fidl::Error::UnknownOrdinal {
859                        ordinal: header.ordinal,
860                        protocol_name: <ActorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
861                    }),
862                }))
863            },
864        )
865    }
866}
867
868/// This protocol is implemented by an actor and exposes ways to query and
869/// run actions. Actors expect exactly one connection to the Actor protocol from
870/// the test runner during the actor's lifetime.
871#[derive(Debug)]
872pub enum ActorRequest {
873    /// Enumerate the actions available in this actor.
874    GetActions { responder: ActorGetActionsResponder },
875    /// Runs a single action with a given seed. Returns when the action has completed.
876    /// If the action failed, the corresponding error message is returned.
877    Run { action_name: String, seed: u64, responder: ActorRunResponder },
878}
879
880impl ActorRequest {
881    #[allow(irrefutable_let_patterns)]
882    pub fn into_get_actions(self) -> Option<(ActorGetActionsResponder)> {
883        if let ActorRequest::GetActions { responder } = self {
884            Some((responder))
885        } else {
886            None
887        }
888    }
889
890    #[allow(irrefutable_let_patterns)]
891    pub fn into_run(self) -> Option<(String, u64, ActorRunResponder)> {
892        if let ActorRequest::Run { action_name, seed, responder } = self {
893            Some((action_name, seed, responder))
894        } else {
895            None
896        }
897    }
898
899    /// Name of the method defined in FIDL
900    pub fn method_name(&self) -> &'static str {
901        match *self {
902            ActorRequest::GetActions { .. } => "get_actions",
903            ActorRequest::Run { .. } => "run",
904        }
905    }
906}
907
908#[derive(Debug, Clone)]
909pub struct ActorControlHandle {
910    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
911}
912
913impl fidl::endpoints::ControlHandle for ActorControlHandle {
914    fn shutdown(&self) {
915        self.inner.shutdown()
916    }
917    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
918        self.inner.shutdown_with_epitaph(status)
919    }
920
921    fn is_closed(&self) -> bool {
922        self.inner.channel().is_closed()
923    }
924    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
925        self.inner.channel().on_closed()
926    }
927
928    #[cfg(target_os = "fuchsia")]
929    fn signal_peer(
930        &self,
931        clear_mask: zx::Signals,
932        set_mask: zx::Signals,
933    ) -> Result<(), zx_status::Status> {
934        use fidl::Peered;
935        self.inner.channel().signal_peer(clear_mask, set_mask)
936    }
937}
938
939impl ActorControlHandle {}
940
941#[must_use = "FIDL methods require a response to be sent"]
942#[derive(Debug)]
943pub struct ActorGetActionsResponder {
944    control_handle: std::mem::ManuallyDrop<ActorControlHandle>,
945    tx_id: u32,
946}
947
948/// Set the the channel to be shutdown (see [`ActorControlHandle::shutdown`])
949/// if the responder is dropped without sending a response, so that the client
950/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
951impl std::ops::Drop for ActorGetActionsResponder {
952    fn drop(&mut self) {
953        self.control_handle.shutdown();
954        // Safety: drops once, never accessed again
955        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
956    }
957}
958
959impl fidl::endpoints::Responder for ActorGetActionsResponder {
960    type ControlHandle = ActorControlHandle;
961
962    fn control_handle(&self) -> &ActorControlHandle {
963        &self.control_handle
964    }
965
966    fn drop_without_shutdown(mut self) {
967        // Safety: drops once, never accessed again due to mem::forget
968        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
969        // Prevent Drop from running (which would shut down the channel)
970        std::mem::forget(self);
971    }
972}
973
974impl ActorGetActionsResponder {
975    /// Sends a response to the FIDL transaction.
976    ///
977    /// Sets the channel to shutdown if an error occurs.
978    pub fn send(
979        self,
980        mut iterator: fidl::endpoints::ClientEnd<ActionIteratorMarker>,
981    ) -> Result<(), fidl::Error> {
982        let _result = self.send_raw(iterator);
983        if _result.is_err() {
984            self.control_handle.shutdown();
985        }
986        self.drop_without_shutdown();
987        _result
988    }
989
990    /// Similar to "send" but does not shutdown the channel if an error occurs.
991    pub fn send_no_shutdown_on_err(
992        self,
993        mut iterator: fidl::endpoints::ClientEnd<ActionIteratorMarker>,
994    ) -> Result<(), fidl::Error> {
995        let _result = self.send_raw(iterator);
996        self.drop_without_shutdown();
997        _result
998    }
999
1000    fn send_raw(
1001        &self,
1002        mut iterator: fidl::endpoints::ClientEnd<ActionIteratorMarker>,
1003    ) -> Result<(), fidl::Error> {
1004        self.control_handle.inner.send::<ActorGetActionsResponse>(
1005            (iterator,),
1006            self.tx_id,
1007            0x21b890f66d9d9cff,
1008            fidl::encoding::DynamicFlags::empty(),
1009        )
1010    }
1011}
1012
1013#[must_use = "FIDL methods require a response to be sent"]
1014#[derive(Debug)]
1015pub struct ActorRunResponder {
1016    control_handle: std::mem::ManuallyDrop<ActorControlHandle>,
1017    tx_id: u32,
1018}
1019
1020/// Set the the channel to be shutdown (see [`ActorControlHandle::shutdown`])
1021/// if the responder is dropped without sending a response, so that the client
1022/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1023impl std::ops::Drop for ActorRunResponder {
1024    fn drop(&mut self) {
1025        self.control_handle.shutdown();
1026        // Safety: drops once, never accessed again
1027        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1028    }
1029}
1030
1031impl fidl::endpoints::Responder for ActorRunResponder {
1032    type ControlHandle = ActorControlHandle;
1033
1034    fn control_handle(&self) -> &ActorControlHandle {
1035        &self.control_handle
1036    }
1037
1038    fn drop_without_shutdown(mut self) {
1039        // Safety: drops once, never accessed again due to mem::forget
1040        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1041        // Prevent Drop from running (which would shut down the channel)
1042        std::mem::forget(self);
1043    }
1044}
1045
1046impl ActorRunResponder {
1047    /// Sends a response to the FIDL transaction.
1048    ///
1049    /// Sets the channel to shutdown if an error occurs.
1050    pub fn send(self, mut error: Option<&Error>) -> Result<(), fidl::Error> {
1051        let _result = self.send_raw(error);
1052        if _result.is_err() {
1053            self.control_handle.shutdown();
1054        }
1055        self.drop_without_shutdown();
1056        _result
1057    }
1058
1059    /// Similar to "send" but does not shutdown the channel if an error occurs.
1060    pub fn send_no_shutdown_on_err(self, mut error: Option<&Error>) -> Result<(), fidl::Error> {
1061        let _result = self.send_raw(error);
1062        self.drop_without_shutdown();
1063        _result
1064    }
1065
1066    fn send_raw(&self, mut error: Option<&Error>) -> Result<(), fidl::Error> {
1067        self.control_handle.inner.send::<ActorRunResponse>(
1068            (error,),
1069            self.tx_id,
1070            0x28a8ff83256eef02,
1071            fidl::encoding::DynamicFlags::empty(),
1072        )
1073    }
1074}
1075
1076mod internal {
1077    use super::*;
1078
1079    impl fidl::encoding::ResourceTypeMarker for ActorGetActionsResponse {
1080        type Borrowed<'a> = &'a mut Self;
1081        fn take_or_borrow<'a>(
1082            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1083        ) -> Self::Borrowed<'a> {
1084            value
1085        }
1086    }
1087
1088    unsafe impl fidl::encoding::TypeMarker for ActorGetActionsResponse {
1089        type Owned = Self;
1090
1091        #[inline(always)]
1092        fn inline_align(_context: fidl::encoding::Context) -> usize {
1093            4
1094        }
1095
1096        #[inline(always)]
1097        fn inline_size(_context: fidl::encoding::Context) -> usize {
1098            4
1099        }
1100    }
1101
1102    unsafe impl
1103        fidl::encoding::Encode<
1104            ActorGetActionsResponse,
1105            fidl::encoding::DefaultFuchsiaResourceDialect,
1106        > for &mut ActorGetActionsResponse
1107    {
1108        #[inline]
1109        unsafe fn encode(
1110            self,
1111            encoder: &mut fidl::encoding::Encoder<
1112                '_,
1113                fidl::encoding::DefaultFuchsiaResourceDialect,
1114            >,
1115            offset: usize,
1116            _depth: fidl::encoding::Depth,
1117        ) -> fidl::Result<()> {
1118            encoder.debug_check_bounds::<ActorGetActionsResponse>(offset);
1119            // Delegate to tuple encoding.
1120            fidl::encoding::Encode::<ActorGetActionsResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1121                (
1122                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ActionIteratorMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.iterator),
1123                ),
1124                encoder, offset, _depth
1125            )
1126        }
1127    }
1128    unsafe impl<
1129            T0: fidl::encoding::Encode<
1130                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ActionIteratorMarker>>,
1131                fidl::encoding::DefaultFuchsiaResourceDialect,
1132            >,
1133        >
1134        fidl::encoding::Encode<
1135            ActorGetActionsResponse,
1136            fidl::encoding::DefaultFuchsiaResourceDialect,
1137        > for (T0,)
1138    {
1139        #[inline]
1140        unsafe fn encode(
1141            self,
1142            encoder: &mut fidl::encoding::Encoder<
1143                '_,
1144                fidl::encoding::DefaultFuchsiaResourceDialect,
1145            >,
1146            offset: usize,
1147            depth: fidl::encoding::Depth,
1148        ) -> fidl::Result<()> {
1149            encoder.debug_check_bounds::<ActorGetActionsResponse>(offset);
1150            // Zero out padding regions. There's no need to apply masks
1151            // because the unmasked parts will be overwritten by fields.
1152            // Write the fields.
1153            self.0.encode(encoder, offset + 0, depth)?;
1154            Ok(())
1155        }
1156    }
1157
1158    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1159        for ActorGetActionsResponse
1160    {
1161        #[inline(always)]
1162        fn new_empty() -> Self {
1163            Self {
1164                iterator: fidl::new_empty!(
1165                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ActionIteratorMarker>>,
1166                    fidl::encoding::DefaultFuchsiaResourceDialect
1167                ),
1168            }
1169        }
1170
1171        #[inline]
1172        unsafe fn decode(
1173            &mut self,
1174            decoder: &mut fidl::encoding::Decoder<
1175                '_,
1176                fidl::encoding::DefaultFuchsiaResourceDialect,
1177            >,
1178            offset: usize,
1179            _depth: fidl::encoding::Depth,
1180        ) -> fidl::Result<()> {
1181            decoder.debug_check_bounds::<Self>(offset);
1182            // Verify that padding bytes are zero.
1183            fidl::decode!(
1184                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ActionIteratorMarker>>,
1185                fidl::encoding::DefaultFuchsiaResourceDialect,
1186                &mut self.iterator,
1187                decoder,
1188                offset + 0,
1189                _depth
1190            )?;
1191            Ok(())
1192        }
1193    }
1194}