Serializer
-
android
interface Serializer<T : Any?>
PreferencesFileSerializer |
Proto based serializer for Preferences. |
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.
Summary
Public functions |
||
|---|---|---|
suspend T |
readFrom(input: InputStream)Unmarshal object from stream. |
android
|
suspend Unit |
writeTo(t: T, output: OutputStream)Marshal object to a stream. |
android
|
Public properties |
||
|---|---|---|
T |
Value to return if there is no data on disk. |
android
|
Public functions
readFrom
suspend fun readFrom(input: InputStream): T
Unmarshal object from stream.
| Parameters | |
|---|---|
input: InputStream |
the InputStream with the data to deserialize |
| Throws | |
|---|---|
androidx.datastore.core.CorruptionException |
if the data from |
writeTo
suspend fun writeTo(t: T, output: OutputStream): Unit
Marshal object to a stream. Closing the provided OutputStream is a no-op.
| Parameters | |
|---|---|
t: T |
the data to write to output |
output: OutputStream |
the OutputStream to serialize data to |