File tree Expand file tree Collapse file tree
module-ped-bson/src/commonMain/kotlin
module-ped-core/src/commonMain/kotlin Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -38,6 +38,10 @@ fun <I> BsonCodec(block: context(BsonCodecBuilder<I>) () -> Unit): BsonCodec<I>
3838 return Codec (block)
3939}
4040
41+ inline fun <reified I : Enum <I >> BsonEnumCodec (block : (I ) -> BsonElement ): BsonEnumCodec <I > {
42+ return EnumCodec (block)
43+ }
44+
4145/* ============= ------------------ ============= */
4246
4347/* *
Original file line number Diff line number Diff line change @@ -2,9 +2,14 @@ package org.cufy.ped
22
33import kotlin.Result.Companion.failure
44import kotlin.Result.Companion.success
5+ import kotlin.enums.enumEntries
56
67/* ============= ------------------ ============= */
78
9+ inline fun <reified I : Enum <I >, O > EnumCodec (block : (I ) -> O ): EnumCodec <I , O > {
10+ return EnumCodec (enumEntries<I >().map { it to block(it) })
11+ }
12+
813/* *
914 * A codec simplifying enum encoding.
1015 */
You can’t perform that action at this time.
0 commit comments