[ccan] New module: iobuffer

Rusty Russell rusty at rustcorp.com.au
Sat Jun 18 13:11:40 EST 2011


On Fri, 17 Jun 2011 01:56:00 -0400, Joseph Adams <joeyadams3.14159 at gmail.com> wrote:
> Here's a new module that provides two callback-driven interfaces,
> struct ibuffer and struct obuffer, for input and output.  The
> interfaces themselves are simple, and should lend themselves to fast
> input and output, but implementing custom input and output drivers is
> a little tricky.

My basic response: really good idea.  It's such a common thing to want
to do; in an ideal world we'd be able to attach userspace backends to
file descriptors and get this effect, but we can't.

Since it's such a good idea, it's worth going over the API with a fine
tooth comb.  Here are some ideas:

First, it's a classic multi-API situation: one for input, one for
output, and then a part of each for implementing new input and output
types.

They almost certainly belong in the same module, but perhaps we should
split the headers?  (I know ccanlint will complain if you don't have an
iobuffer.h, but that can be fixed).

The other question is, is it better to define a 'struct ibuffer_type'
with the new, finish and fill operators inside *that*?  Then there's no
need for an ibuffer_string_new() etc, just expose struct ibuffer_type
ibuffer_string.

Also, I think 's/ensure/need/' would tighten the API language a bit.

Thanks!
Rusty.


More information about the ccan mailing list