From f5adf5f9eade680ed63e19b55a89f83785afd70f Mon Sep 17 00:00:00 2001 From: Juraj Hrivnak Date: Tue, 8 Oct 2024 16:32:26 +0200 Subject: [PATCH] Move Instant serializer to data package --- .../pakku/{ => api/data}/InstantIso8601Serializer.kt | 9 ++++----- .../kotlin/teksturepako/pakku/api/projects/Project.kt | 2 -- .../teksturepako/pakku/api/projects/ProjectFile.kt | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) rename src/commonMain/kotlin/teksturepako/pakku/{ => api/data}/InstantIso8601Serializer.kt (89%) diff --git a/src/commonMain/kotlin/teksturepako/pakku/InstantIso8601Serializer.kt b/src/commonMain/kotlin/teksturepako/pakku/api/data/InstantIso8601Serializer.kt similarity index 89% rename from src/commonMain/kotlin/teksturepako/pakku/InstantIso8601Serializer.kt rename to src/commonMain/kotlin/teksturepako/pakku/api/data/InstantIso8601Serializer.kt index 39719900..b138bbe7 100644 --- a/src/commonMain/kotlin/teksturepako/pakku/InstantIso8601Serializer.kt +++ b/src/commonMain/kotlin/teksturepako/pakku/api/data/InstantIso8601Serializer.kt @@ -1,4 +1,4 @@ -package teksturepako.pakku +package teksturepako.pakku.api.data import kotlinx.serialization.KSerializer import kotlinx.serialization.descriptors.PrimitiveKind @@ -18,15 +18,14 @@ import java.time.Instant */ object InstantIso8601Serializer : KSerializer { - override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("java.time.Instant", PrimitiveKind.STRING) override fun deserialize(decoder: Decoder): Instant = Instant.parse(decoder.decodeString()) - override fun serialize(encoder: Encoder, value: Instant) { + override fun serialize(encoder: Encoder, value: Instant) + { encoder.encodeString(value.toString()) } - -} \ No newline at end of file +} diff --git a/src/commonMain/kotlin/teksturepako/pakku/api/projects/Project.kt b/src/commonMain/kotlin/teksturepako/pakku/api/projects/Project.kt index 66a0c253..6d6bd20f 100644 --- a/src/commonMain/kotlin/teksturepako/pakku/api/projects/Project.kt +++ b/src/commonMain/kotlin/teksturepako/pakku/api/projects/Project.kt @@ -8,7 +8,6 @@ import com.github.michaelbull.result.Result import com.github.michaelbull.result.get import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable -import teksturepako.pakku.InstantIso8601Serializer import teksturepako.pakku.api.actions.ActionError import teksturepako.pakku.api.actions.ActionError.ProjDiffPLinks import teksturepako.pakku.api.actions.ActionError.ProjDiffTypes @@ -17,7 +16,6 @@ import teksturepako.pakku.api.platforms.Multiplatform import teksturepako.pakku.api.platforms.Platform import teksturepako.pakku.api.platforms.Provider import teksturepako.pakku.io.filterPath -import java.time.Instant /** * Represents a project. (E.g. a mod, resource pack, shader, etc.) diff --git a/src/commonMain/kotlin/teksturepako/pakku/api/projects/ProjectFile.kt b/src/commonMain/kotlin/teksturepako/pakku/api/projects/ProjectFile.kt index ff1ff0d5..98ebf623 100644 --- a/src/commonMain/kotlin/teksturepako/pakku/api/projects/ProjectFile.kt +++ b/src/commonMain/kotlin/teksturepako/pakku/api/projects/ProjectFile.kt @@ -3,7 +3,7 @@ package teksturepako.pakku.api.projects import kotlinx.serialization.Required import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable -import teksturepako.pakku.InstantIso8601Serializer +import teksturepako.pakku.api.data.InstantIso8601Serializer import teksturepako.pakku.api.actions.ActionError import teksturepako.pakku.api.actions.ActionError.HashMismatch import teksturepako.pakku.api.actions.ActionError.NoHashes