Draft: Generic BufferPool
This changeset prepares buffer pools to manage different types of buffers like Flat Buffers in !20 (closed), which is useful for #26 (closed). To this end BufferPool
becomes BufferPool<T: InnerBuffer>
where T
is a buffer type and InnerBuffer
is the trait defining the methods required by BufferPool
to allocate at once a set of buffers (method InnerBuffer::calloc
) and by Buffer<T>
to Deref
/ DerefMut
to the buffer contents (methods InnerBuffer::as_slice
and InnerBuffer::as_mut_slice
). The current buffer implementation is moved to the currently only buffer type called BytesBuffer
.
Expected short-term evolutions:
-
make Buffer<T>
Deref
/DerefMut
toT::Content
instead of[u8]
- To this end replace
InnerBuffer::as_slice
/as_mut_slice
withInnerBuffer::get
/get_mut
.
- To this end replace
-
add a Flat Buffer buffer type with pre-allocation of all the buffers metadata memory in InnerBuffer::calloc
- To this end it might be required to provide
InnerBuffer::calloc
with an initializerFn
. - In a simpler alternative the buffer type could define an dedicated initializer trait and take a type parameter implementing this trait to initialize the buffers in
InnerBuffer::calloc
- To this end it might be required to provide