mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2025-12-19 12:46:03 +00:00
add docs to mapper serialization and allow to use them as supertypes
This commit is contained in:
@@ -5,7 +5,15 @@ import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
|
||||
class MapperSerializer<I, O>(
|
||||
/**
|
||||
* Use this serializer when you have serializable type [I] and want to map it to some [O] in process of
|
||||
* serialization/deserialization
|
||||
*
|
||||
* @param base Serializer for [I]
|
||||
* @param serialize Will be used in [serialize] method to convert incoming [O] to [I] and serialize with [base]
|
||||
* @param deserialize Will be used in [deserialize] method to convert deserialized by [base] [I] to [O]
|
||||
*/
|
||||
open class MapperSerializer<I, O>(
|
||||
private val base: KSerializer<I>,
|
||||
private val serialize: (O) -> I,
|
||||
private val deserialize: (I) -> O
|
||||
|
||||
Reference in New Issue
Block a user