code: def write(self, data: Union[bytes, memoryview]) -> "Future[None]":
          
          self._check_closed()
          if data:
              if (
                  self.max_write_buffer_size is not None
                  and len(self._write_buffer) + len(data) > self.max_write_buffer_size
              ):
                  raise StreamBufferFullError("Reached maximum write buffer size")
              self._write_buffer.append(data)
              self._total_write_index += len(data)
          future = Future()  # type: Future[None]
          future.add_done_callback(lambda f: f.exception())
          self._write_futures.append((self._total_write_index, future))
          if not self._connecting:
              self._handle_write()
              if self._write_buffer:
                  self._add_io_state(self.io_loop.WRITE)
              self._maybe_add_error_listener()
          return future
docs: Asynchronously write the given data to this stream.
  
          This method returns a `.Future` that resolves (with a result
          of ``None``) when the write has been completed.
  
          The ``data`` argument may be of type `bytes` or `memoryview`.
  
          .. versionchanged:: 4.0
              Now returns a `.Future` if no callback is given.
  
          .. versionchanged:: 4.5
              Added support for `memoryview` arguments.
  
          .. versionchanged:: 6.0
  
             The ``callback`` argument was removed. Use the returned
             `.Future` instead.