spawned_concurrency/
error.rs1#[derive(Debug, thiserror::Error)]
3pub enum ActorError {
4 #[error("Actor stopped")]
8 ActorStopped,
9 #[error("Request to Actor timed out")]
14 RequestTimeout,
15}
16
17impl<T> From<spawned_rt::threads::mpsc::SendError<T>> for ActorError {
18 fn from(_value: spawned_rt::threads::mpsc::SendError<T>) -> Self {
19 Self::ActorStopped
20 }
21}
22
23impl<T> From<spawned_rt::tasks::mpsc::SendError<T>> for ActorError {
24 fn from(_value: spawned_rt::tasks::mpsc::SendError<T>) -> Self {
25 Self::ActorStopped
26 }
27}
28
29#[cfg(test)]
30mod tests {
31 use super::*;
32
33 #[test]
34 fn test_error_into_std_error() {
35 let error: &dyn std::error::Error = &ActorError::ActorStopped;
36 assert_eq!(error.to_string(), "Actor stopped");
37 }
38}