Add `Encoder` type for custom encoding of values