Demo of custom serialization

I needed to create a custom format for a type I'm working on, so I thought while learning how to do this I'd create a demo for the benefit of others. I suspect the main issue worth discussing is whether this is the best approach, or would it be better/simpler to create custom `read` and `write` methods? CC @simonster.

Once this settles, I'll also add this material to the documentation.