SerializationFactory

abstract class SerializationFactory

An abstraction for serializing and deserializing objects, with support for versioning of the wire format via a header / prefix in the bytes.

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

If there is a need to nest serialization/deserialization with a modified context during serialization or deserialization, this will return the current context used to start serialization/deserialization.

Link copied to clipboard

A context to use as a default if you do not require a specially configured context. It will be the current context if the use is somehow nested (see currentContext).

Functions

Link copied to clipboard
fun <T> asCurrent(block: SerializationFactory.() -> T): T

Allow subclasses to temporarily mark themselves as the current factory for the current thread during serialization/deserialization. Will restore the prior context on exiting the block.

Link copied to clipboard
abstract fun <T : Any> deserialize(byteSequence: ByteSequence, clazz: Class<T>, context: SerializationContext): T

Deserialize the bytes in to an object, using the prefixed bytes to determine the format.

Link copied to clipboard

Deserialize the bytes in to an object, using the prefixed bytes to determine the format.

Link copied to clipboard
abstract fun <T : Any> serialize(obj: T, context: SerializationContext): SerializedBytes<T>

Serialize an object to bytes using the preferred serialization format version from the context.

Link copied to clipboard
fun <T> withCurrentContext(context: SerializationContext?, block: () -> T): T

Change the current context inside the block to that supplied.