encoder: make encoding protocol API sane