Skip to content

Commit ef6d366

Browse files
committed
Add clear method to bufferfish
1 parent 56c556d commit ef6d366

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

  • rust/bufferfish-core/src

rust/bufferfish-core/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,13 @@ impl Bufferfish {
239239
self.reading = true;
240240
}
241241

242+
/// Clears the buffer and resets the cursor to the start position.
243+
pub fn clear(&mut self) {
244+
self.inner.get_mut().clear();
245+
self.inner.set_position(0);
246+
self.reading = false;
247+
}
248+
242249
/// Returns a `Vec<u8>` of the internal byte buffer.
243250
pub fn into_vec(self) -> Vec<u8> {
244251
self.inner.into_inner()

0 commit comments

Comments
 (0)