BlobEncoder

class dsviper.BlobEncoder(blob_layout)

Bases: object

Builds a blob element by element: write(value) appends, end_encoding() returns the finished blob.

blob_layout() → BlobLayout

Return the layout of the blob.

encoder_layout() → BlobEncoderLayout

Return the BlobEncoderLayout: the blob layout together with the Viper types write() accepts for one element and for one component.

end_encoding() → ValueBlob

Return the encoded blob and end the encoding.

A write after this raises.

write(value: _InputValues) → None

Write one element at the end of the blob.

value is an int or a float when the layout packs one component, and a tuple of blob_layout.components() of them otherwise - or a value of encoder_layout().type(). A value of another type, or a tuple of another length, raises.