Trait chomp::buffer::Buffer
[−]
[src]
pub trait Buffer<I>: Deref<Target=[I]> { fn fill<S: DataSource<Item=I>>(&mut self, &mut S) -> Result<usize>; fn request_space(&mut self, usize); fn consume(&self, items: usize); fn len(&self) -> usize; fn capacity(&self) -> usize; fn is_empty(&self) -> bool { ... } }
Trait all parser buffers implement.
Enables the consumer to request specific amounts of data and only consume partial parts of the buffer.
Required Methods
fn fill<S: DataSource<Item=I>>(&mut self, &mut S) -> Result<usize>
Attempt to fill the buffer using the closure F
.
The successful return from F
should contain the number of items successfully written to
the slice.
Notes
The returned value must NOT be larger than the length of the given slice.
Return
0
if no more data is available or if the slice is of zero length.The slice might contain uninitialized memory, do not read from the slice.
fn request_space(&mut self, usize)
Buffer attempts to clear space for additional items.
fn consume(&self, items: usize)
Consumes the given amount of bytes, must be less than or equal to len()
.
Does not invalidate any borrow of data from self.
fn len(&self) -> usize
Returns the number of bytes left in the buffer.
fn capacity(&self) -> usize
Returns the maximum amount of data which can be stored
Provided Methods
Implementors
impl<I: Copy> Buffer<I> for FixedSizeBuffer<I>
impl<I: Copy> Buffer<I> for GrowingBuffer<I>