Struct tantivy::directory::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, Error>>

source§

impl FileSlice

source

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

Wraps a FileHandle.

source

pub fn slice<R>(&self, byte_range: R) -> FileSlice
where R: RangeBounds<usize>,

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, Error>

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, Error>

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

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

impl FileHandle for FileSlice

source§

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

Reads a slice of bytes. Read more
source§

impl<B> From<B> for FileSlice
where B: StableDeref<Target = [u8]> + Deref + '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> Downcast for T
where T: Any,

source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
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> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
source§

impl<T> Fruit for T
where T: Send + Downcast,