pub struct DiskFileAccess { /* private fields */ }Expand description
A FileAccess implementation that reads and writes files on disk.
Files are located by combining a base directory with the filename from the
PAR2 file descriptions. The mapping from FileId to filename is built
from the Par2FileSet at construction time.
Implementations§
Source§impl DiskFileAccess
impl DiskFileAccess
Sourcepub fn new(base_dir: PathBuf, par2_set: &Par2FileSet) -> Self
pub fn new(base_dir: PathBuf, par2_set: &Par2FileSet) -> Self
Create a new DiskFileAccess from a base directory and a PAR2 file set.
Builds the internal file map from the file descriptions in the PAR2 set.
Trait Implementations§
Source§impl FileAccess for DiskFileAccess
impl FileAccess for DiskFileAccess
Source§fn read_file_range(
&self,
file_id: &FileId,
offset: u64,
len: u64,
) -> Result<Vec<u8>>
fn read_file_range( &self, file_id: &FileId, offset: u64, len: u64, ) -> Result<Vec<u8>>
Read a range of bytes from a file identified by its FileId.
Source§fn read_file_range_into(
&self,
file_id: &FileId,
offset: u64,
dst: &mut [u8],
) -> Result<usize>
fn read_file_range_into( &self, file_id: &FileId, offset: u64, dst: &mut [u8], ) -> Result<usize>
Read bytes into a caller-provided buffer, returning the number of bytes read.
Source§fn open_sequential_reader(
&self,
file_id: &FileId,
) -> Result<Option<Box<dyn Read>>>
fn open_sequential_reader( &self, file_id: &FileId, ) -> Result<Option<Box<dyn Read>>>
Open a forward-only reader for hot paths that consume a whole file from offset 0.
Source§fn open_range_reader(
&self,
file_id: &FileId,
) -> Result<Option<Box<dyn FileRangeReader>>>
fn open_range_reader( &self, file_id: &FileId, ) -> Result<Option<Box<dyn FileRangeReader>>>
Open a reusable seekable reader for range-oriented repair input.
Source§fn file_exists(&self, file_id: &FileId) -> bool
fn file_exists(&self, file_id: &FileId) -> bool
Check if a file exists on disk.
Auto Trait Implementations§
impl Freeze for DiskFileAccess
impl RefUnwindSafe for DiskFileAccess
impl Send for DiskFileAccess
impl Sync for DiskFileAccess
impl Unpin for DiskFileAccess
impl UnsafeUnpin for DiskFileAccess
impl UnwindSafe for DiskFileAccess
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more