I'm trying to use Scala Pickling to program some generic unpickling logic.
Say you have two types, A and B, and you pickle them into a byte array.
You take this byte array and send it to another machine and that's received as a byte array.
Now you need to unpickle it, but you don't know whether the byte array is for type A or type B.
How would you program the unpicking part? Do you make A and B extend another type, say T, and then call unpickle[T], and then pattern match on the result for A or B?
Or do you add a instance variable to T, say a Byte, which uses different number for instances of type A or B, and based on that, call unpickle[A] or unpickle[B]?
UPDATE: Looking into the Scala Pickling testsuite, the closest thing I found is base.scala, which kinda follows the first option.