Skip to content

Commit

Permalink
flatten EvalCacheEntry.Id bson handler
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasf committed Apr 15, 2024
1 parent 58442c5 commit 6d855d0
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/main/scala/evalCache/EvalCacheBsonHandlers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,12 @@ object EvalCacheBsonHandlers:
private def handlerBadType[T](b: BSONValue): Try[T] =
Failure(TypeDoesNotMatchException("BSONValue", b.getClass.getSimpleName))

given BSONHandler[BinaryFen] = new:
given BSONHandler[Id] = new:
def readTry(bson: BSONValue) =
bson match
case v: BSONBinary => Success(BinaryFen(v.byteArray))
case v: BSONBinary => Success(Id(BinaryFen(v.byteArray)))
case _ => handlerBadType(bson)
def writeTry(v: BinaryFen) = Success(BSONBinary(v.value, Subtype.GenericBinarySubtype))
given BSONHandler[Id] = Macros.handler
def writeTry(v: Id) = Success(BSONBinary(v.position.value, Subtype.GenericBinarySubtype))

given BSONDocumentHandler[Eval] = Macros.handler
given BSONDocumentHandler[EvalCacheEntry] = Macros.handler

0 comments on commit 6d855d0

Please sign in to comment.