#message-parser #irc #parser #networking #irc-client #no-alloc

no-std const_irc_message_parser

A 0 dependency, no_std, const-only parser for the IRC message protocol

11 releases (breaking)

0.9.0 Sep 24, 2024
0.7.1 Mar 12, 2024
0.6.0 Oct 29, 2023

#1906 in Parser implementations

ISC license

160KB
2.5K SLoC

const_irc_message_parser

A 0 dependency, no_std, const-only parser for the IRC message protocol.

Motivation

I wanted to see how much of an IRC message parser can be written in a const context. Every public and private function is const. I was even able to make all the tests const functions even though it ends up being more verbose. The only exceptions are the Display impls as functions on Traits are not yet allowed to be const (https://github.com/rust-lang/rust/issues/103265). I am also unaware of how to test Display impls in a const manner for code coverage. Suggestions welcome.

Documentation

Documentation can be found here: https://docs.rs/const_irc_message_parser

Acknowledgements


lib.rs:

Const IRC Message Parser

A crate that allows you to parse a slice of bytes into a whole IrcMsg or parse a slice of bytes into the individual components that make up an IrcMsg. It also allows you to extract whichever portion of the message you want.

This is a #![no_std] crate that does not require alloc and has no dependencies.

Motivation

I wanted to see how much of an IRC message parser can be written in a const context. Every public and private function is const. I was even able to make all the tests const functions even though it ends up being more verbose. The only exceptions are the Display impls as functions on Traits are not yet allowed to be const (click here for details). I am also unaware of how to test Display impls in a const manner for code coverage. Suggestions welcome.

Usage

Ensure you have a single message as a slice of bytes from your network. Feed that single slice into the parser without the trailing carriage return and line feed to create an IrcMsg. Use the provided methods to extract the information desired for an IRC client, server or bot.

No runtime deps