pub trait EntityHandler: Send + Sync {
// Required method
fn handle_request<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
tag: &'life1 str,
payload: &'life2 [u8],
headers: &'life3 HashMap<String, String>,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, ClusterError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait;
// Provided methods
fn handle_stream<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
tag: &'life1 str,
payload: &'life2 [u8],
headers: &'life3 HashMap<String, String>,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<Vec<u8>, ClusterError>> + Send>>, ClusterError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait { ... }
fn on_idle<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}Expand description
Handles incoming RPCs for a specific entity instance.
Each entity instance has one handler that processes all incoming messages.
The handler is created by Entity::spawn and lives until the entity is
reaped (idle timeout) or the runner shuts down.
Required Methods§
Sourcefn handle_request<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
tag: &'life1 str,
payload: &'life2 [u8],
headers: &'life3 HashMap<String, String>,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, ClusterError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn handle_request<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
tag: &'life1 str,
payload: &'life2 [u8],
headers: &'life3 HashMap<String, String>,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, ClusterError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Handle an incoming request. Returns serialized response bytes.
Provided Methods§
Sourcefn handle_stream<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
tag: &'life1 str,
payload: &'life2 [u8],
headers: &'life3 HashMap<String, String>,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<Vec<u8>, ClusterError>> + Send>>, ClusterError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn handle_stream<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
tag: &'life1 str,
payload: &'life2 [u8],
headers: &'life3 HashMap<String, String>,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<Vec<u8>, ClusterError>> + Send>>, ClusterError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Handle a streaming request. Returns a stream of serialized chunks.
Default implementation wraps handle_request as a single-item stream.