Change async def write

To return `None` instead of `int. `Writer.write` *does* write all data
in all use case.
This commit is contained in:
mhchia
2020-02-07 18:33:15 +08:00
parent 1152f9b703
commit fb53edbc04
7 changed files with 10 additions and 14 deletions

View File

@ -160,7 +160,7 @@ class Mplex(IMuxedConn):
return await self.write_to_stream(_bytes)
async def write_to_stream(self, _bytes: bytes) -> int:
async def write_to_stream(self, _bytes: bytes) -> None:
"""
writes a byte array to a secured connection.
@ -174,8 +174,6 @@ class Mplex(IMuxedConn):
"failed to write message to the underlying connection"
) from e
return len(_bytes)
async def handle_incoming(self) -> None:
"""Read a message off of the secured connection and add it to the
corresponding message buffer."""

View File

@ -134,7 +134,7 @@ class MplexStream(IMuxedStream):
self._buf = self._buf[len(payload) :]
return bytes(payload)
async def write(self, data: bytes) -> int:
async def write(self, data: bytes) -> None:
"""
write to stream.
@ -147,7 +147,7 @@ class MplexStream(IMuxedStream):
if self.is_initiator
else HeaderTags.MessageReceiver
)
return await self.muxed_conn.send_message(flag, data, self.stream_id)
await self.muxed_conn.send_message(flag, data, self.stream_id)
async def close(self) -> None:
"""Closing a stream closes it for writing and closes the remote end for