Skip to content

Parser for

faststream.mqtt.parser.parser_for #

parser_for(version: MQTTVersion) -> type[MQTTBaseParser]

The parser class a Broker version speaks.

One place says it, because the Subscriber that consumes through a parser and the in-memory test broker that encodes for one have to agree on the version.

Source code in faststream/mqtt/parser.py
def parser_for(version: MQTTVersion) -> type[MQTTBaseParser]:
    """The parser class a Broker version speaks.

    One place says it, because the Subscriber that consumes through a parser and
    the in-memory test broker that encodes for one have to agree on the version.
    """
    if version == "3.1.1":
        return MQTTParserV311
    if version == "5.0":
        return MQTTParserV5
    assert_never(version)