autobahn.flatbuffers.flexbuffers¶
Implementation of FlexBuffers binary format.
For more info check https://google.github.io/flatbuffers/flexbuffers.html and corresponding C++ implementation at https://github.com/google/flatbuffers/blob/master/include/flatbuffers/flexbuffers.h
Classes¶
Functions¶
Module Contents¶
- class Builder(share_strings=False, share_keys=True, force_min_bit_width=BitWidth.W8)[source]¶
Helper class to encode structural data into flexbuffers format.
- Blob(value)[source]¶
Encodes binary blob value.
- Parameters:
value – A byte/bytearray value to encode
- Returns:
Offset of the encoded value in underlying the byte buffer.
- FixedTypedVectorFromElements(elements, element_type=None, byte_width=0)[source]¶
Encodes sequence of elements of the same type as fixed typed vector.
- Parameters:
elements – Sequence of elements, they must be of the same type. Allowed types are Type.INT, Type.UINT, Type.FLOAT. Allowed number of elements are 2, 3, or 4.
element_type – Suggested element type. Setting it to None means determining correct value automatically based on the given elements.
byte_width – Number of bytes to use per element. For Type.INT and Type.UINT: 1, 2, 4, or 8. For Type.FLOAT: 4 or 8. Setting it to 0 means determining correct value automatically based on the given elements.
- Float(value, byte_width=0)[source]¶
Encodes floating point value.
- Parameters:
value – A floating point value.
byte_width – Number of bytes to use: 4 or 8.
- IndirectFloat(value, byte_width=0)[source]¶
Encodes floating point value indirectly.
- Parameters:
value – A floating point value.
byte_width – Number of bytes to use: 4 or 8.
- IndirectInt(value, byte_width=0)[source]¶
Encodes signed integer value indirectly.
- Parameters:
value – A signed integer value.
byte_width – Number of bytes to use: 1, 2, 4, or 8.
- IndirectUInt(value, byte_width=0)[source]¶
Encodes unsigned integer value indirectly.
- Parameters:
value – An unsigned integer value.
byte_width – Number of bytes to use: 1, 2, 4, or 8.
- Int(value, byte_width=0)[source]¶
Encodes signed integer value.
- Parameters:
value – A signed integer value.
byte_width – Number of bytes to use: 1, 2, 4, or 8.
- Key(value)[source]¶
Encodes key value.
- Parameters:
value – A byte/bytearray/str value to encode. Byte object must not contain zero bytes. String object must be convertible to ASCII.
- Returns:
Offset of the encoded value in the underlying byte buffer.
- TypedVectorFromElements(elements, element_type=None)[source]¶
Encodes sequence of elements of the same type as typed vector.
- Parameters:
elements – Sequence of elements, they must be of the same type.
element_type – Suggested element type. Setting it to None means determining correct value automatically based on the given elements.
- UInt(value, byte_width=0)[source]¶
Encodes unsigned integer value.
- Parameters:
value – An unsigned integer value.
byte_width – Number of bytes to use: 1, 2, 4, or 8.
- VectorFromElements(elements)[source]¶
Encodes sequence of any elements as a vector.
- Parameters:
elements – sequence of elements, they may have different types.
- _CreateVector(elements, typed, fixed, keys=None)[source]¶
Writes vector elements to the underlying buffer.
- _WriteScalarVector(element_type, byte_width, elements, fixed)[source]¶
Writes scalar vector elements to the underlying buffer.
- class Type[source]¶
Bases:
enum.IntEnumSupported types of encoded data.
These are used as the upper 6 bits of a type field to indicate the actual type.