Skip to content

Commit

Permalink
Merge pull request #595 from epage/reset
Browse files Browse the repository at this point in the history
feat(stream): Allow reseting streams to an absolute position
  • Loading branch information
epage committed Sep 24, 2024
2 parents efeda0f + 2dc8e72 commit 7a3675d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/stream/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,21 @@ where
}
}

impl<I> Located<I>
where
I: Clone + Stream + Offset,
{
/// Reset the stream to the start
///
/// This is useful for formats that encode a graph with addresses relative to the start of the
/// input.
#[doc(alias = "fseek")]
pub fn reset_to_start(&mut self) {
let start = self.initial.checkpoint();
self.input.reset(&start);
}
}

impl<I> AsRef<I> for Located<I> {
#[inline(always)]
fn as_ref(&self) -> &I {
Expand Down

0 comments on commit 7a3675d

Please sign in to comment.