hdfs_native::file

Struct FileReader

Source
pub struct FileReader { /* private fields */ }

Implementations§

Source§

impl FileReader

Source

pub fn file_length(&self) -> usize

Returns the total size of the file

Source

pub fn remaining(&self) -> usize

Returns the remaining bytes left based on the current cursor position.

Source

pub fn seek(&mut self, pos: usize)

Sets the cursor to the position. Panics if the position is beyond the end of the file

Source

pub fn tell(&self) -> usize

Returns the current cursor position in the file

Source

pub async fn read(&mut self, len: usize) -> Result<Bytes>

Read up to len bytes into a new Bytes object, advancing the internal position in the file. An empty Bytes object will be returned if the end of the file has been reached.

Source

pub async fn read_buf(&mut self, buf: &mut [u8]) -> Result<usize>

Read up to buf.len() bytes into the provided slice, advancing the internal position in the file. Returns the number of bytes that were read, or 0 if the end of the file has been reached.

Source

pub async fn read_range(&self, offset: usize, len: usize) -> Result<Bytes>

Read up to len bytes starting at offset into a new Bytes object. The returned buffer could be smaller than len if offset + len extends beyond the end of the file.

Panics if the requested range is outside of the file

Source

pub async fn read_range_buf(&self, buf: &mut [u8], offset: usize) -> Result<()>

Read file data into an existing buffer

Panics if the requested range is outside of the file

Source

pub fn read_range_stream( &self, offset: usize, len: usize, ) -> impl Stream<Item = Result<Bytes>>

Return a stream of Bytes objects containing the content of the file

Panics if the requested range is outside of the file

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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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

Source§

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T