pub struct Sender { /* fields omitted */ }
Sends a global command.
#![feature(async_await, await_macro, futures_api)]
#![recursion_limit = "128"]
use futures03::prelude::*;
use showdown::message::{Kind, ParsedMessage, QueryResponse};
use showdown::{connect, Result, RoomId};
use tokio::await;
use tokio::runtime::Runtime;
async fn start() -> Result<()> {
let (mut sender, mut receiver) = await!(connect("showdown"))?;
await!(sender.send_global_command("cmd rooms"))?;
loop {
let received = await!(receiver.receive())?;
if let Kind::QueryResponse(QueryResponse::Rooms(rooms)) = received.parse().kind {
assert!(rooms
.official
.iter()
.any(|room| room.title == "Tournaments"));
return Ok(());
}
}
}
Runtime::new()
.unwrap()
.block_on_all(start().boxed().compat())
.unwrap();
Sends a message in a chat room.
#![feature(async_await, await_macro, futures_api)]
#![recursion_limit = "128"]
use futures03::prelude::*;
use showdown::message::{Kind, ParsedMessage, QueryResponse};
use showdown::{connect, Result, RoomId};
use tokio::await;
use tokio::runtime::Runtime;
async fn start() -> Result<()> {
let (mut sender, mut receiver) = await!(connect("showdown"))?;
await!(sender.send_global_command("join lobby"))?;
await!(sender.send_chat_message(RoomId::LOBBY, "/roomdesc"));
loop {
if let Kind::Html(html) = await!(receiver.receive())?.parse().kind {
assert!(html.contains("Relax here amidst the chaos."));
return Ok(());
}
}
}
Runtime::new()
.unwrap()
.block_on_all(start().boxed().compat())
.unwrap();
Performs copy-assignment from source
. Read more
Formats the value using the given formatter. Read more
Creates owned data from borrowed data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
impl<T> Typeable for T where T: Any, | |
Get the TypeId
of this object.