public interface OkioSerializer<T extends Object>

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 methods

abstract @NonNull T

Value to return if there is no data on disk.

abstract @NonNull T

Unmarshal object from source.

abstract void

Marshal object to a Sink.

Public methods

getDefaultValue

Added in 1.1.0-beta02
abstract @NonNullgetDefaultValue()

Value to return if there is no data on disk.

readFrom

abstract @NonNullreadFrom(@NonNull BufferedSource source)

Unmarshal object from source.

Parameters
@NonNull BufferedSource source

the BufferedSource with the data to deserialize

writeTo

Added in 1.1.0-beta02
abstract void writeTo(@NonNull T t, @NonNull BufferedSink sink)

Marshal object to a Sink.

Parameters
@NonNull T t

the data to write to output

@NonNull BufferedSink sink

the BufferedSink to serialize data to