Struct rubbl_core::io::AligningReader
source · pub struct AligningReader<R: Read> { /* private fields */ }
Expand description
This struct wraps a Read type to equip it with hooks to track its alignment — that is, how many bytes into the stream the read has progressed, and whether the current offset is an exact multiple of a certain number of bytes from the beginning.
Streams often have alignment requirements so that they can safely be mapped into in-memory data structures. In particular, this is the case for MIRIAD files.
Implementations§
source§impl<R: Read> AligningReader<R>
impl<R: Read> AligningReader<R>
sourcepub fn into_inner(self) -> R
pub fn into_inner(self) -> R
Consume this struct, returning the underlying inner reader.
sourcepub fn offset(&self) -> u64
pub fn offset(&self) -> u64
Return how many bytes we have read since this struct was created.
Note that this offset is tracked internally. If you open a file, read part of it, and then create an AligningReader, the returned offset will refer to the number of bytes read since creation, not the actual file position as understood by the underlying OS.
Trait Implementations§
source§impl<R: Read> Read for AligningReader<R>
impl<R: Read> Read for AligningReader<R>
source§fn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
1.36.0 · source§fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
read
, except that it reads into a slice of buffers. Read moresource§fn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
can_vector
)1.0.0 · source§fn read_to_end(&mut self, buf: &mut Vec<u8, Global>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8, Global>) -> Result<usize, Error>
buf
. Read more1.0.0 · source§fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
buf
. Read more1.6.0 · source§fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
buf
. Read moresource§fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
read_buf
)source§fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
read_buf
)cursor
. Read more1.0.0 · source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Read
. Read moreAuto Trait Implementations§
impl<R> RefUnwindSafe for AligningReader<R>where
R: RefUnwindSafe,
impl<R> Send for AligningReader<R>where
R: Send,
impl<R> Sync for AligningReader<R>where
R: Sync,
impl<R> Unpin for AligningReader<R>where
R: Unpin,
impl<R> UnwindSafe for AligningReader<R>where
R: UnwindSafe,
Blanket Implementations§
source§impl<R> EofReadExactExt for Rwhere
R: Read,
impl<R> EofReadExactExt for Rwhere
R: Read,
source§fn eof_read_exact<E>(&mut self, buf: &mut [u8]) -> Result<bool, E>where
E: From<Error>,
fn eof_read_exact<E>(&mut self, buf: &mut [u8]) -> Result<bool, E>where
E: From<Error>,
Read::read_exact
, except returns Ok(false) if EOF was
encountered at the first read attempt. Returns Ok(true) if everything
was OK and EOF has not yet been hit. Returns Err with an IoError with
a “kind” of UnexpectedEof if EOF was encountered somewhere in the
midst of the buffer.source§fn eof_read_be_i16<E>(&mut self) -> Result<Option<i16>, E>where
E: From<Error>,
fn eof_read_be_i16<E>(&mut self) -> Result<Option<i16>, E>where
E: From<Error>,
byteorder::ReadBytesExt::read_i16::<BigEndian>
, except returns
Some(n) on success and None if EOF was encountered at the first read
attempt.source§fn eof_read_be_i32<E>(&mut self) -> Result<Option<i32>, E>where
E: From<Error>,
fn eof_read_be_i32<E>(&mut self) -> Result<Option<i32>, E>where
E: From<Error>,
byteorder::ReadBytesExt::read_i32::<BigEndian>
, except returns
Some(n) on success and None if EOF was encountered at the first read
attempt.source§fn eof_read_be_i64<E>(&mut self) -> Result<Option<i64>, E>where
E: From<Error>,
fn eof_read_be_i64<E>(&mut self) -> Result<Option<i64>, E>where
E: From<Error>,
byteorder::ReadBytesExt::read_i64::<BigEndian>
, except returns
Some(n) on success and None if EOF was encountered at the first read
attempt.source§fn eof_read_be_f32<E>(&mut self) -> Result<Option<f32>, E>where
E: From<Error>,
fn eof_read_be_f32<E>(&mut self) -> Result<Option<f32>, E>where
E: From<Error>,
byteorder::ReadBytesExt::read_f32::<BigEndian>
, except returns
Some(n) on success and None if EOF was encountered at the first read
attempt.source§fn eof_read_be_f64<E>(&mut self) -> Result<Option<f64>, E>where
E: From<Error>,
fn eof_read_be_f64<E>(&mut self) -> Result<Option<f64>, E>where
E: From<Error>,
byteorder::ReadBytesExt::read_f64::<BigEndian>
, except returns
Some(n) on success and None if EOF was encountered at the first read
attempt.source§fn eof_read_be_c64<E>(&mut self) -> Result<Option<Complex<f32>>, E>where
E: From<Error>,
fn eof_read_be_c64<E>(&mut self) -> Result<Option<Complex<f32>>, E>where
E: From<Error>,
byteorder::ReadBytesExt::read_f32::<BigEndian>
, except it reads
two values and packs them into a Complex<f32>
, and returns Some(n)
on success and None if EOF was encountered at the first read attempt.
The real part comes before the imaginary part.source§impl<R> ReadBytesExt for Rwhere
R: Read + ?Sized,
impl<R> ReadBytesExt for Rwhere
R: Read + ?Sized,
source§fn read_u8(&mut self) -> Result<u8, Error>
fn read_u8(&mut self) -> Result<u8, Error>
source§fn read_i8(&mut self) -> Result<i8, Error>
fn read_i8(&mut self) -> Result<i8, Error>
source§fn read_u16<T>(&mut self) -> Result<u16, Error>where
T: ByteOrder,
fn read_u16<T>(&mut self) -> Result<u16, Error>where
T: ByteOrder,
source§fn read_i16<T>(&mut self) -> Result<i16, Error>where
T: ByteOrder,
fn read_i16<T>(&mut self) -> Result<i16, Error>where
T: ByteOrder,
source§fn read_u24<T>(&mut self) -> Result<u32, Error>where
T: ByteOrder,
fn read_u24<T>(&mut self) -> Result<u32, Error>where
T: ByteOrder,
source§fn read_i24<T>(&mut self) -> Result<i32, Error>where
T: ByteOrder,
fn read_i24<T>(&mut self) -> Result<i32, Error>where
T: ByteOrder,
source§fn read_u32<T>(&mut self) -> Result<u32, Error>where
T: ByteOrder,
fn read_u32<T>(&mut self) -> Result<u32, Error>where
T: ByteOrder,
source§fn read_i32<T>(&mut self) -> Result<i32, Error>where
T: ByteOrder,
fn read_i32<T>(&mut self) -> Result<i32, Error>where
T: ByteOrder,
source§fn read_u48<T>(&mut self) -> Result<u64, Error>where
T: ByteOrder,
fn read_u48<T>(&mut self) -> Result<u64, Error>where
T: ByteOrder,
source§fn read_i48<T>(&mut self) -> Result<i64, Error>where
T: ByteOrder,
fn read_i48<T>(&mut self) -> Result<i64, Error>where
T: ByteOrder,
source§fn read_u64<T>(&mut self) -> Result<u64, Error>where
T: ByteOrder,
fn read_u64<T>(&mut self) -> Result<u64, Error>where
T: ByteOrder,
source§fn read_i64<T>(&mut self) -> Result<i64, Error>where
T: ByteOrder,
fn read_i64<T>(&mut self) -> Result<i64, Error>where
T: ByteOrder,
source§fn read_u128<T>(&mut self) -> Result<u128, Error>where
T: ByteOrder,
fn read_u128<T>(&mut self) -> Result<u128, Error>where
T: ByteOrder,
source§fn read_i128<T>(&mut self) -> Result<i128, Error>where
T: ByteOrder,
fn read_i128<T>(&mut self) -> Result<i128, Error>where
T: ByteOrder,
source§fn read_uint<T>(&mut self, nbytes: usize) -> Result<u64, Error>where
T: ByteOrder,
fn read_uint<T>(&mut self, nbytes: usize) -> Result<u64, Error>where
T: ByteOrder,
source§fn read_int<T>(&mut self, nbytes: usize) -> Result<i64, Error>where
T: ByteOrder,
fn read_int<T>(&mut self, nbytes: usize) -> Result<i64, Error>where
T: ByteOrder,
source§fn read_uint128<T>(&mut self, nbytes: usize) -> Result<u128, Error>where
T: ByteOrder,
fn read_uint128<T>(&mut self, nbytes: usize) -> Result<u128, Error>where
T: ByteOrder,
source§fn read_int128<T>(&mut self, nbytes: usize) -> Result<i128, Error>where
T: ByteOrder,
fn read_int128<T>(&mut self, nbytes: usize) -> Result<i128, Error>where
T: ByteOrder,
source§fn read_f32<T>(&mut self) -> Result<f32, Error>where
T: ByteOrder,
fn read_f32<T>(&mut self) -> Result<f32, Error>where
T: ByteOrder,
source§fn read_f64<T>(&mut self) -> Result<f64, Error>where
T: ByteOrder,
fn read_f64<T>(&mut self) -> Result<f64, Error>where
T: ByteOrder,
source§fn read_u16_into<T>(&mut self, dst: &mut [u16]) -> Result<(), Error>where
T: ByteOrder,
fn read_u16_into<T>(&mut self, dst: &mut [u16]) -> Result<(), Error>where
T: ByteOrder,
source§fn read_u32_into<T>(&mut self, dst: &mut [u32]) -> Result<(), Error>where
T: ByteOrder,
fn read_u32_into<T>(&mut self, dst: &mut [u32]) -> Result<(), Error>where
T: ByteOrder,
source§fn read_u64_into<T>(&mut self, dst: &mut [u64]) -> Result<(), Error>where
T: ByteOrder,
fn read_u64_into<T>(&mut self, dst: &mut [u64]) -> Result<(), Error>where
T: ByteOrder,
source§fn read_u128_into<T>(&mut self, dst: &mut [u128]) -> Result<(), Error>where
T: ByteOrder,
fn read_u128_into<T>(&mut self, dst: &mut [u128]) -> Result<(), Error>where
T: ByteOrder,
source§fn read_i8_into(&mut self, dst: &mut [i8]) -> Result<(), Error>
fn read_i8_into(&mut self, dst: &mut [i8]) -> Result<(), Error>
source§fn read_i16_into<T>(&mut self, dst: &mut [i16]) -> Result<(), Error>where
T: ByteOrder,
fn read_i16_into<T>(&mut self, dst: &mut [i16]) -> Result<(), Error>where
T: ByteOrder,
source§fn read_i32_into<T>(&mut self, dst: &mut [i32]) -> Result<(), Error>where
T: ByteOrder,
fn read_i32_into<T>(&mut self, dst: &mut [i32]) -> Result<(), Error>where
T: ByteOrder,
source§fn read_i64_into<T>(&mut self, dst: &mut [i64]) -> Result<(), Error>where
T: ByteOrder,
fn read_i64_into<T>(&mut self, dst: &mut [i64]) -> Result<(), Error>where
T: ByteOrder,
source§fn read_i128_into<T>(&mut self, dst: &mut [i128]) -> Result<(), Error>where
T: ByteOrder,
fn read_i128_into<T>(&mut self, dst: &mut [i128]) -> Result<(), Error>where
T: ByteOrder,
source§fn read_f32_into<T>(&mut self, dst: &mut [f32]) -> Result<(), Error>where
T: ByteOrder,
fn read_f32_into<T>(&mut self, dst: &mut [f32]) -> Result<(), Error>where
T: ByteOrder,
source§fn read_f32_into_unchecked<T>(&mut self, dst: &mut [f32]) -> Result<(), Error>where
T: ByteOrder,
fn read_f32_into_unchecked<T>(&mut self, dst: &mut [f32]) -> Result<(), Error>where
T: ByteOrder,
read_f32_into
instead