package dev.inmo.postssystem.features.roles.manager.common

import dev.inmo.postssystem.features.roles.common.Role
import dev.inmo.postssystem.features.roles.common.RoleSerializer
import dev.inmo.micro_utils.serialization.typed_serializer.TypedSerializer
import kotlinx.serialization.Serializable

@Serializable(RolesManagerRoleSerializer::class)
interface RolesManagerRole : Role {
    companion object {
        fun serializer() = RolesManagerRoleSerializer
    }
}

@Serializable
object GeneralRolesManagerRole : RolesManagerRole {
    override fun toString(): String = "GeneralRolesManagerRole"
}

private const val KEY = "roles_manager"

object RolesManagerRoleSerializer : TypedSerializer<RolesManagerRole>(
    RolesManagerRole::class,
    mapOf(
        "${KEY}_general" to GeneralRolesManagerRole.serializer()
    )
) {
    init {
        RoleSerializer.includeSerializer(KEY, RolesManagerRoleSerializer)
        serializers.forEach { (k, v) -> RoleSerializer.includeSerializer(k, v) }
    }
}
