-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4cff9c4
commit d4b351e
Showing
7 changed files
with
163 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use crate::disktree::dptr::Dp; | ||
|
||
pub(crate) trait DtSeek { | ||
fn pos(&mut self) -> std::io::Result<Dp>; | ||
|
||
fn seek(&mut self, dp: Dp) -> std::io::Result<Dp>; | ||
|
||
fn fast_forward(&mut self) -> std::io::Result<Dp>; | ||
} | ||
|
||
impl<S> DtSeek for S | ||
where | ||
S: std::io::Seek, | ||
{ | ||
fn pos(&mut self) -> std::io::Result<Dp> { | ||
self.stream_position().map(Dp::from) | ||
} | ||
|
||
fn seek(&mut self, dp: Dp) -> std::io::Result<Dp> { | ||
self.seek(std::io::SeekFrom::Start(dp.into())).map(Dp::from) | ||
} | ||
|
||
fn fast_forward(&mut self) -> std::io::Result<Dp> { | ||
self.seek(std::io::SeekFrom::End(0)).map(Dp::from) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.