generate docs for a lot of API (test try)

This commit is contained in:
2026-02-24 18:18:10 +06:00
parent 3df90b1993
commit 4f270d9047
81 changed files with 2519 additions and 6 deletions

View File

@@ -5,6 +5,14 @@ import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
/**
* A serializer that encodes values to Base64 strings and decodes them back.
* Uses custom conversion functions to transform between type [T] and string representation.
*
* @param T The type to serialize/deserialize
* @param converterFrom Converts from type [T] to a string representation
* @param converterTo Converts from a string representation back to type [T]
*/
open class Base64Serializer<T>(
private val converterFrom: (T) -> String,
private val converterTo: (String) -> T,
@@ -14,5 +22,12 @@ open class Base64Serializer<T>(
override fun serialize(encoder: Encoder, value: T) = Base64BytesToFromStringSerializer.serialize(encoder, converterFrom(value).encodeToByteArray())
}
/**
* Serializer for [String] values encoded as Base64.
*/
object Base64StringSerializer : Base64Serializer<String>({ it }, { it })
/**
* Serializer for [ByteArray] values encoded as Base64.
*/
object Base64ByteArraySerializer : Base64Serializer<ByteArray>({ it.decodeToString() }, { it.encodeToByteArray() })