Trait chomp::buffer::Buffer [] [src]

pub trait Buffer<I: Copy + PartialEq>: 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

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.

Buffer attempts to clear space for additional items.

Consumes the given amount of bytes, must be less than or equal to len().

Does not invalidate any borrow of data from self.

Returns the number of bytes left in the buffer.

Returns the maximum amount of data which can be stored

Provided Methods

If the buffer has no more data.

Implementors