Handler

Trait Handler 

Source
pub trait Handler:
    Sized
    + Send
    + 'static {
    type Param: Param;

    // Required method
    fn prove<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<(Vec<u8>, Vec<u8>), Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;

    // Provided methods
    fn viewable() -> bool { ... }
    fn chain_accept<'life0, 'async_trait>(
        _players: &'life0 [Player],
    ) -> Pin<Box<dyn Future<Output = Vec<u8>> + Send + 'async_trait>>
       where 'life0: 'async_trait { ... }
    fn chain_create<'life0, 'async_trait>(
        _players: &'life0 [Player],
        _params: Vec<u8>,
        _rid: u64,
        _seed: [u8; 32],
    ) -> Pin<Box<dyn Future<Output = Option<(Self, Vec<Box<dyn Task<H = Self>>>)>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait { ... }
    fn pozk_create<'async_trait>(
        _player: Player,
        _params: Vec<u8>,
        _rid: u64,
    ) -> Pin<Box<dyn Future<Output = Option<(Self, Vec<Box<dyn Task<H = Self>>>)>> + Send + 'async_trait>>
       where Self: 'async_trait { ... }
    fn pozk_join<'life0, 'async_trait>(
        &'life0 mut self,
        _player: Player,
        _params: Vec<u8>,
    ) -> Pin<Box<dyn Future<Output = Result<HandleResult<Self::Param>, Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait { ... }
    fn viewer_online<'life0, 'async_trait>(
        &'life0 mut self,
        _peer: PeerId,
    ) -> Pin<Box<dyn Future<Output = Result<HandleResult<Self::Param>, Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait { ... }
    fn viewer_offline<'life0, 'async_trait>(
        &'life0 mut self,
        _peer: PeerId,
    ) -> Pin<Box<dyn Future<Output = Result<HandleResult<Self::Param>, Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait { ... }
    fn online<'life0, 'async_trait>(
        &'life0 mut self,
        _peer: PeerId,
    ) -> Pin<Box<dyn Future<Output = Result<HandleResult<Self::Param>, Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait { ... }
    fn offline<'life0, 'async_trait>(
        &'life0 mut self,
        _peer: PeerId,
    ) -> Pin<Box<dyn Future<Output = Result<HandleResult<Self::Param>, Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait { ... }
    fn handle<'life0, 'async_trait>(
        &'life0 mut self,
        _peer: PeerId,
        _param: Self::Param,
    ) -> Pin<Box<dyn Future<Output = Result<HandleResult<Self::Param>, Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait { ... }
}
Expand description

Export useful types Handle message received from players

Required Associated Types§

Source

type Param: Param

Request/Response params

Required Methods§

Source

fn prove<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(Vec<u8>, Vec<u8>), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Generate proof for this game result, when find game is over

Provided Methods§

Source

fn viewable() -> bool

Viewable for game

Source

fn chain_accept<'life0, 'async_trait>( _players: &'life0 [Player], ) -> Pin<Box<dyn Future<Output = Vec<u8>> + Send + 'async_trait>>
where 'life0: 'async_trait,

Accept params when submit to chain

Source

fn chain_create<'life0, 'async_trait>( _players: &'life0 [Player], _params: Vec<u8>, _rid: u64, _seed: [u8; 32], ) -> Pin<Box<dyn Future<Output = Option<(Self, Vec<Box<dyn Task<H = Self>>>)>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Create new room scan from chain

Source

fn pozk_create<'async_trait>( _player: Player, _params: Vec<u8>, _rid: u64, ) -> Pin<Box<dyn Future<Output = Option<(Self, Vec<Box<dyn Task<H = Self>>>)>> + Send + 'async_trait>>
where Self: 'async_trait,

Create new room from PoZK

Source

fn pozk_join<'life0, 'async_trait>( &'life0 mut self, _player: Player, _params: Vec<u8>, ) -> Pin<Box<dyn Future<Output = Result<HandleResult<Self::Param>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

New player join from PoZK

Source

fn viewer_online<'life0, 'async_trait>( &'life0 mut self, _peer: PeerId, ) -> Pin<Box<dyn Future<Output = Result<HandleResult<Self::Param>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

New Viewer online if viewable is true

Source

fn viewer_offline<'life0, 'async_trait>( &'life0 mut self, _peer: PeerId, ) -> Pin<Box<dyn Future<Output = Result<HandleResult<Self::Param>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

New Viewer offline if viewable is true

Source

fn online<'life0, 'async_trait>( &'life0 mut self, _peer: PeerId, ) -> Pin<Box<dyn Future<Output = Result<HandleResult<Self::Param>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

When player online

Source

fn offline<'life0, 'async_trait>( &'life0 mut self, _peer: PeerId, ) -> Pin<Box<dyn Future<Output = Result<HandleResult<Self::Param>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

When player offline

Source

fn handle<'life0, 'async_trait>( &'life0 mut self, _peer: PeerId, _param: Self::Param, ) -> Pin<Box<dyn Future<Output = Result<HandleResult<Self::Param>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Handle message in a room

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.

Implementors§