Created
June 20, 2017 07:55
-
-
Save andoriyu/bcd5d0e27aa09381a37be4d6322499dd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pub trait ClientExt<T: Service<Request=Frame,Response=Frame,Future=FrameFuture,Error=io::Error>> { | |
| fn service(&self) -> Rc<RefCell<T>>; | |
| fn session(&self) -> Rc<RefCell<ClientSession>>; | |
| fn authenticate(&self) -> Box<Future<Item = (), Error = io::Error>> { | |
| let session = self.session().clone(); | |
| let service = self.service().clone(); | |
| let hello_frame = session.borrow().make_hello(); | |
| let hello_future = service.borrow().call(hello_frame); | |
| let ret = hello_future.and_then(|hello_resp| { | |
| let initiate = session.borrow_mut().make_initiate(&hello_resp).unwrap(); | |
| service.borrow().call(initiate).and_then(|_| ok(())) | |
| }); | |
| Box::new(ret) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment