bite.io module
- class bite.io.BytesBuffer(data: bytes)[source]
Implements the ParserBuffer protocol for a
bytes
object.The buffer is static, i.e. all bytes are already provided.
- Parameters:
data – Data for the buffer.
- at_eof() bool [source]
Always returns True as the complete buffer is provided at construction time.
- async get(key: int | slice) bytes [source]
Get a range from from the buffer.
Blocks if the requested range is not available yet. If the requested range will never become available (e.g. because it would go past the end of file), as much as possible is returned.
- Parameters:
key – Range to return. An integer
i
is treated as a single byte rangeslice(i, i + 1)
.- Returns:
A
bytes
object containing the requested range from the buffer. This should always be abytes
objects even if a single integer index was provided (this is in contrast to how indexing works onbytes
objects). A smaller range than requested may be returned if the buffer is unable to provide that range (however, the method must block if that range may become available).# noqa (DAR202)
- class bite.io.ParserBuffer(*args, **kwargs)[source]
Protocol used by parsers to read from a bytes buffer.
- at_eof() bool [source]
Whether the end of file has been found.
If the end of file has been found, all possible bytes have been read into the buffer and no new bytes will be added.
- async get(key: int | slice) bytes [source]
Get a range from from the buffer.
Blocks if the requested range is not available yet. If the requested range will never become available (e.g. because it would go past the end of file), as much as possible is returned.
- Parameters:
key – Range to return. An integer
i
is treated as a single byte rangeslice(i, i + 1)
.- Returns:
A
bytes
object containing the requested range from the buffer. This should always be abytes
objects even if a single integer index was provided (this is in contrast to how indexing works onbytes
objects). A smaller range than requested may be returned if the buffer is unable to provide that range (however, the method must block if that range may become available).# noqa (DAR202)
- class bite.io.StreamReaderBuffer(reader: StreamReader)[source]
Implements the ParserBuffer protocol for a
asyncio.StreamReader
.- Parameters:
reader – Reader providing the bytes to be read into the buffer.
- at_eof() bool [source]
Whether the end of file has been found.
If the end of file has been found, all possible bytes have been read into the buffer and no new bytes will be added.
- async get(key: int | slice) bytes [source]
Get a range from from the buffer.
Blocks if the requested range is not available yet. If the requested range will never become available (e.g. because it would go past the end of file), as much as possible is returned.
- Parameters:
key – Range to return. An integer
i
is treated as a single byte rangeslice(i, i + 1)
.- Returns:
A
bytes
object containing the requested range from the buffer. This should always be abytes
objects even if a single integer index was provided (this is in contrast to how indexing works onbytes
objects). A smaller range than requested may be returned if the buffer is unable to provide that range (however, the method must block if that range may become available).# noqa (DAR202)