python_pae.abstract module

This module defines the basic abstract building blocks of the API.

class python_pae.abstract.PAEType(*args, **kwds)

Bases: Generic[python_pae.abstract.T]

Provides a serialisation implementation for a particular type of values.

constant_length: Optional[int] = None

If not None, the output length of the write() method must always be equal to the value of this property.

Length prefixes for types with a fixed byte length can optionally be omitted.

write(value: python_pae.abstract.T, 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) python_pae.abstract.T

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.

exception python_pae.abstract.PAEDecodeError

Bases: ValueError

Raised if an error occurs during PAE decoding.