Crate ts3[][src]

Expand description

TS3

A fully asynchronous library to interact with the TeamSpeak 3 Server query interface. The commands are avaliable after connecting to a TS3 Server using a Client. Commands can either be sent using the associated command or using [Client.sent] to send raw messages.

Examples

Connect to a TS3 query interface and select a server

use ts3::Client;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
    // Create a new client and connect to the server query interface
    let client = Client::new("localhost:10011").await?;

    // switch to virtual server with id 1
    client.use_sid(1).await?;

    Ok(())
}
use ts3::{
    async_trait, Client,
    client::TextMessageTarget,
    event::{EventHandler, ClientEnterView}
};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
    let client = Client::new("localhost:10011").await?;

    client.use_sid(1).await?;

    // Assign a new event handler.
    client.set_event_handler(Handler);

    tokio::signal::ctrl_c().await?;
}

pub struct Handler;

#[async_trait]
impl EventHandler for Handler {
    async fn cliententerview(&self, client: Client, event: ClientEnterView) {
        println!("Client {} joined!", event.client_nickname);

        // Send a private message to the client using "sendtextmessage".
        client.sendtextmessage(TextMessageTarget::Client(event.clid), "Hello World!")
            .await.unwrap();
    }
}

Re-exports

pub use client::Client;
pub use client::RawResp;
pub use event::EventHandler;

Modules

Structs

A list of other objects that are being read from or written to the TS3 server interface. It implements both FromStr and ToString as long as T itself also implements these traits.

Enums

Traits

Any type implementing Decode can be directly decoded from the TS3 stream. It provides the complete buffer of the response from the stream.

Derive Macros