def encode_body(self, f):
        """

        Parameters
        ----------
        f: file
            File-like object with write method.

        Returns
        -------
        int
            Number of bytes written to file.
        """
        num_bytes_written = 0
        num_bytes_written += f.write(mqtt_io.FIELD_U16.pack(self.packet_id))
        for topic in self.topics:
            num_bytes_written += mqtt_io.encode_utf8(topic.name, f)
            num_bytes_written += f.write(mqtt_io.FIELD_U8.pack(topic.max_qos))

        return num_bytes_written
def encode_body ( self , f ) : num_bytes_written = 0 num_bytes_written += f . write ( mqtt_io . FIELD_U16 . pack ( self . packet_id ) ) for topic in self . topics : num_bytes_written += mqtt_io . encode_utf8 ( topic . name , f ) num_bytes_written += f . write ( mqtt_io . FIELD_U8 . pack ( topic . max_qos ) ) return num_bytes_written
Parameters
        ----------
        f: file
            File-like object with write method.

        Returns
        -------
        int
            Number of bytes written to file.