pub struct DataStream<T> { /* private fields */ }Expand description
A stream that allows endian-aware read and write.
This struct is generic over any type T that implements some combination of
Read, Write, and Seek. Methods are conditionally available based on
the traits implemented by T.
Implementations§
Trait Implementations§
Source§impl<T: Debug> Debug for DataStream<T>
impl<T: Debug> Debug for DataStream<T>
Source§impl<T> Deref for DataStream<T>
impl<T> Deref for DataStream<T>
Source§impl<T> DerefMut for DataStream<T>
impl<T> DerefMut for DataStream<T>
Source§impl<T> EndianExt for DataStream<T>
impl<T> EndianExt for DataStream<T>
Source§impl<T: Read> ReadExt for DataStream<T>
impl<T: Read> ReadExt for DataStream<T>
Source§fn read_exact<const N: usize>(&mut self) -> Result<[u8; N], DataError>
fn read_exact<const N: usize>(&mut self) -> Result<[u8; N], DataError>
Reads exactly N bytes from the current stream. Read more
Source§fn read_length(&mut self, buffer: &mut [u8]) -> Result<usize, DataError>
fn read_length(&mut self, buffer: &mut [u8]) -> Result<usize, DataError>
Attempts to fill the buffer with data. Read more
Source§fn read_slice(&mut self, length: usize) -> Result<Cow<'_, [u8]>, DataError>
fn read_slice(&mut self, length: usize) -> Result<Cow<'_, [u8]>, DataError>
Reads a slice of the given length from the current position. Read more
Source§fn remaining_slice(&mut self) -> Result<Cow<'_, [u8]>, DataError>
fn remaining_slice(&mut self) -> Result<Cow<'_, [u8]>, DataError>
Returns the remaining data from the current position. Read more
Source§fn read_string(&mut self, length: usize) -> Result<Cow<'_, str>, DataError>
fn read_string(&mut self, length: usize) -> Result<Cow<'_, str>, DataError>
Reads a UTF-8 encoded string of the given length from the current position. Read more
Source§impl<T: Seek> SeekExt for DataStream<T>
impl<T: Seek> SeekExt for DataStream<T>
Source§fn len(&mut self) -> Result<u64, DataError>
fn len(&mut self) -> Result<u64, DataError>
Returns the total length of the data.
Note that this can be an expensive operation due to seeking. You should instead use something like
std::fs::Metadata::len.
§Errors
Returns an error if unable to determine the length of the stream.
Source§impl<T: Write> WriteExt for DataStream<T>
impl<T: Write> WriteExt for DataStream<T>
Source§fn write_exact<const N: usize>(
&mut self,
bytes: &[u8; N],
) -> Result<(), DataError>
fn write_exact<const N: usize>( &mut self, bytes: &[u8; N], ) -> Result<(), DataError>
Writes exactly N bytes to the current stream. Read more
Source§fn write_u8(&mut self, value: u8) -> Result<(), DataError>
fn write_u8(&mut self, value: u8) -> Result<(), DataError>
Writes an unsigned 8-bit integer. Read more
Source§fn write_i8(&mut self, value: i8) -> Result<(), DataError>
fn write_i8(&mut self, value: i8) -> Result<(), DataError>
Writes a signed 8-bit integer. Read more
Source§fn write_u16(&mut self, value: u16) -> Result<(), DataError>
fn write_u16(&mut self, value: u16) -> Result<(), DataError>
Writes an unsigned 16-bit integer. Read more
Source§fn write_i16(&mut self, value: i16) -> Result<(), DataError>
fn write_i16(&mut self, value: i16) -> Result<(), DataError>
Writes a signed 16-bit integer. Read more
Source§fn write_u32(&mut self, value: u32) -> Result<(), DataError>
fn write_u32(&mut self, value: u32) -> Result<(), DataError>
Writes an unsigned 32-bit integer. Read more
Source§fn write_i32(&mut self, value: i32) -> Result<(), DataError>
fn write_i32(&mut self, value: i32) -> Result<(), DataError>
Writes a signed 32-bit integer. Read more
Source§fn write_u64(&mut self, value: u64) -> Result<(), DataError>
fn write_u64(&mut self, value: u64) -> Result<(), DataError>
Writes an unsigned 64-bit integer. Read more
Source§fn write_i64(&mut self, value: i64) -> Result<(), DataError>
fn write_i64(&mut self, value: i64) -> Result<(), DataError>
Writes a signed 64-bit integer. Read more
Auto Trait Implementations§
impl<T> Freeze for DataStream<T>where
T: Freeze,
impl<T> RefUnwindSafe for DataStream<T>where
T: RefUnwindSafe,
impl<T> Send for DataStream<T>where
T: Send,
impl<T> Sync for DataStream<T>where
T: Sync,
impl<T> Unpin for DataStream<T>where
T: Unpin,
impl<T> UnwindSafe for DataStream<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more