package dev.inmo.postssystem.features.files.common

import dev.inmo.micro_utils.repos.KeyValueRepo
import dev.inmo.micro_utils.repos.mappers.withMapper
import kotlinx.serialization.StringFormat

fun MetasKeyValueRepo(
    serialFormat: StringFormat,
    originalRepo: KeyValueRepo<String, String>
) = originalRepo.withMapper<FileId, MetaFileInfo, String, String>(
    { string },
    { serialFormat.encodeToString(MetaFileInfo.serializer(), this) },
    { FileId(this) },
    { serialFormat.decodeFromString(MetaFileInfo.serializer(), this) }
)
