buffer: define a generic parser API