12 releases (6 breaking)

0.7.2 Aug 15, 2024
0.7.1 Jun 22, 2024
0.6.1 Jun 14, 2024
0.6.0 Mar 31, 2024
0.4.0 Nov 12, 2023

#628 in Web programming

Download history 16/week @ 2024-08-19 16/week @ 2024-08-26 16/week @ 2024-09-02 14/week @ 2024-09-09 15/week @ 2024-09-16 66/week @ 2024-09-23 42/week @ 2024-09-30 9/week @ 2024-10-07 12/week @ 2024-10-14 12/week @ 2024-10-21 53/week @ 2024-10-28 54/week @ 2024-11-04 15/week @ 2024-11-11 14/week @ 2024-11-18 13/week @ 2024-11-25 33/week @ 2024-12-02

81 downloads per month
Used in 2 crates

MIT license

225KB
5K SLoC

tmi-rsDocumentation Latest Version

Blazingly fast 🚀 Rust 🦀 library for interacting with twitch.tv's chat interface.

Quick Start

$ cargo add tmi anyhow tokio -F tokio/full
const CHANNELS: &[&str] = &["#forsen"];

#[tokio::main]
async fn main() -> anyhow::Result<()> {
  let mut client = tmi::Client::anonymous().await?;
  client.join_all(CHANNELS).await?;

  loop {
    let msg = client.recv().await?;
    match msg.as_typed()? {
      tmi::Message::Privmsg(msg) => {
        println!("{}: {}", msg.sender().name(), msg.text());
      }
      tmi::Message::Reconnect => {
        client.reconnect().await?;
        client.join_all(CHANNELS).await?;
      }
      tmi::Message::Ping(ping) => {
        client.pong(&ping).await?;
      }
      _ => {}
    }
  }
}

Performance

Calling the library blazingly fast is done in jest, but it is true that tmi-rs is very fast. tmi-rs is part of the twitch-irc-benchmarks, where it is currently the fastest implementation by a significant margin (nearly 6x faster than the second best Rust implementation). This is because underlying IRC message parser is handwritten and accelerated using SIMD on x86 and ARM. For every other architecture, there is a scalar fallback.

Acknowledgements

Initially based on dank-twitch-irc, and twitch-irc-rs. Lots of test messages were taken directly from twitch-irc-rs.

Dependencies

~0–10MB
~115K SLoC