[][src]Struct showdown::SendMessage

pub struct SendMessage(_);

Implementations

impl SendMessage[src]

pub fn global_command(command: impl Display) -> Self[src]

Creates a global command.

Example

use futures::SinkExt;
use showdown::message::{Kind, QueryResponse};
use showdown::{connect, ReceiveExt, Result, RoomId, SendMessage};

#[tokio::main]
async fn main() -> Result<()> {
    let mut stream = connect("showdown").await?;
    stream.send(SendMessage::global_command("cmd rooms")).await?;
    loop {
        let received = stream.receive().await?;
        if let Kind::QueryResponse(QueryResponse::Rooms(rooms)) = received.kind() {
            assert!(rooms
                .official
                .iter()
                .any(|room| room.title == "Tournaments"));
            return Ok(());
        }
    }
}

pub fn chat_message(room_id: RoomId<'_>, message: impl Display) -> Self[src]

Creates a command that executes in a chat room.

Examples

use futures::SinkExt;
use showdown::message::{Kind, QueryResponse};
use showdown::{connect, ReceiveExt, Result, RoomId, SendMessage};

#[tokio::main]
async fn main() -> Result<()> {
    let mut stream = connect("showdown").await?;
    stream.send(SendMessage::global_command("join lobby")).await?;
    stream.send(SendMessage::chat_message(RoomId::LOBBY, "roomdesc")).await;
    loop {
        if let Kind::Html(html) = stream.receive().await?.kind() {
            assert!(html.contains("Relax here amidst the chaos."));
            return Ok(());
        }
    }
}

pub fn chat_command(room_id: RoomId<'_>, command: impl Display) -> Self[src]

Creates a chat room command message.

pub fn broadcast_command(room_id: RoomId<'_>, command: impl Display) -> Self[src]

Trait Implementations

impl Clone for SendMessage[src]

impl Debug for SendMessage[src]

impl Eq for SendMessage[src]

impl PartialEq<SendMessage> for SendMessage[src]

impl Sink<SendMessage> for Stream[src]

type Error = Error

The type of value produced by the sink when an error occurs.

impl StructuralEq for SendMessage[src]

impl StructuralPartialEq for SendMessage[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,