Serializer

interface Serializer<T>(source)

The serializer determines the on-disk format and API for accessing it.

The type T MUST be immutable. Mutable types will result in broken DataStore functionality.

TODO(b/151635324): consider changing InputStream to File.

Functions

Link copied to clipboard
abstract suspend fun readFrom(input: InputStream): T

Unmarshal object from stream.

Link copied to clipboard
abstract suspend fun writeTo(t: T, output: OutputStream)

Marshal object to a stream. Closing the provided OutputStream is a no-op.

Properties

Link copied to clipboard
abstract val defaultValue: T

Value to return if there is no data on disk.