async-tw-econ

Crates.ioasync-tw-econ
lib.rsasync-tw-econ
version0.9.0
created_at2025-10-29 15:58:10.839696+00
updated_at2026-01-06 18:54:57.602805+00
descriptionSimple Rust library to use Teeworlds external console asynchronously
homepage
repositoryhttps://github.com/gerdoe-jr/async-tw-econ
max_upload_size
id1906864
size8,766
ByFox (ByFox213)

documentation

README

async-tw-econ

Description

Rust library provides you a simple asynchronous interface to interconnect with Teeworlds external console.

Beware! Only tokio runtime is supported since async-std TcpStream seems to be unusable in this context.

Example

Let's say you have Teeworlds server running with ec_password zohan and ec_port 6060 and you want to use it's econ.

use async_tw_econ::Econ;

#[tokio::main]
async fn main() -> std::io::Result<()> {
    let mut econ = Econ::new();

    econ.connect("127.0.0.1:6060").await?;

    let authed = econ.try_auth("nahoz").await?;
    assert_eq!(authed, false);

    let authed = econ.try_auth("hozan").await?;
    assert_eq!(authed, false);

    let authed = econ.try_auth("zohan").await?;
    assert_eq!(authed, true);

    econ.send_line("echo \"Hi\"").await?;

    econ.fetch().await?;
    
    println!("{}", econ.pop_line()?);

    Ok(())
}
Commit count: 7

cargo fmt