Skip to main content

Framework

Trait Framework 

Source
pub trait Framework: Send + Sync {
    // Required method
    fn dispatch<'life0, 'async_trait>(
        &'life0 self,
        ctx: Context,
        event: FullEvent,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn init<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        client: &'life1 Client,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

A trait for defining your own framework for serenity to use.

Should you implement this trait, or define a message handler, depends on you. However, using this will benefit you by abstracting the EventHandler away.

Required Methods§

Source

fn dispatch<'life0, 'async_trait>( &'life0 self, ctx: Context, event: FullEvent, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Called on every incoming event.

Provided Methods§

Source

fn init<'life0, 'life1, 'async_trait>( &'life0 mut self, client: &'life1 Client, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Called directly after the Client is created.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<F> Framework for &mut F
where F: Framework + ?Sized,

Source§

fn init<'life0, 'life1, 'async_trait>( &'life0 mut self, client: &'life1 Client, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn dispatch<'life0, 'async_trait>( &'life0 self, ctx: Context, event: FullEvent, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

impl<F> Framework for Box<F>
where F: Framework + ?Sized,

Source§

fn init<'life0, 'life1, 'async_trait>( &'life0 mut self, client: &'life1 Client, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn dispatch<'life0, 'async_trait>( &'life0 self, ctx: Context, event: FullEvent, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Implementors§