Expand description
IRCv3 wire format.
This crate holds no connection and no client state. It turns bytes into a Message and back,
and it knows the rules that depend only on the line itself: tag escaping, casemapping, ISUPPORT
token grammar, mode argument arity.
use obby_proto::Message;
let msg = Message::parse("@time=2026-09-06T10:00:00.000Z :nick!u@h PRIVMSG #chan :hello")?;
assert_eq!(msg.command, "PRIVMSG");
assert_eq!(msg.params, ["#chan", "hello"]);
assert_eq!(msg.tag("time"), Some("2026-09-06T10:00:00.000Z"));Structs§
- Case
Folded - A nick or channel name folded under a server’s casemapping.
- Chan
Modes - The four classes of channel mode, from
CHANMODES=beI,k,l,imnpst. - Ctcp
- A CTCP request or reply extracted from a message body, such as
ACTION waves. - Emphasis
- The six independent text-decoration toggles, packed into one byte.
- Isupport
- Everything the server told us about itself in
005. - Message
- A parsed protocol line.
- Mode
Change - One mode letter changing, with the argument it consumed.
- Prefix
- The membership prefixes a server uses, in rank order, highest first.
- Source
- Where a message came from, as sent in the
:-prefixed source. - Span
- A run of text plus the
Styleactive over it. - Style
- The formatting active over a run of text.
- Tag
- One message tag. A tag with an empty value is the same as a tag with no value, so both parse to
value: None. - Tags
- The tag section of a message, in the order it arrived.
- Token
- One token after the wire grammar has been read off it.
Enums§
- Casemapping
- How a server folds case, from the
CASEMAPPINGISUPPORT token. - Colour
- A colour carried by
\x03or\x04. - Parse
Error - Why a line could not be parsed.
Constants§
- MAX_
CLIENT_ TAG_ BYTES - The byte budget a client may spend on its own
+-prefixed tags. - MAX_
LINE_ BYTES - The byte budget for everything after the tags, including the trailing CRLF.
- MAX_
TAG_ BYTES - The byte budget for the tag section, excluding the leading
@and the separating space.
Functions§
- format_
server_ time - Write milliseconds since the Unix epoch as a
server-timevalue. - parse_
channel_ modes - Split a channel MODE change into one entry per letter.
- parse_
ctcp - Recognise a CTCP-wrapped body:
\x01COMMAND params\x01. - parse_
server_ time - Read a
server-timevalue as milliseconds since the Unix epoch. - parse_
spans - Parse a message body into styled spans.
- parse_
user_ modes - Split a user MODE change. User modes never take an argument.
- strip_
formatting - The plain text of a message body, with every formatting and colour code removed.