mqtt_packet_map_topic (mqtt_packet_map v1.3.1)

View Source

MQTT packet encoder

Summary

Functions

Recombine a normalized topic to a single binary string.

Check if a topic is valid, the topic must have been normalized. All topic characters must be utf-8 and topic levels shouldn't contain + and # characters.

Normalize a topic to a list. Wildcards are replace by the atoms '+' and '#' (as used by the router).

Validate a topic, return the normalized topic if it is a valid topic or topic filter.

Validate a topic, return the normalized topic. Must not contain any wild cards.

Functions

flatten_topic(B)

-spec flatten_topic(mqtt_packet_map:mqtt_topic()) -> binary().

Recombine a normalized topic to a single binary string.

is_valid_topic(L)

-spec is_valid_topic(list()) -> boolean().

Check if a topic is valid, the topic must have been normalized. All topic characters must be utf-8 and topic levels shouldn't contain + and # characters.

is_wildcard_topic(L)

-spec is_wildcard_topic(list()) -> boolean().

normalize_topic(B)

Normalize a topic to a list. Wildcards are replace by the atoms '+' and '#' (as used by the router).

validate_topic(T)

-spec validate_topic(mqtt_packet_map:mqtt_topic()) ->
                        {ok, mqtt_packet_map:mqtt_topic()} | {error, invalid_topic}.

Validate a topic, return the normalized topic if it is a valid topic or topic filter.

validate_topic_publish(T)

-spec validate_topic_publish(mqtt_packet_map:mqtt_topic()) ->
                                {ok, mqtt_packet_map:mqtt_topic()} | {error, invalid_topic}.

Validate a topic, return the normalized topic. Must not contain any wild cards.