interface OkioSerializer<T : Any?>

Known direct subclasses
PreferencesSerializer

Proto based serializer for Preferences.


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

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

Summary

Public functions

suspend T

Unmarshal object from source.

suspend Unit
writeTo(t: T, sink: BufferedSink)

Marshal object to a Sink.

Public properties

T

Value to return if there is no data on disk.

Public functions

readFrom

suspend fun readFrom(source: BufferedSource): T

Unmarshal object from source.

Parameters
source: BufferedSource

the BufferedSource with the data to deserialize

writeTo

Added in 1.1.0
suspend fun writeTo(t: T, sink: BufferedSink): Unit

Marshal object to a Sink.

Parameters
t: T

the data to write to output

sink: BufferedSink

the BufferedSink to serialize data to

Public properties

defaultValue

Added in 1.1.0
val defaultValue: T

Value to return if there is no data on disk.