stress_test/
actor.rs

1// Copyright 2021 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5pub use crate::actor_runner::ActorRunner;
6
7use async_trait::async_trait;
8
9pub enum ActorError {
10    /// The operation did not occur due to the current state of the instance.
11    /// The global operation count should not be incremented.
12    ///
13    /// For example, an actor that tries to delete files from a filesystem may return DoNotCount
14    /// if there are no files to delete.
15    DoNotCount,
16
17    /// The operation did not occur because the actor requires the environment to be reset.
18    /// The global operation count should not be incremented.
19    ///
20    /// For example, if an actor's connection to a filesystem is severed, they may return
21    /// ResetEnvironment to establish a new connection.
22    ResetEnvironment,
23}
24#[async_trait]
25pub trait Actor: Sync + Send + 'static {
26    // ActorRunner invokes this function, instructing the actor
27    // to perform exactly one operation and return result.
28    async fn perform(&mut self) -> Result<(), ActorError>;
29}