pub enum Error {
Send {
identity: Identity,
details: String,
},
Receive {
identity: Identity,
details: String,
},
Timeout {
identity: Identity,
timeout: Duration,
operation: String,
},
Downcast {
identity: Identity,
expected_type: String,
},
Runtime {
identity: Identity,
details: String,
},
MailboxCapacity {
message: String,
},
Join {
identity: Identity,
source: JoinError,
},
}Expand description
Variants§
Send
Error when sending a message to an actor
Fields
Receive
Error when receiving a response from an actor
Fields
Timeout
Error when a request times out
Fields
Downcast
Error when downcasting a reply to the expected type
Fields
Runtime
Error when a runtime operation fails
Fields
MailboxCapacity
Error related to mailbox capacity configuration
Join
Error when awaiting a JoinHandle fails
Implementations§
Source§impl Error
impl Error
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Returns whether this error might succeed if retried.
§⚠️ Important Caveat
This method checks the error type only and does not account for elapsed time.
If you store an error instance and check is_retryable() later, it will still
return true for Timeout errors even if significant time has passed.
Best Practice: Always use fresh error instances for retry decisions. Do not cache error instances for later retry logic.
§Retryable Errors
| Error Type | Retryable | Reason |
|---|---|---|
Timeout | ✓ Yes | Transient; may succeed with longer timeout |
Send | ✗ No | Actor stopped; channel permanently closed |
Receive | ✗ No | Reply channel dropped; cannot recover |
Downcast | ✗ No | Type mismatch; programming error |
Runtime | ✗ No | Actor lifecycle failure |
MailboxCapacity | ✗ No | Configuration error |
Join | ✗ No | Task panic or cancellation |
§Example
use rsactor::{ActorRef, Actor, Error, Message};
use std::time::Duration;
async fn send_with_retry<T, M>(
actor: &ActorRef<T>,
msg: M,
max_attempts: usize,
) -> Result<(), Error>
where
T: Actor + Message<M>,
M: Clone + Send + 'static,
{
let mut attempts = 0;
loop {
// Always get a fresh error from the current attempt
match actor.tell(msg.clone()).await {
Ok(()) => return Ok(()),
Err(e) if e.is_retryable() && attempts < max_attempts => {
attempts += 1;
tokio::time::sleep(Duration::from_millis(100 * attempts as u64)).await;
}
Err(e) => return Err(e),
}
}
}Sourcepub fn debugging_tips(&self) -> &'static [&'static str]
pub fn debugging_tips(&self) -> &'static [&'static str]
Trait Implementations§
Source§impl Display for Error
Implementation of the Display trait for Error enum.
impl Display for Error
Implementation of the Display trait for Error enum.
Provides human-readable error messages for each error variant.
Source§impl Error for Error
Implementation of the standard Error trait for rsactor Error enum.
impl Error for Error
Implementation of the standard Error trait for rsactor Error enum.
This allows Error to be used with standard error handling mechanisms.