Zserio Python runtime library documentation

zserio Package

Zserio Python runtime library.

It implements all functionality needed by Zserio code generated by Python extension.

Furthermore, it provides the following convenient functionality for generated Zserio objects which can be called by applications:

  • Serialization (zserio.serialization module)

  • Debug string output (zserio.debugstring module)

Functions

deserialize(obj_class, bitbuffer, *args)

Deserializes bit buffer to the generated object.

deserialize_bytes(obj_class, buffer, *args)

Deserializes byte buffer to the generated object.

deserialize_from_file(obj_class, filename, *args)

Deserializes file to the generated object.

from_json_file(obj_class, filename, *arguments)

Parses JSON debug string from given file and creates instance of the requested zserio object according to the data contained in the debug string.

from_json_stream(obj_class, text_io, *arguments)

Parses JSON debug string from given text stream and creates instance of the requested zserio object according to the data contained in the debug string.

from_json_string(obj_class, json_string, ...)

Parses JSON debug string and creates instance of the requested zserio object according to the data contained in the debug string.

serialize(obj)

Serializes generated object to the bit buffer.

serialize_to_bytes(obj)

Serializes generated object to the byte buffer.

serialize_to_file(obj, filename)

Serializes generated object to the byte buffer.

to_json_file(obj, filename, *[, indent, ...])

Writes contents of given zserio object to debug file in JSON format using Walker with JsonWriter.

to_json_stream(obj, text_io, *[, indent, ...])

Writes contents of given zserio object to debug stream in JSON format using Walker with JsonWriter.

to_json_string(obj, *[, indent, walk_filter])

Gets debug string in JSON format using Walker with JsonWriter for given zserio object.

Classes

AndWalkFilter(walk_filters)

Walk filter which implements composition of particular filters.

ArrayLengthWalkFilter(max_array_length)

Walk filter which allows to walk only to the given maximum array length.

BitBuffer(buffer[, bitsize])

Bit buffer.

BitStreamReader(buffer[, bitsize])

Bit stream reader.

BitStreamWriter()

Bit stream writer using bytearray.

DefaultWalkObserver()

Default walk observer which just does nothing.

DepthWalkFilter(max_depth)

Walk filter which allows to walk only to the given maximum depth.

JsonReader(text_io)

Reads zserio object tree defined by a type info from a text stream.

JsonWriter(*[, text_io, item_separator, ...])

Walker observer which dumps zserio objects to JSON format.

PubsubException

Exception thrown in case of an error in Zserio Pub/Sub.

PubsubInterface()

Interface for Pub/Sub client backends.

PythonRuntimeException

Exception thrown in case of an error in Zserio python runtime library.

RegexWalkFilter(path_regex)

Walk filter which allows to walk only paths matching the given regex.

ServiceClientInterface()

Generic interface for all Zserio services on client side.

ServiceData(zserio_object)

Data abstraction to be sent or to be received in all Zserio services.

ServiceException

Exception thrown in case of an error in Zserio Service

ServiceInterface()

Generic interface for all Zserio services on server side.

WalkFilter()

Interface for filters which can influence the walking.

WalkObserver()

Interface for observers which are called by the walker.

Walker(walk_observer[, walk_filter])

Walker through zserio objects, based on generated type info (see -withTypeInfoCode).

ZserioTreeCreator(type_info, *arguments)

Allows to build zserio object tree defined by the given type info.

Class Inheritance Diagram

Inheritance diagram of zserio.walker.AndWalkFilter, zserio.walker.ArrayLengthWalkFilter, zserio.bitbuffer.BitBuffer, zserio.bitreader.BitStreamReader, zserio.bitwriter.BitStreamWriter, zserio.walker.DefaultWalkObserver, zserio.walker.DepthWalkFilter, zserio.json.JsonReader, zserio.json.JsonWriter, zserio.pubsub.PubsubException, zserio.pubsub.PubsubInterface, zserio.exception.PythonRuntimeException, zserio.walker.RegexWalkFilter, zserio.service.ServiceClientInterface, zserio.service.ServiceData, zserio.service.ServiceException, zserio.service.ServiceInterface, zserio.walker.WalkFilter, zserio.walker.WalkObserver, zserio.walker.Walker, zserio.creator.ZserioTreeCreator
zserio.VERSION_STRING = '2.7.0'

Zserio Python runtime library version string.

zserio.array Module

The module implements abstraction for arrays used by Zserio python extension.

Classes

Array(array_traits[, raw_array, is_auto, ...])

Abstraction for arrays to which Zserio arrays are mapped in python.

BitBufferArrayTraits()

Array traits for Zserio extern bit buffer type.

BitFieldArrayTraits(numbits)

Array traits for unsigned fixed integer Zserio types (uint16, uint32, uint64, bit:5, etc...).

BoolArrayTraits()

Array traits for Zserio bool type.

DeltaContext()

Context for delta packing created for each packable field.

Float16ArrayTraits()

Array traits for Zserio float16 type.

Float32ArrayTraits()

Array traits for Zserio float32 type.

Float64ArrayTraits()

Array traits for Zserio float64 type.

ObjectArrayTraits(object_creator, ...)

Array traits for Zserio structure, choice, union and enum types.

ObjectPackedArrayTraits(...)

Packed array traits for Zserio objects.

PackedArrayTraits(array_traits)

Packed array traits.

PackingContextNode()

Packing context node which allows to keep packing contexts in a tree which corresponds with the user defined Zserio tree.

SignedBitFieldArrayTraits(numbits)

Array traits for signed fixed integer Zserio types (int16, int32, int64, int:5, etc...).

StringArrayTraits()

Array traits for Zserio string type.

VarInt16ArrayTraits()

Array traits for Zserio varint16 type.

VarInt32ArrayTraits()

Array traits for Zserio varint32 type.

VarInt64ArrayTraits()

Array traits for Zserio varint64 type.

VarIntArrayTraits()

Array traits for Zserio varint type.

VarSizeArrayTraits()

Array traits for Zserio varsize type.

VarUInt16ArrayTraits()

Array traits for Zserio varuint16 type.

VarUInt32ArrayTraits()

Array traits for Zserio varuint32 type.

VarUInt64ArrayTraits()

Array traits for Zserio varuint64 type.

VarUIntArrayTraits()

Array traits for Zserio varuint type.

zserio.bitbuffer Module

The module implements abstraction for holding bit sequence.

Classes

BitBuffer(buffer[, bitsize])

Bit buffer.

zserio.bitfield Module

The module provides help methods for bit fields calculation.

Functions

bitfield_lowerbound(length)

Gets the lower bound of a unsigned bitfield type with given length.

bitfield_upperbound(length)

Gets the upper bound of a unsigned bitfield type with given length.

signed_bitfield_lowerbound(length)

Gets the lower bound of a signed bitfield type with given length.

signed_bitfield_upperbound(length)

Gets the upper bound of a signed bitfield type with given length.

zserio.bitposition Module

The module provides help methods for bit position calculation.

Functions

alignto(alignment_value, bitposition)

Aligns the bit size to the given alignment value.

bits_to_bytes(numbits)

Converts number of bits to bytes.

bitsize_to_bytesize(bitsize)

Converts number of bits to number of bytes.

bytes_to_bits(num_bytes)

Converts number of bytes to bits.

zserio.bitreader Module

The module implements abstraction for reading data to the bit stream.

Classes

BitStreamReader(buffer[, bitsize])

Bit stream reader.

zserio.bitsizeof Module

The module provides help methods to calculate size of nontrivial types.

Functions

bitsizeof_bitbuffer(bitbuffer)

Gets the bit size of bit buffer which is stored in bit stream.

bitsizeof_string(string)

Gets bit size of string.

bitsizeof_varint(value)

Gets bit size of variable signed integer value (up to 9 bytes).

bitsizeof_varint16(value)

Gets bit size of variable 16-bit signed integer value.

bitsizeof_varint32(value)

Gets bit size of variable 32-bit signed integer value.

bitsizeof_varint64(value)

Gets bit size of variable 64-bit signed integer value.

bitsizeof_varsize(value)

Gets bit size of variable size integer value.

bitsizeof_varuint(value)

Gets bit size of variable unsigned integer value (up to 9 bytes).

bitsizeof_varuint16(value)

Gets bit size of variable 16-bit unsigned integer value.

bitsizeof_varuint32(value)

Gets bit size of variable 32-bit unsigned integer value.

bitsizeof_varuint64(value)

Gets bit size of variable 64-bit unsigned integer value.

zserio.bitwriter Module

The module implements abstraction for writing data to the bit stream.

Classes

BitStreamWriter()

Bit stream writer using bytearray.

zserio.builtin Module

The module provides implementation of zserio built-in operators.

Functions

numbits(num_values)

Gets the minimum number of bits required to encode given number of different values.

zserio.creator Module

The module implements creator of zserio object tree based on type info.

Classes

ZserioTreeCreator(type_info, *arguments)

Allows to build zserio object tree defined by the given type info.

Class Inheritance Diagram

Inheritance diagram of zserio.creator.ZserioTreeCreator

zserio.debugstring Module

The module provides utilities for JSON debug string which can be obtained from zserio objects.

Note

Zserio objects must be generated with -withTypeInfoCode zserio option to enable JSON debug string!

Functions

from_json_file(obj_class, filename, *arguments)

Parses JSON debug string from given file and creates instance of the requested zserio object according to the data contained in the debug string.

from_json_stream(obj_class, text_io, *arguments)

Parses JSON debug string from given text stream and creates instance of the requested zserio object according to the data contained in the debug string.

from_json_string(obj_class, json_string, ...)

Parses JSON debug string and creates instance of the requested zserio object according to the data contained in the debug string.

to_json_file(obj, filename, *[, indent, ...])

Writes contents of given zserio object to debug file in JSON format using Walker with JsonWriter.

to_json_stream(obj, text_io, *[, indent, ...])

Writes contents of given zserio object to debug stream in JSON format using Walker with JsonWriter.

to_json_string(obj, *[, indent, walk_filter])

Gets debug string in JSON format using Walker with JsonWriter for given zserio object.

zserio.exception Module

The module implements exceptions for Zserio python runtime library.

zserio.float Module

The module provides help methods for manipulation with float numbers.

The following float formats defined by IEEE 754 standard are supported:

Functions

float_to_uint16(float64)

Converts python native float to 16-bit float stored as integer value.

float_to_uint32(float64)

Converts python native float to 32-bit float stored as integer value.

float_to_uint64(float64)

Converts python native float to 64-bit float stored as integer value.

uint16_to_float(float16_value)

Converts 16-bit float stored as an integer value to python native float.

uint32_to_float(float32_value)

Converts 32-bit float stored as an integer value to python native float.

uint64_to_float(float64_value)

Converts 64-bit float stored as an integer value to python native float.

zserio.hashcode Module

The module provides utility methods for hash code calculation.

Functions

calc_hashcode(seed_value, value)

Calculates hash code of the value using seed value.

zserio.json Module

The module implements WalkObserver for writing of zserio objects to JSON format.

Classes

JsonDecoder()

JSON value decoder.

JsonEncoder()

Converts zserio values to Json string representation.

JsonParser(text_io, observer)

Json Parser.

JsonParserException

Exception used to distinguish exceptions from the JsonParser.

JsonReader(text_io)

Reads zserio object tree defined by a type info from a text stream.

JsonToken(value)

Tokens used by Json Tokenizer.

JsonTokenizer(text_io)

Tokenizer used by JsonParser.

JsonWriter(*[, text_io, item_separator, ...])

Walker observer which dumps zserio objects to JSON format.

Class Inheritance Diagram

Inheritance diagram of zserio.json.JsonDecoder, zserio.json.JsonEncoder, zserio.json.JsonParser, zserio.json.JsonParserException, zserio.json.JsonReader, zserio.json.JsonToken, zserio.json.JsonTokenizer, zserio.json.JsonWriter

zserio.limits Module

Zserio types limits.

zserio.pubsub Module

The module provides classes for Zserio Pub/Sub.

Classes

PubsubException

Exception thrown in case of an error in Zserio Pub/Sub.

PubsubInterface()

Interface for Pub/Sub client backends.

Class Inheritance Diagram

Inheritance diagram of zserio.pubsub.PubsubException, zserio.pubsub.PubsubInterface

zserio.serialization Module

The module provides help methods for serialization and deserialization of generated objects.

Functions

deserialize(obj_class, bitbuffer, *args)

Deserializes bit buffer to the generated object.

deserialize_bytes(obj_class, buffer, *args)

Deserializes byte buffer to the generated object.

deserialize_from_file(obj_class, filename, *args)

Deserializes file to the generated object.

serialize(obj)

Serializes generated object to the bit buffer.

serialize_to_bytes(obj)

Serializes generated object to the byte buffer.

serialize_to_file(obj, filename)

Serializes generated object to the byte buffer.

zserio.service Module

The module provides classes for Zserio services.

Classes

ServiceClientInterface()

Generic interface for all Zserio services on client side.

ServiceData(zserio_object)

Data abstraction to be sent or to be received in all Zserio services.

ServiceException

Exception thrown in case of an error in Zserio Service

ServiceInterface()

Generic interface for all Zserio services on server side.

Class Inheritance Diagram

Inheritance diagram of zserio.service.ServiceClientInterface, zserio.service.ServiceData, zserio.service.ServiceException, zserio.service.ServiceInterface

zserio.typeinfo Module

The module contains classes for type info.

Classes

CaseInfo(case_expressions, field)

Case info class which provides information about choice cases in generated choices.

ItemInfo(schema_name, py_item)

Item info class which provides information about items of generated enumerable types.

MemberAttribute(value)

Member attribute type to be used in MemberInfo.

MemberInfo(schema_name, typeinfo, *[, ...])

Member info class which provides information about members of compound types.

RecursiveTypeInfo(type_info_func)

Type info for recursive types used as a wrapper around generated static type_info method to prevent infinite recursion in type info definition.

TypeAttribute(value)

Type attribute type to be used in TypeInfo.

TypeInfo(schema_name, py_type, *[, attributes])

Type info class which provides information about generated types.

Class Inheritance Diagram

Inheritance diagram of zserio.typeinfo.CaseInfo, zserio.typeinfo.ItemInfo, zserio.typeinfo.MemberAttribute, zserio.typeinfo.MemberInfo, zserio.typeinfo.RecursiveTypeInfo, zserio.typeinfo.TypeAttribute, zserio.typeinfo.TypeInfo

zserio.walker Module

The module implements generic walker through given zserio object tree.

Classes

AndWalkFilter(walk_filters)

Walk filter which implements composition of particular filters.

ArrayLengthWalkFilter(max_array_length)

Walk filter which allows to walk only to the given maximum array length.

DefaultWalkFilter()

Default walk filter which filters nothing.

DefaultWalkObserver()

Default walk observer which just does nothing.

DepthWalkFilter(max_depth)

Walk filter which allows to walk only to the given maximum depth.

RegexWalkFilter(path_regex)

Walk filter which allows to walk only paths matching the given regex.

WalkFilter()

Interface for filters which can influence the walking.

WalkObserver()

Interface for observers which are called by the walker.

Walker(walk_observer[, walk_filter])

Walker through zserio objects, based on generated type info (see -withTypeInfoCode).

Class Inheritance Diagram

Inheritance diagram of zserio.walker.AndWalkFilter, zserio.walker.ArrayLengthWalkFilter, zserio.walker.DefaultWalkFilter, zserio.walker.DefaultWalkObserver, zserio.walker.DepthWalkFilter, zserio.walker.RegexWalkFilter, zserio.walker.WalkFilter, zserio.walker.WalkObserver, zserio.walker.Walker

Indices and tables