object StateStoreSerializer : OkioSerializer<StateStorePreferences>


Serializer for StateStorePreferences using DataStore and Okio.

Serializes the preferences to a JSON string backed by a UTF-8 file.

Summary

Public functions

open suspend StateStorePreferences

Unmarshal object from source.

open suspend Unit

Marshal object to a Sink.

Public properties

open StateStorePreferences

Value to return if there is no data on disk.

Public functions

readFrom

open suspend fun readFrom(source: BufferedSource): StateStorePreferences

Unmarshal object from source.

Parameters
source: BufferedSource

the BufferedSource with the data to deserialize

Throws
androidx.datastore.core.CorruptionException

if the data from source is corrupted and/or unparseable, e.g. InvalidProtocolBufferException when the type T is a protobuf message and it is corrupted. Other unrecoverable androidx.datastore.core.IOException from the file system should not be thrown as androidx.datastore.core.CorruptionException.

writeTo

Added in 1.0.0-alpha01
open suspend fun writeTo(t: StateStorePreferences, sink: BufferedSink): Unit

Marshal object to a Sink.

Parameters
t: StateStorePreferences

the data to write to output

sink: BufferedSink

the BufferedSink to serialize data to

Public properties

defaultValue

Added in 1.0.0-alpha01
open val defaultValue: StateStorePreferences

Value to return if there is no data on disk.