pub trait RaceHandler<S: Send + Sync + ?Sized + 'static>: Send + Sized + 'static {
Show 15 methods fn new<'life0, 'async_trait>(
        ctx: &'life0 RaceContext,
        state: Arc<S>
    ) -> Pin<Box<dyn Future<Output = Result<Self, Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
; fn should_handle(race_data: &RaceData) -> Result<bool, Error> { ... } fn command<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 mut self,
        _ctx: &'life1 RaceContext,
        _cmd_name: String,
        _args: Vec<String>,
        _is_moderator: bool,
        _is_monitor: bool,
        _msg: &'life2 ChatMessage
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        'life2: 'async_trait,
        Self: 'async_trait
, { ... } fn should_stop<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        ctx: &'life1 RaceContext
    ) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
, { ... } fn end<'life0, 'async_trait>(
        self,
        _ctx: &'life0 RaceContext
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
, { ... } fn chat_history<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        _ctx: &'life1 RaceContext,
        _msgs: Vec<ChatMessage>
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
, { ... } fn chat_message<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        ctx: &'life1 RaceContext,
        message: ChatMessage
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
, { ... } fn chat_delete<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        _ctx: &'life1 RaceContext,
        _event: ChatDelete
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
, { ... } fn chat_purge<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        _ctx: &'life1 RaceContext,
        _event: ChatPurge
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
, { ... } fn error<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        _ctx: &'life1 RaceContext,
        errors: Vec<String>
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
, { ... } fn pong<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        _ctx: &'life1 RaceContext
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
, { ... } fn race_data<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        _ctx: &'life1 RaceContext,
        _old_race_data: RaceData
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
, { ... } fn race_renders<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        _ctx: &'life1 RaceContext
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
, { ... } fn race_split<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        _ctx: &'life1 RaceContext
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
, { ... } fn task<'async_trait>(
        _state: Arc<S>,
        _join_handle: JoinHandle<()>
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> { ... }
}
Expand description

This trait should be implemented using the [async_trait] attribute.

Required Methods§

Called when a new race room is found and should_handle has returned true.

Equivalent to:

async fn new(ctx: &RaceContext, state: Arc<T>) -> Result<Self, Error>;

The RaceHandler this returns will receive events for that race.

Provided Methods§

Called when a new race room is found. If this returns false, that race is ignored entirely.

The default implementation returns true for any race whose status value is neither finished nor cancelled.

Called for each chat message that starts with ! and was not sent by the system or a bot.

Equivalent to:

async fn command(&mut self: _ctx: &RaceContext, _cmd_name: String, _args: Vec<String>, _is_moderator: bool, _is_monitor: bool, _msg: &ChatMessage) -> Result<(), Error>;

Determine if the handler should be terminated. This is checked after every receieved message.

Equivalent to:

async fn should_stop(&mut self, ctx: &RaceContext) -> Result<bool, Error>;

The default implementation checks should_handle.

Bot actions to perform just before disconnecting from a race room.

Equivalent to:

async fn end(self, _ctx: &RaceContext) -> Result<(), Error>;

The default implementation does nothing.

Called when a chat.history message is received.

Equivalent to:

async fn chat_history(&mut self, _ctx: &RaceContext: _msgs: Vec<ChatMessage>) -> Result<(), Error>;

The default implementation does nothing.

Called when a chat.message message is received.

Equivalent to:

async fn chat_message(&mut self, ctx: &RaceContext, message: ChatMessage) -> Result<(), Error>;

The default implementation calls command if appropriate.

Called when a chat.delete message is received.

Equivalent to:

async fn chat_delete(&mut self, _ctx: &RaceContext, _event: ChatDelete) -> Result<(), Error>;

The default implementation does nothing.

Called when a chat.purge message is received.

Equivalent to:

async fn chat_purge(&mut self, _ctx: &RaceContext, _event: ChatPurge) -> Result<(), Error>;

The default implementation does nothing.

Called when an error message is received.

Equivalent to:

async fn error(&mut self, _ctx: &RaceContext, errors: Vec<String>) -> Result<(), Error>;

The default implementation returns the errors as Error::Server.

Called when a pong message is received.

Equivalent to:

async fn pong(&mut self, _ctx: &RaceContext) -> Result<(), Error>;

The default implementation does nothing.

Called when a race.data message is received.

Equivalent to:

async fn race_data(&mut self, _ctx: &RaceContext, _old_race_data: RaceData) -> Result<(), Error>;

The new race data can be found in the RaceContext parameter. The RaceData parameter contains the previous data.

The default implementation does nothing.

Called when a race.renders message is received.

Equivalent to:

async fn race_renders(&mut self, _ctx: &RaceContext) -> Result<(), Error>;

The default implementation does nothing.

Called when a race.split message is received.

Equivalent to:

async fn race_split(&mut self, _ctx: &RaceContext) -> Result<(), Error>;

The default implementation does nothing.

Called when a room handler task is created.

Equivalent to:

async fn task(_state: Arc<S>, _join_handle: tokio::task::JoinHandle<()>) -> Result<(), Error>;

The default implementation does nothing.

Implementors§