Struct showdown::SendMessage
source · [−]pub struct SendMessage(_);
Implementations
Creates a global command.
Example
use futures::{SinkExt, StreamExt};
use showdown::message::{Kind, QueryResponse};
use showdown::{Result, RoomId, SendMessage, Stream};
#[tokio::main]
async fn main() -> Result<()> {
let mut stream = Stream::connect("showdown").await?;
stream.send(SendMessage::global_command("cmd rooms")).await?;
while let Some(received) = stream.next().await {
if let Kind::QueryResponse(QueryResponse::Rooms(rooms)) = received?.kind() {
assert!(rooms
.official
.iter()
.any(|room| room.title == "Tournaments"));
return Ok(());
}
}
panic!("Server didn't provide a list of rooms")
}
Creates a chat room message.
Creates a command that executes in a chat room.
Examples
use futures::{SinkExt, StreamExt};
use showdown::message::{Kind, QueryResponse};
use showdown::{Result, RoomId, SendMessage, Stream};
#[tokio::main]
async fn main() -> Result<()> {
let mut stream = Stream::connect("showdown").await?;
stream.send(SendMessage::global_command("join lobby")).await?;
stream.send(SendMessage::chat_command(RoomId::LOBBY, "roomdesc")).await;
while let Some(message) = stream.next().await {
if let Kind::Html(html) = message?.kind() {
assert!(html.contains("Relax here amidst the chaos."));
return Ok(());
}
}
panic!("Server didn't provide a room description")
}
Trait Implementations
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
Auto Trait Implementations
impl RefUnwindSafe for SendMessage
impl Send for SendMessage
impl Sync for SendMessage
impl Unpin for SendMessage
impl UnwindSafe for SendMessage
Blanket Implementations
Mutably borrows from an owned value. Read more
Compare self to key
and return true
if they are equal.
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more