pub trait ActorContext: Send {
// Required methods
fn kind(&self) -> &str;
fn key(&self) -> &str;
fn now(&self) -> OffsetDateTime;
fn get<'life0, 'life1, 'async_trait>(
&'life0 mut self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, ActorError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn put<'life0, 'life1, 'async_trait>(
&'life0 mut self,
key: &'life1 str,
value: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<(), ActorError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn delete<'life0, 'life1, 'async_trait>(
&'life0 mut self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), ActorError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn delete_all<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), ActorError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn list_prefix<'life0, 'life1, 'async_trait>(
&'life0 mut self,
prefix: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<(String, Vec<u8>)>, ActorError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn set_alarm<'life0, 'async_trait>(
&'life0 mut self,
at: OffsetDateTime,
) -> Pin<Box<dyn Future<Output = Result<(), ActorError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn alarm<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<Option<OffsetDateTime>, ActorError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn cancel_alarm<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), ActorError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
The operations an ActorHandler performs on its actor while handling a
message or an alarm. Writes are staged and committed together by the
run_actor_message / run_actor_alarm runners.
Required Methods§
Sourcefn now(&self) -> OffsetDateTime
fn now(&self) -> OffsetDateTime
Wall time, from the runtime’s Clock.
Sourcefn get<'life0, 'life1, 'async_trait>(
&'life0 mut self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, ActorError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait>(
&'life0 mut self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, ActorError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Fetches the value at key, seeing this call’s staged writes first.
Sourcefn put<'life0, 'life1, 'async_trait>(
&'life0 mut self,
key: &'life1 str,
value: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<(), ActorError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn put<'life0, 'life1, 'async_trait>(
&'life0 mut self,
key: &'life1 str,
value: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<(), ActorError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Stages a write of value at key, replacing any existing value.
Sourcefn delete<'life0, 'life1, 'async_trait>(
&'life0 mut self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), ActorError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete<'life0, 'life1, 'async_trait>(
&'life0 mut self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), ActorError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Stages a delete of key. Idempotent: deleting a missing key is Ok.
Sourcefn delete_all<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), ActorError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn delete_all<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), ActorError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Stages a delete of every key in this actor. Also drops writes staged
before it, so delete_all followed by nothing leaves the actor empty.
Sourcefn list_prefix<'life0, 'life1, 'async_trait>(
&'life0 mut self,
prefix: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<(String, Vec<u8>)>, ActorError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn list_prefix<'life0, 'life1, 'async_trait>(
&'life0 mut self,
prefix: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<(String, Vec<u8>)>, ActorError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Every (key, value) whose key starts with prefix, sorted by key,
seeing this call’s staged writes first.
Sourcefn set_alarm<'life0, 'async_trait>(
&'life0 mut self,
at: OffsetDateTime,
) -> Pin<Box<dyn Future<Output = Result<(), ActorError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn set_alarm<'life0, 'async_trait>(
&'life0 mut self,
at: OffsetDateTime,
) -> Pin<Box<dyn Future<Output = Result<(), ActorError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Sets the actor’s one alarm to fire at at, replacing any pending one.
Sourcefn alarm<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<Option<OffsetDateTime>, ActorError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn alarm<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<Option<OffsetDateTime>, ActorError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
The pending alarm, or None if none is set. Sees a staged alarm
first.
Sourcefn cancel_alarm<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), ActorError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn cancel_alarm<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), ActorError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Clears the pending alarm.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".