class documentation

Base converter to/from single payload/value with a known encoding for use in CompositePayloadConverter.

Method from_payload Decode a single payload to a Python value or raise exception.
Method to_payload Encode a single value to a payload or None.
Property encoding Encoding for the payload this converter works with.
@abstractmethod
def from_payload(self, payload: temporalio.api.common.v1.Payload, type_hint: Optional[Type] = None) -> Any: (source)

Decode a single payload to a Python value or raise exception.

Parameters
payload:temporalio.api.common.v1.PayloadPayload to convert to Python value.
type_hint:Optional[Type]Type that is expected if any. This may not have a type if there are no annotations on the target.
Returns
AnyThe decoded value from the payload. Since the encoding is checked by the caller, this should raise an exception if the payload cannot be converted.
Raises
RuntimeErrorGeneral error during decoding.

Encode a single value to a payload or None.

Parameters
value:AnyValue to be converted.
Returns
Optional[temporalio.api.common.v1.Payload]Payload of the value or None if unable to convert.
Raises
TypeErrorValue is not the expected type.
ValueErrorValue is of the expected type but otherwise incorrect.
RuntimeErrorGeneral error during encoding.