Declaratively encode and decode binary data