Serializable

class Serializable<T>(encodeToString: (T) -> String, decodeFromString: (String) -> T)

A class that encapsulates serialization and deserialization logic for a specific type.

This class provides a convenient way to store and retrieve objects in a serialized format. It hides the implementation details of serialization and deserialization behind private methods, while offering public methods for basic usage.

Parameters

T

The type of object this Serializable instance handles.

encodeToString

A function that converts an object of type T to a string representation.

decodeFromString

A function that converts a string representation back to an object of type T.

Constructors

Link copied to clipboard
constructor(encodeToString: (T) -> String, decodeFromString: (String) -> T)