libp2p.io package¶
Submodules¶
libp2p.io.abc module¶
-
class
libp2p.io.abc.
EncryptedMsgReadWriter
¶ Bases:
libp2p.io.abc.MsgReadWriteCloser
,libp2p.io.abc.Encrypter
Read/write message with encryption/decryption.
-
class
libp2p.io.abc.
Encrypter
¶ Bases:
abc.ABC
-
abstract
decrypt
(data: bytes) → bytes¶
-
abstract
encrypt
(data: bytes) → bytes¶
-
abstract
-
class
libp2p.io.abc.
MsgReadWriteCloser
¶ Bases:
libp2p.io.abc.MsgReader
,libp2p.io.abc.MsgWriter
,libp2p.io.abc.Closer
-
class
libp2p.io.abc.
ReadCloser
¶
-
class
libp2p.io.abc.
ReadWriteCloser
¶ Bases:
libp2p.io.abc.Reader
,libp2p.io.abc.Writer
,libp2p.io.abc.Closer
-
class
libp2p.io.abc.
ReadWriter
¶
-
class
libp2p.io.abc.
WriteCloser
¶
libp2p.io.exceptions module¶
-
exception
libp2p.io.exceptions.
DecryptionFailedException
¶
-
exception
libp2p.io.exceptions.
IOException
¶
-
exception
libp2p.io.exceptions.
IncompleteReadError
¶ Bases:
libp2p.io.exceptions.IOException
Fewer bytes were read than requested.
-
exception
libp2p.io.exceptions.
MessageTooLarge
¶
-
exception
libp2p.io.exceptions.
MissingLengthException
¶
-
exception
libp2p.io.exceptions.
MissingMessageException
¶
-
exception
libp2p.io.exceptions.
MsgioException
¶
libp2p.io.msgio module¶
msgio
is an implementation of https://github.com/libp2p/go-msgio.
from that repo: “a simple package to r/w length-delimited slices.”
NOTE: currently missing the capability to indicate lengths by “varint” method.
-
class
libp2p.io.msgio.
BaseMsgReadWriter
(read_write_closer: libp2p.io.abc.ReadWriteCloser)¶ Bases:
libp2p.io.abc.MsgReadWriteCloser
-
async
close
() → None¶
-
abstract
encode_msg
(msg: bytes) → bytes¶
-
abstract async
next_msg_len
() → int¶
-
async
read_msg
() → bytes¶
-
read_write_closer
: ReadWriteCloser = None¶
-
size_len_bytes
: int = None¶
-
async
write_msg
(msg: bytes) → None¶
-
async
-
class
libp2p.io.msgio.
FixedSizeLenMsgReadWriter
(read_write_closer: libp2p.io.abc.ReadWriteCloser)¶ Bases:
libp2p.io.msgio.BaseMsgReadWriter
-
encode_msg
(msg: bytes) → bytes¶
-
async
next_msg_len
() → int¶
-
size_len_bytes
: int = None¶
-
-
class
libp2p.io.msgio.
VarIntLengthMsgReadWriter
(read_write_closer: libp2p.io.abc.ReadWriteCloser)¶ Bases:
libp2p.io.msgio.BaseMsgReadWriter
-
encode_msg
(msg: bytes) → bytes¶
-
max_msg_size
: int = None¶
-
async
next_msg_len
() → int¶
-
-
libp2p.io.msgio.
encode_msg_with_length
(msg_bytes: bytes, size_len_bytes: int) → bytes¶
-
async
libp2p.io.msgio.
read_length
(reader: libp2p.io.abc.Reader, size_len_bytes: int) → int¶
libp2p.io.utils module¶
-
async
libp2p.io.utils.
read_exactly
(reader: libp2p.io.abc.Reader, n: int, retry_count: int = 100) → bytes¶ NOTE: relying on exceptions to break out on erroneous conditions, like EOF