def write_early_data(self, data: bytes) -> int:
        """Returns the number of (encrypted) bytes sent.
        """
        if self._is_handshake_completed:
            raise IOError('SSL Handshake was completed; cannot send early data.')

        # Pass the cleartext data to the SSL engine
        self._ssl.write_early_data(data)

        # Recover the corresponding encrypted data
        final_length = self._flush_ssl_engine()
        return final_length
Returns the number of (encrypted) bytes sent.