Skip to main content

Crate obby_proto

Crate obby_proto 

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

CaseFolded
A nick or channel name folded under a server’s casemapping.
ChanModes
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.
ModeChange
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 Style active 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 CASEMAPPING ISUPPORT token.
Colour
A colour carried by \x03 or \x04.
ParseError
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-time value.
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-time value 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.