Generates a `MqttSubscribe` packet given a
        `MqttFixedHeader`.  This method asserts that header.packet_type
        is `subscribe`.

        Parameters
        ----------
        header: MqttFixedHeader
        f: file
            Object with a read method.

        Raises
        ------
        DecodeError
            When there are extra bytes at the end of the packet.

        Returns
        -------
        int
            Number of bytes consumed from ``f``.
        MqttSubscribe
            Object extracted from ``f``.

def decode_body(cls, header, f):
        """Generates a `MqttSubscribe` packet given a
        `MqttFixedHeader`.  This method asserts that header.packet_type
        is `subscribe`.

        Parameters
        ----------
        header: MqttFixedHeader
        f: file
            Object with a read method.

        Raises
        ------
        DecodeError
            When there are extra bytes at the end of the packet.

        Returns
        -------
        int
            Number of bytes consumed from ``f``.
        MqttSubscribe
            Object extracted from ``f``.
        """
        assert header.packet_type == MqttControlPacketType.subscribe

        decoder = mqtt_io.FileDecoder(mqtt_io.LimitReader(f, header.remaining_len))
        packet_id, = decoder.unpack(mqtt_io.FIELD_PACKET_ID)

        topics = []
        while header.remaining_len > decoder.num_bytes_consumed:
            num_str_bytes, name = decoder.unpack_utf8()
            max_qos, = decoder.unpack(mqtt_io.FIELD_U8)
            try:
                sub_topic = MqttTopic(name, max_qos)
            except ValueError:
                raise DecodeError('Invalid QOS {}'.format(max_qos))
            topics.append(sub_topic)

        assert header.remaining_len == decoder.num_bytes_consumed

        return decoder.num_bytes_consumed, MqttSubscribe(packet_id, topics)