add including of contents serializers

This commit is contained in:
InsanusMokrassar 2020-12-01 12:48:24 +06:00
parent cc5a498436
commit ed46c888e3

View File

@ -1,10 +1,7 @@
package dev.inmo.postssystem.core.content package dev.inmo.postssystem.core.content
import dev.inmo.micro_utils.common.ByteArrayAllocator
import dev.inmo.micro_utils.common.ByteArrayAllocatorSerializer
import dev.inmo.micro_utils.mime_types.KnownMimeTypes
import dev.inmo.micro_utils.mime_types.MimeType
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import kotlinx.serialization.modules.*
typealias ContentId = String typealias ContentId = String
@ -23,6 +20,14 @@ data class OtherContentLinkContent(
) : Content ) : Content
fun SerializersModuleBuilder.includeContentsSerializers(
block: PolymorphicModuleBuilder<Content>.() -> Unit
) {
polymorphic(Content::class) {
subclass(OtherContentLinkContent::class, OtherContentLinkContent.serializer())
block()
}
}
/** /**
* Content which is already registered in database. Using its [id] you can retrieve all known * Content which is already registered in database. Using its [id] you can retrieve all known