Skip to main content

FileReader

Struct FileReader 

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

Type-erased byte input explicitly associated with an opened file.

Aggregate reads retry ordinary interruptions and typed interruptions whose effect is absent or FsEffectState::Unchanged. A typed interruption with another effect, or with a conflicting error kind, is returned with outer IoErrorKind::Other; its original FsError remains the direct error payload. A failed aggregate read may already have written bytes into its destination buffer; those bytes are not rolled back.

§Examples

The example runs against an isolated in-memory fixture. Applications obtain their configured facade from a provider or registry integration.

use qubit_fs::Path;
use qubit_fs::read::ReadOptions;
use qubit_io::Input;

let mut reader = filesystem.open_reader(&Path::parse("/report")?, ReadOptions::default())?;
let mut prefix = [0; 3];
assert_eq!(3, reader.read_fully(&mut prefix)?);
assert_eq!(*b"rep", prefix);

Implementations§

Source§

impl FileReader

Source

pub fn info(&self) -> &OpenedFileInfo

Returns the fixed identity and open-time metadata snapshot.

§Returns

Information captured when the reader was opened.

Trait Implementations§

Source§

impl Debug for FileReader

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> FmtResult

Formats the reader’s stable file information without exposing its input.

§Parameters
  • formatter: Destination for the debug representation.
Source§

impl Input for FileReader

Source§

type Item = u8

Byte value yielded by this synchronous reader.

Source§

fn is_buffered(&self) -> bool

Reports whether the wrapped byte input can satisfy reads from its buffer.

Source§

unsafe fn read_unchecked( &mut self, output: &mut [u8], index: usize, count: usize, ) -> IoResult<usize>

Reads the requested byte range under the caller’s Input safety contract.

§Parameters
  • output: Caller-owned destination buffer.
  • index: Start index of the requested output range.
  • count: Number of bytes requested from that range.
§Safety

index..index + count must be a valid range within output, and the addition must not overflow.

Source§

fn into_std_read(self) -> StdRead<Self> ⓘ
where Self: Sized + ByteInput,

Converts this byte input into a standard library reader. Read more
Source§

fn read(&mut self, output: &mut [Self::Item]) -> Result<usize, Error>

Reads items into the full output slice. Read more
Source§

unsafe fn read_fully_unchecked( &mut self, output: &mut [Self::Item], index: usize, count: usize, ) -> Result<usize, Error>

Reads items into an indexed output range until it is full or EOF is reached. Read more
Source§

fn read_fully(&mut self, output: &mut [Self::Item]) -> Result<usize, Error>

Reads items into the full output slice until it is full or EOF is reached. Read more
Source§

fn read_exactly(&mut self, output: &mut [Self::Item]) -> Result<(), Error>

Reads items until the full output slice is filled. Read more
Source§

fn read_vectored( &mut self, buffers: &mut [&mut [Self::Item]], ) -> Result<usize, Error>

Reads items into multiple buffers in list order. Read more

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> ByteInput for T
where T: Input<Item = u8> + ?Sized,

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.