Crate tmi

source ·
Expand description

Blazingly fast 🚀 Rust 🦀 library for interacting with’s chat interface.

$ cargo add tmi
let mut client = tmi::Client::connect().await?;

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


Calling the library blazingly fast is done in jest, but it is true that twitch-rs is very fast. twitch-rs is part of the twitch-irc-benchmarks, where it is currently the fastest implementation by a significant margin (roughly 2.5x faster than the second best implementation). The reason for this is that the IRC message parser is handwritten using SIMD instructions for x86 and ARM. For every other architecture, there is a scalar fallback. The SIMD implementation is quite portable, as on x86 it relies only on SSE2, which is available in every x86 CPU created in the last two decades, and on ARM it relies on Neon, which is also well supported.


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