-
-
Save kolemannix/c3292c9fed1a9292d099d5af8159d550 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// type annotation is added for clarity and is not needed | |
implicit val pointTrySerializable: SafeSerializable[Point, Try] = SafeSerializable.makeTry[Point]( | |
serializePoint, deserializePoint | |
) | |
val result: Try[Array[Byte]] = Serializer.serialize(point) | |
result match { | |
case Success(bytes) => | |
// type annotation is actually needed! We have to tell `deserialize` what type | |
// we want back | |
val deserialized: Try[Point] = Serializer.deserialize(bytes) | |
println("Success? " + deserialized.isSuccess) | |
case Failure(ex) => ex.printStackTrace | |
} | |
> "Success? true" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment