Crate ts3

Source
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::connect("localhost:10011").await?;

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

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

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

    client.use_sid(1).await?;

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

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

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();
    }
}

Modules§

event
request
response
Response types returned by client requests
shared
Types shared between requests/responses.

Structs§

Client
A Client used to send commands to the serverquery interface.
Error
An error that can occur when interacting with the TS3 query API.

Traits§

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

Attribute Macros§

async_trait

Derive Macros§

Decode