streams: minor API change

with_limit suggests that the method returns a new StreamReader, instead of mutating self.
This commit is contained in:
Jan Pochyla 2016-10-26 17:33:52 +02:00
parent 83043f7aef
commit b3c03496e4
1 changed files with 2 additions and 2 deletions

View File

@ -38,13 +38,13 @@ class StreamReader:
self._buffer = buf self._buffer = buf
self._ofs = ofs self._ofs = ofs
def with_limit(self, n): def set_limit(self, n):
''' '''
Makes this reader to signal EOF after reading `n` bytes. Makes this reader to signal EOF after reading `n` bytes.
Returns the number of bytes that the reader can read after Returns the number of bytes that the reader can read after
raising EOF (intended to be restored with another call to raising EOF (intended to be restored with another call to
`with_limit`). `set_limit`).
''' '''
if self._limit is not None: if self._limit is not None:
rem = self._limit - n rem = self._limit - n