Struct tantivy_common::file_slice::FileSlice
source · pub struct FileSlice { /* private fields */ }
Expand description
Logical slice of read only file in tantivy.
It can be cloned and sliced cheaply.
Implementations§
source§impl FileSlice
impl FileSlice
pub fn stream_file_chunks( &self ) -> impl Iterator<Item = Result<OwnedBytes>> + '_
source§impl FileSlice
impl FileSlice
sourcepub fn new(file_handle: Arc<dyn FileHandle>) -> Self
pub fn new(file_handle: Arc<dyn FileHandle>) -> Self
Wraps a FileHandle.
sourcepub fn slice<R: RangeBounds<usize>>(&self, byte_range: R) -> FileSlice
pub fn slice<R: RangeBounds<usize>>(&self, byte_range: R) -> FileSlice
Creates a fileslice that is just a view over a slice of the data.
§Panics
Panics if byte_range.end
exceeds the filesize.
sourcepub fn read_bytes(&self) -> Result<OwnedBytes>
pub fn read_bytes(&self) -> Result<OwnedBytes>
Returns a OwnedBytes
with all of the data in the FileSlice
.
The behavior is strongly dependent on the implementation of the underlying
Directory
and the FileSliceTrait
it creates.
In particular, it is up to the Directory
implementation
to handle caching if needed.
sourcepub fn read_bytes_slice(&self, range: Range<usize>) -> Result<OwnedBytes>
pub fn read_bytes_slice(&self, range: Range<usize>) -> Result<OwnedBytes>
Reads a specific slice of data.
This is equivalent to running file_slice.slice(from, to).read_bytes()
.
sourcepub fn split(self, left_len: usize) -> (FileSlice, FileSlice)
pub fn split(self, left_len: usize) -> (FileSlice, FileSlice)
Splits the FileSlice at the given offset and return two file slices.
file_slice[..split_offset]
and file_slice[split_offset..]
.
This operation is cheap and must not copy any underlying data.
sourcepub fn split_from_end(self, right_len: usize) -> (FileSlice, FileSlice)
pub fn split_from_end(self, right_len: usize) -> (FileSlice, FileSlice)
Splits the file slice at the given offset and return two file slices.
file_slice[..split_offset]
and file_slice[split_offset..]
.
sourcepub fn slice_from(&self, from_offset: usize) -> FileSlice
pub fn slice_from(&self, from_offset: usize) -> FileSlice
Like .slice(...)
but enforcing only the from
boundary.
Equivalent to .slice(from_offset, self.len())
sourcepub fn slice_from_end(&self, from_offset: usize) -> FileSlice
pub fn slice_from_end(&self, from_offset: usize) -> FileSlice
Returns a slice from the end.
Equivalent to .slice(self.len() - from_offset, self.len())