ircv3_parse 3.1.0

Zero-copy parser for IRCv3 messages
Documentation

IRCv3 Parse

crates.io Documentation License: MIT License: Apache 2.0

A zero-copy IRC message parser with IRCv3 support

Documentation

Features

  • Zero-copy parsing for performance
  • IRCv3 message tags support
  • Derive macro for easy message extraction
  • no_std compatible (with alloc)

Quick Start

[dependencies]
ircv3_parse = { version = "3", features = ["derive"] }
use ircv3_parse::FromMessage;

#[derive(FromMessage)]
#[irc(command = "PRIVMSG")]
struct PrivMsg<'a> {
    #[irc(source = "name")]
    nick: &'a str,
    #[irc(trailing)]
    message: &'a str
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let input = ":nick!user@example.com PRIVMSG #channel :hi";
    let msg: PrivMsg = ircv3_parse::from_str(input)?;

    println!("From: {}", msg.nick);
    println!("Message: {}",msg.message);

    Ok(())
}

Feature Flags

  • derive - Enables the FromMessage derive macro (recommended)
  • serde - Enables Serialize implementation for Message

no_std Support

[dependencies]
ircv3_parse = { version = "3", default-features = false, features = ["derive"] }

Parsing Rules

Notice: Each component parses first special character and follows the rule. Use validation methods for strict parsing.

  • Tags: Start with @, separated by ;, followed by space
  • Source: Start with :, format name!user@host or host, followed by space
  • Command: Letters or 3-digit number
  • Middle Parameters: Separated by spaces
  • Trailing Parameters: Start with : (space + colon)

License

Licensed under either of:

  • Apache License, Version 2.0
  • MIT license