Package dev.restate.serde
Interface Serde<T extends @Nullable Object>
- All Superinterfaces:
TypeTag<T>
Interface defining serialization and deserialization of concrete types.
For more info on the serialization stack, and how to customize it, see SerdeFactory
.
Implementations MUST be thread safe.
You can create a custom one using using(String, ThrowingFunction, ThrowingFunction)
.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final record
Schema to be serialized using internal Jackson mapper.static interface
static final record
Schema already serialized to String.Nested classes/interfaces inherited from interface dev.restate.serde.TypeTag
TypeTag.Class<T>
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondefault @Nullable String
Content-type to use in request/responses.deserialize
(Slice value) default @Nullable Serde.Schema
using
(ThrowingFunction<T, byte[]> serializer, ThrowingFunction<byte[], T> deserializer) Likeusing(String, ThrowingFunction, ThrowingFunction)
, using content-typeapplication/octet-stream
.using
(String contentType, ThrowingFunction<T, byte[]> serializer, ThrowingFunction<byte[], T> deserializer) static <T> Serde
<T> withContentType
(String contentType, Serde<T> inner)
-
Field Details
-
Method Details
-
serialize
-
deserialize
-
contentType
Content-type to use in request/responses.If null, the SDK assumes the produced output is empty. This might change in the future.
-
jsonSchema
- Returns:
- a Draft 2020-12 Json Schema. It should be self-contained, and MUST not contain refs to files or HTTP. The schema is currently used by Restate to introspect the service contract and generate an OpenAPI definition.
-
using
static <T extends @NonNull Object> Serde<@NonNull T> using(ThrowingFunction<T, byte[]> serializer, ThrowingFunction<byte[], T> deserializer) Likeusing(String, ThrowingFunction, ThrowingFunction)
, using content-typeapplication/octet-stream
. -
using
static <T extends @NonNull Object> Serde<@NonNull T> using(String contentType, ThrowingFunction<T, byte[]> serializer, ThrowingFunction<byte[], T> deserializer) Create aSerde
fromserializer
/deserializer
lambdas, tagging withcontentType
. Before invoking the serializer, we check thatvalue
is non-null. -
withContentType
-