python_pae.pae_types module
This module defines the serialisation logic for a number of basic types.
- class python_pae.pae_types.PAEBytes(*args, **kwds)
Bases:
python_pae.abstract.PAEType[bytes]Represents a raw byte string, encoded as the identity.
- write(value: bytes, stream: IO) int
Serialise and write a value to a stream, length prefix not included.
- Parameters
value – The value to write.
stream – The stream to write to.
- Returns
The number of bytes written.
- read(stream: IO, length: int) bytes
Read a value from a stream, length prefix not included, and decode it.
- Parameters
stream – The stream to write to.
length – The expected length of the content to be read.
- Returns
The decoded value.
- class python_pae.pae_types.PAEString(*args, **kwds)
Bases:
python_pae.abstract.PAEType[str]Represents a text string, encoded in UTF-8.
- write(value: str, stream: IO) int
Serialise and write a value to a stream, length prefix not included.
- Parameters
value – The value to write.
stream – The stream to write to.
- Returns
The number of bytes written.
- read(stream: IO, length: int) str
Read a value from a stream, length prefix not included, and decode it.
- Parameters
stream – The stream to write to.
length – The expected length of the content to be read.
- Returns
The decoded value.
- class python_pae.pae_types.PAENumberType(value)
Bases:
python_pae.abstract.PAEType[int]Encodes various unsigned integer types. All are encoded in little-endian order.
- property constant_length
- unpack(packed: bytes)
- pack(value: int)
- write(value: int, stream: IO) int
Serialise and write a value to a stream, length prefix not included.
- Parameters
value – The value to write.
stream – The stream to write to.
- Returns
The number of bytes written.
- read(stream: IO, length: int) int
Read a value from a stream, length prefix not included, and decode it.
- Parameters
stream – The stream to write to.
length – The expected length of the content to be read.
- Returns
The decoded value.
- class python_pae.pae_types.PAEHomogeneousList(child_type: python_pae.abstract.PAEType[python_pae.pae_types.S], settings: python_pae.encode.PAEListSettings = PAEListSettings(size_type=<uint64 (ULLONG)>, length_type=None, prefix_if_constant=False))
Bases:
python_pae.abstract.PAEType[List[python_pae.pae_types.S]]Homogeneous list of length-prefixed items.
- Parameters
child_type – The type of the list’s elements.
settings – Encoding settings for the list.
- write(value: List[python_pae.pae_types.S], stream: IO) int
Serialise and write a value to a stream, length prefix not included.
- Parameters
value – The value to write.
stream – The stream to write to.
- Returns
The number of bytes written.
- read(stream: IO, length: int) List[python_pae.pae_types.S]
Read a value from a stream, length prefix not included, and decode it.
- Parameters
stream – The stream to write to.
length – The expected length of the content to be read.
- Returns
The decoded value.
- class python_pae.pae_types.PAEHeterogeneousList(component_types: List[python_pae.abstract.PAEType], settings: python_pae.encode.PAEListSettings = PAEListSettings(size_type=<uint64 (ULLONG)>, length_type=None, prefix_if_constant=True))
Bases:
python_pae.abstract.PAEType[list]Heterogeneous, fixed-length list of length-prefixed items, or a tuple.
- Parameters
component_types – The list of types that appear as the list’s components, in order.
settings – Encoding settings for the list.
- write(value: list, stream: IO) int
Serialise and write a value to a stream, length prefix not included.
- Parameters
value – The value to write.
stream – The stream to write to.
- Returns
The number of bytes written.
- read(stream: IO, length: int) list
Read a value from a stream, length prefix not included, and decode it.
- Parameters
stream – The stream to write to.
length – The expected length of the content to be read.
- Returns
The decoded value.
- python_pae.pae_types.DEFAULT_HMG_LIST_SETTINGS = PAEListSettings(size_type=<uint64 (ULLONG)>, length_type=None, prefix_if_constant=False)
Default list settings for homogeneous lists.
- python_pae.pae_types.DEFAULT_HTRG_LIST_SETTINGS = PAEListSettings(size_type=<uint64 (ULLONG)>, length_type=None, prefix_if_constant=True)
Default list settings for heterogeneous lists.