[][src]Struct showdown::Sender

pub struct Sender { /* fields omitted */ }

Message sender.

Implementations

impl Sender[src]

pub async fn send_global_command<'_>(
    &'_ mut self,
    command: impl Display
) -> Result<()>
[src]

Sends a global command.

Example

use futures::prelude::*;
use showdown::message::{Kind, QueryResponse};
use showdown::{connect, Result, RoomId};

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

pub async fn send_chat_message<'_, '_>(
    &'_ mut self,
    room_id: RoomId<'_>,
    message: impl Display
) -> Result<()>
[src]

Sends a message in a chat room.

pub async fn send_chat_command<'_, '_>(
    &'_ mut self,
    room_id: RoomId<'_>,
    command: impl Display
) -> Result<()>
[src]

Sends a command in a chat room.

Examples

use futures::prelude::*;
use showdown::message::{Kind, QueryResponse};
use showdown::{connect, Result, RoomId};

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

pub async fn broadcast_command<'_, '_>(
    &'_ mut self,
    room_id: RoomId<'_>,
    command: impl Display
) -> Result<()>
[src]

Trait Implementations

impl Debug for Sender[src]

Auto Trait Implementations

impl !RefUnwindSafe for Sender

impl Send for Sender

impl Sync for Sender

impl Unpin for Sender

impl !UnwindSafe for Sender

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<T> From<T> 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, 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>,