def METHOD_NAME(self, data: Union[str, bytes]) -> None:
    if isinstance(data, str):
        data = data.encode('utf-8')
    sz = struct.pack(self.size_fmt, len(data))
    self.write(sz)
    self.write(data)