9 releases

✓ Uses Rust 2018 edition

new 0.2.2 May 23, 2020
0.2.1 May 22, 2020
0.2.0 Apr 7, 2020
0.1.6 Apr 7, 2020
0.1.2 Nov 14, 2019

#21 in Multimedia

Download history 2/week @ 2020-01-31 3/week @ 2020-02-07 26/week @ 2020-02-14 25/week @ 2020-02-21 24/week @ 2020-02-28 11/week @ 2020-03-06 10/week @ 2020-03-13 27/week @ 2020-03-20 16/week @ 2020-03-27 37/week @ 2020-04-03 59/week @ 2020-04-10 11/week @ 2020-04-17 5/week @ 2020-04-24 5/week @ 2020-05-01 11/week @ 2020-05-08

87 downloads per month

MIT/Apache

39KB
836 lines

Ts3 Query Library

crates.io docs.rs Build Status

Very barebone lib to connect to ts3 query interfaces and issue commands.

For examples visit the docs.

A lot of command-functions are currently not implemented, feel free to open issues or PRs adding them. (You can use the raw_command method along with its helpers to issue not implemented commands.) Any callback functionality for server events is also missing.


lib.rs:

Ts3 query library
Small, bare-metal ts query lib without any callback support currently.

A connectivity checking wrapper is available under managed when enabling its feature.

Examples

Simple auth + clients of a server group

use ts3_query::*;

# fn main() -> Result<(),Ts3Error> {
let mut client = QueryClient::new("localhost:10011")?;

client.login("serveradmin", "password")?;
client.select_server_by_port(9987)?;

let group_clients = client.get_servergroup_client_list(7)?;
println!("Got clients in group 7: {:?}",group_clients);

client.logout()?;
# Ok(())
# }

Using the raw interface for setting client descriptions.

use ts3_query::*;

# fn main() -> Result<(),Ts3Error> {
let mut client = QueryClient::new("localhost:10011")?;

client.login("serveradmin", "password")?;
client.select_server_by_port(9987)?;

// escape things like string args, not required for clid
// as it's not user input/special chars in this case
let cmd = format!("clientedit clid={} client_description={}",
 7, raw::escape_arg("Some Description!")
);
// we don't expect any value returned
let _ = client.raw_command(&cmd)?;

client.logout()?;
# Ok(())
# }

Raw interface example retrieving online client names

use ts3_query::*;
use std::collections::HashSet;

# fn main() -> Result<(),Ts3Error> {
let mut client = QueryClient::new("localhost:10011")?;

client.login("serveradmin", "password")?;
client.select_server_by_port(9987)?;

let res = raw::parse_multi_hashmap(client.raw_command("clientlist")?, false);
let names = res
    .into_iter()
    .map(|e| e.get("client_nickname").map(raw::unescape_val)
     // may want to catch this in a real application
        .unwrap())
    .collect::<HashSet<String>>();
println!("{:?}",names);
client.logout()?;
# Ok(())
# }

Dependencies

~0.5–0.8MB
~19K SLoC