[][src]Function showdown::connect

pub fn connect(
    name: &str
) -> impl Future<Item = (Sender, Receiver), Error = Error>

Connects to a named Showdown server.

Returns two structures, Sender can be used to send messages to Showdown, while Receiver can be used to retrieve messages from Showdown. Due to borrow checker, those structures are separate - it's practically necessary to implement anything interesting.

Examples

#![feature(async_await, await_macro, futures_api)]
#![recursion_limit = "128"]

use futures03::prelude::*;
use showdown::{connect, Result};
use tokio::await;
use tokio::runtime::Runtime;

async fn start() {
    assert!(await!(connect("showdown")).is_ok());
    assert!(await!(connect("fakestofservers")).is_err());
}

Runtime::new()
    .unwrap()
    .block_on_all(start().unit_error().boxed().compat())
    .unwrap();