Crate ircparser

Source
Expand description

An IRC (RFC1459) parser and formatter, built in Rust.

§Parsing messages

You can parse IRC messages using the provided parse function.

let msg = "@id=123;name=rick :nick!user@host.tmi.twitch.tv PRIVMSG #rickastley :Never gonna give you up!\r\n";
match ircparser::parse(msg) {
    Ok(mut x) => {
        let line = x.pop_front().unwrap();

        assert_eq!(&line.tags["id"], "123");
        if line.source.is_some() {
            assert_eq!(line.source.unwrap(), ":nick!user@host.tmi.twitch.tv");
        }
        assert_eq!(line.command, "PRIVMSG");
        assert_eq!(line.params[0], "#rickastley");
        assert_eq!(line.params[1], "Never gonna give you up!");
    }
    Err(e) => {
        println!("A parsing error occured: {e}");
        return;
    }
};

Structs§

Line
A struct representing a parsed line.
ParseError
Exception thrown when an error occurs during message parsing.

Functions§

parse
Parses an IRC message.