Skip to content

Commit

Permalink
Define plugin hook spec for serialize_many
Browse files Browse the repository at this point in the history
  • Loading branch information
faph committed Sep 16, 2023
1 parent ca9f688 commit 1115185
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/py_adapter/plugin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import functools
import logging
import sys
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Sequence

import pluggy

Expand Down Expand Up @@ -111,6 +111,18 @@ def serialize(obj: "py_adapter.Basic", writer_schema: bytes) -> bytes:
raise NotImplementedError()


@_hookspec(firstresult=True)
def serialize_many(objs: Sequence["py_adapter.Basic"], writer_schema: bytes) -> bytes:
"""
Hook specification. Serialize multiple Python objects of basic types to the format supported by the implementing
plugin.
:param objs: Python objects to serialize
:param writer_schema: Data schema to serialize the data with, as JSON bytes.
"""
raise NotImplementedError()


@_hookspec(firstresult=True)
def deserialize(data: bytes, writer_schema: bytes) -> "py_adapter.Basic":
"""
Expand Down

0 comments on commit 1115185

Please sign in to comment.