Skip to main content

Module subject

Module subject 

Source
Expand description

Utilities for building NATS subjects out of arbitrary tokens.

NATS reserves three characters with special meaning inside a subject: . separates tokens, * matches a single token, and > matches one or more trailing tokens. A token that contains any of these (for example a Matrix room ID) would otherwise be split or interpreted as a wildcard, so EscapingSubject escapes them (along with the escape character \ itself) when serializing and restores them when parsing.

Structs§

EscapingSubject
Struct that allows building a NATS subject out of tokens, escaping any reserved characters that would otherwise split up or wildcard the tokens.

Enums§

TokenEscapeError
Errors that occur when unescaping a NATS token

Constants§

ESCAPES 🔒
The single source of truth for NATS reserved characters and their escape codes, as (literal, escape-code) pairs. Escaping looks a character up by its literal; unescaping looks it up by its code.
ESCAPE_CHAR 🔒
The character that introduces an escape sequence.

Functions§

escape_token
Escape every NATS-reserved character in a token (see ESCAPES) so it survives being placed in a subject.
unescape_token
Unescape a string that has been escaped with escape_token