use streambuf api