File tree Expand file tree Collapse file tree
module-ped-bson/src/jvmTest/kotlin Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -93,7 +93,7 @@ data class Document1f2(val document: BsonDocument) {
9393
9494val Document1f2 .birthday1 get() = document[Document1 .Birthday1 ]
9595
96- val Document1f1Codec = Codec {
96+ val Document1f1Codec = BsonCodec {
9797 encodeCatching { it: Document1f1 ->
9898 BsonDocument {
9999 Document1 .Id by it.id
@@ -109,3 +109,19 @@ val Document1f1Codec = Codec {
109109 )
110110 }
111111}
112+
113+ @JvmInline
114+ value class CustomScalar (val value : String )
115+
116+ val ChSq : BsonCodec <CharSequence > = TODO ()
117+
118+ val CustomScalarCodec = BsonCodec <CustomScalar > {
119+ encodeCatching(Bson .String ) { it.value }
120+ decodeCatching(Bson .String ) { CustomScalar (it) }
121+ encodeCatching(ChSq ) { it.value }
122+ decodeCatching(ChSq ) { xyz: String -> CustomScalar (xyz) }
123+ decodeCatching { it: BsonString -> CustomScalar (it.value) }
124+ encodeCatching { it: CustomScalar -> it.value.bson }
125+ decodeCatching { CustomScalar (it decode Bson .String ) }
126+ encodeCatching { it.value.bson }
127+ }
You can’t perform that action at this time.
0 commit comments