scala/pickling

Custom Serializers

Opened this issue · 1 comments

Is it possible to write a custom serializer and hook it up with pickling? For example, when one wants to serialize/deserialize ActorRefs, one has to incorporate the address part which is only known at run time. Is it possible with pickling?

So, if I have understood your question correctly and unless I'm missing something, it's not only possible but the way scala pickling works. You generate the code at compile-time, but you provide the objects that will be serialized at runtime. Just make sure you import everything that is necessary to generate a pickler and unpickler for ActorRef (the guide explains it) or, at least, you create your own custom one if scala pickling cannot generate it automatically. You can even create custom runtime picklers and unpicklers, but you don't want this in your use case. You know beforehand the type, ask for an implicit pickler and unpickler and use them.