Open
Description
Is there any plans for integration with Androidx DataStore? Or does Androidx provide this somewhere?
There are some nuances with https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:datastore/datastore-core-okio/src/commonMain/kotlin/androidx/datastore/core/okio/OkioSerializer.kt?q=OkioSerializer
That would be good to handle once. Something like
fun <T: Message<T, Nothing>> ProtoAdapter<T>.toOkioSerializer(): OkioSerializer<T> {
return object : OkioSerializer<T> {
override val defaultValue: T = [email protected](ByteString.EMPTY)
override suspend fun readFrom(source: BufferedSource): T {
try {
return [email protected](source)
} catch (exception: IOException) {
throw CorruptionException("Cannot read UserFavouriteGames proto.", exception)
}
}
override suspend fun writeTo(t: T, sink: BufferedSink) {
sink.write(t.encode())
}
}
}
Metadata
Metadata
Assignees
Labels
No labels