Skip to content

Typing utilities

The classes in this module are only used for type hinting and do not have any functionality.

Protocol Reader

Bases: Protocol

Protocol for reading bytes from a source.

read(length=-1)

Read at most length bytes from the source.

Parameters:

  • length (int, default: -1 ) –

    The maximum number of bytes to read. If -1, read until EOF.

Returns:

  • bytes ( bytes ) –

    The bytes read from the source.

Protocol Writer

Bases: Protocol

Protocol for writing bytes to a destination.

write(buf)

Parameters:

  • buf (Buffer) –

    The bytes to write.

Returns:

  • int ( int ) –

    The number of bytes written.