pub trait AsyncServiceExt: AsyncService {
const MAX_FPS: u32 = 60u32;
const FRAME_TIME_NS: u64 = _;
// Provided methods
fn on_startup<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_messages: &'life1 mut Messages,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: Send + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn on_tick<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_messages: &'life1 mut Messages,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: Send + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn on_event<'life0, 'life1, 'async_trait>(
&'life0 mut self,
messages: &'life1 mut Messages,
event: ClientEvent,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: Send + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn on_exit<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_messages: &'life1 mut Messages,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: Send + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn main<'async_trait>(
self,
messages: Messages,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: Sized + Send + 'async_trait { ... }
}
Expand description
A trait extension for AsyncService
that provides additional default functionality:
- default
main
event loop implementation, which handles client events and callstick
andhandle_event
methods. events
method to access the event receiver.tick
method to perform periodic tasks.handle_event
method to handle client events.
Provided Associated Constants§
Provided Methods§
Sourcefn on_startup<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_messages: &'life1 mut Messages,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_startup<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_messages: &'life1 mut Messages,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Startup function for the service.
This is called when the service is started and can be used to perform any necessary initialization.
Sourcefn on_tick<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_messages: &'life1 mut Messages,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_tick<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_messages: &'life1 mut Messages,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Handle periodic tasks in the service.
This is called each iteration in the default main
implementation event loop to perform any necessary updates.
Sourcefn on_event<'life0, 'life1, 'async_trait>(
&'life0 mut self,
messages: &'life1 mut Messages,
event: ClientEvent,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_event<'life0, 'life1, 'async_trait>(
&'life0 mut self,
messages: &'life1 mut Messages,
event: ClientEvent,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Handle client events in the service.
This is called for each ClientEvent
received in the default main
implementation event loop.
Sourcefn on_exit<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_messages: &'life1 mut Messages,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_exit<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_messages: &'life1 mut Messages,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Graceful exit of the service.
This is called when the service receives a StatusUpdate
event with Exit
status.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.