tiled.media_type_registration.SerializationRegistry.register

SerializationRegistry.register(structure_family, media_type, func=None)[source]

Register a new media_type for a structure family.

Parameters:
structure_familystr

The structure we are encoding, as in “array”, “dataframe”, “variable”, …

media_type{str, List[str]}

MIME type, as in “application/json” or “text/csv”. If there is not standard name, use “application/x-INVENT-NAME-HERE”.

funccallable, optional

Should accept the relevant structure as input (e.g. a numpy array) and return bytes or memoryview

Examples

Use as a normal method.

>>> serialization_registry.register("array", "image/tiff", serialize_tiff)

Use as a decorator.

>>> @serialization_registry.register("array", "image_tiff")
... def serialize_tiff(...):
...     ...
...