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

source

pub fn stream_file_chunks( &self ) -> impl Iterator<Item = Result<OwnedBytes>> + '_

source§

impl FileSlice

source

pub fn new(file_handle: Arc<dyn FileHandle>) -> Self

Wraps a FileHandle.

source

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.

source

pub fn empty() -> FileSlice

Creates an empty FileSlice

source

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.

source

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().

source

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.

source

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..].

source

pub fn slice_from(&self, from_offset: usize) -> FileSlice

Like .slice(...) but enforcing only the from boundary.

Equivalent to .slice(from_offset, self.len())

source

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())

source

pub fn slice_to(&self, to_offset: usize) -> FileSlice

Like .slice(...) but enforcing only the to boundary.

Equivalent to .slice(0, to_offset)

source

pub fn num_bytes(&self) -> ByteCount

Returns the byte count of the FileSlice.

Trait Implementations§

source§

impl Clone for FileSlice

source§

fn clone(&self) -> FileSlice

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for FileSlice

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl FileHandle for FileSlice

source§

fn read_bytes(&self, range: Range<usize>) -> Result<OwnedBytes>

Reads a slice of bytes. Read more
source§

impl<B> From<B> for FileSlice
where B: StableDeref + Deref<Target = [u8]> + 'static + Send + Sync,

source§

fn from(bytes: B) -> FileSlice

Converts to this type from the input type.
source§

impl HasLen for FileSlice

source§

fn len(&self) -> usize

Return length
source§

fn is_empty(&self) -> bool

Returns true iff empty.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.