diff options
author | Colin Finck <colin@reactos.org> | 2021-12-15 22:06:35 +0300 |
---|---|---|
committer | Colin Finck <colin@reactos.org> | 2021-12-15 22:06:35 +0300 |
commit | 5ff15ae17d618f846176ab40140c4141aab24bbb (patch) | |
tree | a23951f8c4b538ed628c2d159e2b13d8429f7511 /src/traits.rs | |
parent | 14b8be0c9ab74257738cb36d7683386604c4bbac (diff) |
Add the missing documentation and some final polishing.
Diffstat (limited to 'src/traits.rs')
-rw-r--r-- | src/traits.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/traits.rs b/src/traits.rs index 150e150..0a9f202 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -2,11 +2,18 @@ use crate::error::{NtfsError, Result}; use binread::io; use binread::io::{Read, Seek, SeekFrom}; +/// Trait to read/seek in a source by the help of a temporarily passed mutable reference to the filesystem reader. +/// +/// By requiring the user to pass the filesystem reader on every read, we circumvent the problems associated with permanently +/// holding a mutable reference. +/// If we held one, we could not read from two objects in alternation. pub trait NtfsReadSeek { + /// See [`std::io::Read::read`]. fn read<T>(&mut self, fs: &mut T, buf: &mut [u8]) -> Result<usize> where T: Read + Seek; + /// See [`std::io::Read::read_exact`]. fn read_exact<T>(&mut self, fs: &mut T, mut buf: &mut [u8]) -> Result<()> where T: Read + Seek, @@ -34,6 +41,7 @@ pub trait NtfsReadSeek { } } + /// See [`std::io::Seek::seek`]. fn seek<T>(&mut self, fs: &mut T, pos: SeekFrom) -> Result<u64> where T: Read + Seek; |