Crate const_irc_message_parser

Source
Expand description

§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.

Modules§

casemapping
Method for checking equivalency of slices using IrcCaseMapping.
command
Method for parsing and extracting a Command.
formatting
Methods for detecting, extracting and separating an IrcFmtByte.
isupport
Methods for parsing and extracting information from an ISupportToken.
parameters
Methods for parsing and extracting information from Parameters.
source
Methods for parsing and extracting information from Source.
tags
Methods for parsing and extracting information from Tags.

Structs§

IrcMsg
A single IRC Message created from a slice of bytes.

Enums§

ContentType
A wrapper containing either a string slice or a non-utf8 slice of bytes.
IrcMsgError
The possible types of errors when parsing an IrcMsg.