async-tw-econ 0.9.0

Simple Rust library to use Teeworlds external console asynchronously
Documentation
  • Coverage
  • 0%
    0 out of 2 items documented0 out of 0 items with examples
  • Size
  • Source code size: 12.75 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.03 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 26s Average build duration of successful builds.
  • all releases: 30s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • gerdoe-jr/async-tw-econ
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • gerdoe-jr ByFox213

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