Trait dogehouse_rs::EventHandler [−][src]
pub trait EventHandler { #[must_use] fn on_message<'life0, 'async_trait>(
&'life0 self,
_msg: String
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait; #[must_use] fn on_pong<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait; #[must_use] fn connection_closed<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait; #[must_use] fn on_ready<'life0, 'life1, 'async_trait>(
&'life0 self,
_user: &'life1 User
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait; }
In order to use EvenHandler you must first define a struct and then implement EvenHandler for that struct.
Then you must pass that struct as an argument to add_event_handler which is defined on Client.
#[async_trait] impl EventHandler for Handler { async fn on_message(&self, msg: String) { println!("{}", msg); } async fn on_pong(&self) { println!("Received ping") } async fn connection_closed(&self) { println!("Connection has closed"); std::process::exit(1); } async fn on_ready(&self, user: &User) { println!("{} is ready", user.display_name); } }
Required methods
#[must_use]fn on_message<'life0, 'async_trait>(
&'life0 self,
_msg: String
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
[src]
#[must_use]
fn on_message<'life0, 'async_trait>(&'life0 self,
_msg: String
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
#[must_use]fn on_pong<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
[src]
#[must_use]
fn on_pong<'life0, 'async_trait>(&'life0 self
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
#[must_use]fn connection_closed<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
[src]
#[must_use]
fn connection_closed<'life0, 'async_trait>(&'life0 self
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
#[must_use]fn on_ready<'life0, 'life1, 'async_trait>(
&'life0 self,
_user: &'life1 User
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
[src]
#[must_use]
fn on_ready<'life0, 'life1, 'async_trait>(&'life0 self,
_user: &'life1 User
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,