def build_payload(self, payload):
        """Build payload of all parts and write them into the payload buffer"""
        remaining_size = self.MAX_SEGMENT_PAYLOAD_SIZE

        for part in self.parts:
            part_payload = part.pack(remaining_size)
            payload.write(part_payload)
            remaining_size -= len(part_payload)
Build payload of all parts and write them into the payload buffer