Bundler

open class Bundler(val serializersModule: SerializersModule) : SerialFormat

Implements encoding and decoding classes to/from androidx.core.bundle.Bundle.

Usage:

@Serializable
class Data(val property1: String)

@Serializable
class DataHolder(val data: Data, val property2: String)

val bundle = Bundler.encodeToBundle(DataHolder(Data("value1"), "value2"))

val dataHolder = Bundler.decodeFromBundle<DataHolder>(bundle)

Parameters

serializersModule

A SerializersModule which should contain registered serializers for kotlinx.serialization.Contextual and kotlinx.serialization.Polymorphic serialization, if you have any.

Inheritors

Constructors

Link copied to clipboard
constructor(serializersModule: SerializersModule)

Types

Link copied to clipboard

The default instance of Bundler

Properties

Link copied to clipboard
open override val serializersModule: SerializersModule

Functions

Link copied to clipboard
@ExperimentalSerializationApi
inline fun <T> decodeFromBundle(bundle: Bundle, deserializer: DeserializationStrategy<T> = serializer()): T

Decodes a value from the given bundle using the provided deserializer of type T.

Link copied to clipboard
@ExperimentalSerializationApi
inline fun <T> encodeToBundle(value: T, serializer: SerializationStrategy<T> = serializer()): Bundle

Encodes the given value to a Bundle using the provided serializer of type T.