let flush p =
let rec faux () =
match Queue.dequeue p.records with
| Some r ->
Buffer.add_string p.buffer (p.to_string r);
faux ()
| None -> () in
faux ();
let ret = Buffer.contents p.buffer in
p.clear_buffer p.buffer;
ret