SHARE
TWEET

Untitled

a guest Sep 11th, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. mod handler
  2. {
  3.     pub type Result<T> = ::std::result::Result<T, HandlerError>;
  4.    
  5.     pub struct HandlerError;
  6.    
  7.     pub trait Handler
  8.     {
  9.         fn on_open(&mut self, h: usize) -> Result<()>;
  10.         fn on_message(&mut self, m: bool) -> Result<()>;
  11.     }
  12. }
  13.  
  14. mod client
  15. {
  16.     use super::handler::{ self, Handler };
  17.    
  18.     struct Client
  19.     {
  20.         h: usize,
  21.         m: bool,
  22.     }
  23.    
  24.     impl Handler for Client
  25.     {
  26.         fn on_open(&mut self, h: usize) -> handler::Result<()>
  27.         {
  28.             self.handle_on_open(h)
  29.         }
  30.        
  31.         fn on_message(&mut self, m: bool) -> handler::Result<()>
  32.         {
  33.             self.handle_on_message(m)
  34.         }
  35.     }
  36.    
  37.     mod open
  38.     {
  39.         use super::super::handler;
  40.         use super::Client;
  41.        
  42.         impl Client
  43.         {
  44.             pub fn handle_on_open(&mut self, h: usize) -> handler::Result<()>
  45.             {
  46.                 self.h = h;
  47.                 Ok(())
  48.             }
  49.         }
  50.     }
  51.    
  52.     mod message
  53.     {
  54.         use super::super::handler;
  55.         use super::Client;
  56.        
  57.         impl Client
  58.         {
  59.             pub fn handle_on_message(&mut self, m: bool) -> handler::Result<()>
  60.             {
  61.                 self.m = m;
  62.                 Ok(())
  63.             }
  64.         }
  65.     }
  66. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top