[−][src]Struct showdown::Sender
Message sender.
Methods
impl Sender
[src]
pub fn send_global_command(
&mut self,
command: &str
) -> impl Future<Item = (), Error = Error> + '_
[src]
&mut self,
command: &str
) -> impl Future<Item = (), Error = Error> + '_
Sends a global command.
Example
#![feature(async_await, await_macro, futures_api)] #![recursion_limit = "128"] use futures03::prelude::*; use showdown::message::{Kind, 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.kind() { assert!(rooms .official .iter() .any(|room| room.title == "Tournaments")); return Ok(()); } } } Runtime::new() .unwrap() .block_on_all(start().boxed().compat()) .unwrap();
pub fn send_chat_message(
&mut self,
room_id: RoomId,
message: &str
) -> impl Future<Item = (), Error = Error> + '_
[src]
&mut self,
room_id: RoomId,
message: &str
) -> impl Future<Item = (), Error = Error> + '_
Sends a message in a chat room.
Examples
#![feature(async_await, await_macro, futures_api)] #![recursion_limit = "128"] use futures03::prelude::*; use showdown::message::{Kind, 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())?.kind() { assert!(html.contains("Relax here amidst the chaos.")); return Ok(()); } } } Runtime::new() .unwrap() .block_on_all(start().boxed().compat()) .unwrap();
Trait Implementations
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
🔬 This is a nightly-only experimental API. (
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
🔬 This is a nightly-only experimental API. (
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Erased for T
impl<T> Typeable for T where
T: Any,
T: Any,