pub struct WordAdapter<W: UnsignedInt + FromBytes + ToBytes, B> { /* private fields */ }
Expand description
An adapter from Read
, Write
, and Seek
, to WordRead
,
WordWrite
, and WordSeek
, respectively.
Instances of this struct can be created using WordAdapter::new
. They
turn every standard (possibly seekable) source or destination of bytes (such
as std::fs::File
, std::io::BufReader
, sockets, etc.) into a source
or destination of words.
Due to the necessity of managing files whose length is not a multiple of the
word length, read_word
will return a partially
read word extended with zeros at the end of such files.
To provide a sensible value after such a read,
word_pos
will always return the position
of the underlying Seek
rounded up to the next multiple of W::Bytes
.
This approach, however, requires that if you adapt a Seek
, its current position must be
a multiple of W::Bytes
, or the results of word_pos
will be shifted by the rounding.
Implementations§
Source§impl<W: UnsignedInt + FromBytes + ToBytes, B> WordAdapter<W, B>
impl<W: UnsignedInt + FromBytes + ToBytes, B> WordAdapter<W, B>
pub fn into_inner(self) -> B
Trait Implementations§
Source§impl<W: Clone + UnsignedInt + FromBytes + ToBytes, B: Clone> Clone for WordAdapter<W, B>
impl<W: Clone + UnsignedInt + FromBytes + ToBytes, B: Clone> Clone for WordAdapter<W, B>
Source§fn clone(&self) -> WordAdapter<W, B>
fn clone(&self) -> WordAdapter<W, B>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<W: UnsignedInt + FromBytes + ToBytes, B> CopyType for WordAdapter<W, B>
impl<W: UnsignedInt + FromBytes + ToBytes, B> CopyType for WordAdapter<W, B>
Source§impl<W: Debug + UnsignedInt + FromBytes + ToBytes, B: Debug> Debug for WordAdapter<W, B>
impl<W: Debug + UnsignedInt + FromBytes + ToBytes, B: Debug> Debug for WordAdapter<W, B>
Source§impl<W: UnsignedInt + FromBytes + ToBytes, B> MemDbgImpl for WordAdapter<W, B>
impl<W: UnsignedInt + FromBytes + ToBytes, B> MemDbgImpl for WordAdapter<W, B>
fn _mem_dbg_rec_on( &self, _memdbg_writer: &mut impl Write, _memdbg_total_size: usize, _memdbg_max_depth: usize, _memdbg_prefix: &mut String, _memdbg_is_last: bool, _memdbg_flags: DbgFlags, ) -> Result
fn _mem_dbg_depth_on( &self, writer: &mut impl Write, total_size: usize, max_depth: usize, prefix: &mut String, field_name: Option<&str>, is_last: bool, padded_size: usize, flags: DbgFlags, ) -> Result<(), Error>
Source§impl<W: UnsignedInt + FromBytes + ToBytes, B> MemSize for WordAdapter<W, B>
impl<W: UnsignedInt + FromBytes + ToBytes, B> MemSize for WordAdapter<W, B>
Source§impl<W: UnsignedInt + ToBytes + FromBytes + FiniteRangeNumber, B: Read> WordRead for WordAdapter<W, B>
impl<W: UnsignedInt + ToBytes + FromBytes + FiniteRangeNumber, B: Read> WordRead for WordAdapter<W, B>
Source§impl<W: UnsignedInt + ToBytes + FromBytes + FiniteRangeNumber, B: Seek> WordSeek for WordAdapter<W, B>
impl<W: UnsignedInt + ToBytes + FromBytes + FiniteRangeNumber, B: Seek> WordSeek for WordAdapter<W, B>
Source§impl<W: UnsignedInt + ToBytes + FromBytes + FiniteRangeNumber, B: Write> WordWrite for WordAdapter<W, B>
impl<W: UnsignedInt + ToBytes + FromBytes + FiniteRangeNumber, B: Write> WordWrite for WordAdapter<W, B>
Auto Trait Implementations§
impl<W, B> Freeze for WordAdapter<W, B>where
B: Freeze,
impl<W, B> RefUnwindSafe for WordAdapter<W, B>where
B: RefUnwindSafe,
W: RefUnwindSafe,
impl<W, B> Send for WordAdapter<W, B>where
B: Send,
impl<W, B> Sync for WordAdapter<W, B>where
B: Sync,
impl<W, B> Unpin for WordAdapter<W, B>
impl<W, B> UnwindSafe for WordAdapter<W, B>where
B: UnwindSafe,
W: 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
Source§impl<T, U> CastableInto<U> for Twhere
U: CastableFrom<T>,
impl<T, U> CastableInto<U> for Twhere
U: CastableFrom<T>,
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DowncastableFrom<T> for T
impl<T> DowncastableFrom<T> for T
Source§fn downcast_from(value: T) -> T
fn downcast_from(value: T) -> T
Source§impl<T, U> DowncastableInto<U> for Twhere
U: DowncastableFrom<T>,
impl<T, U> DowncastableInto<U> for Twhere
U: DowncastableFrom<T>,
Source§impl<T> MemDbg for Twhere
T: MemDbgImpl,
impl<T> MemDbg for Twhere
T: MemDbgImpl,
Source§fn mem_dbg(&self, flags: DbgFlags) -> Result<(), Error>
fn mem_dbg(&self, flags: DbgFlags) -> Result<(), Error>
Source§fn mem_dbg_on(
&self,
writer: &mut impl Write,
flags: DbgFlags,
) -> Result<(), Error>
fn mem_dbg_on( &self, writer: &mut impl Write, flags: DbgFlags, ) -> Result<(), Error>
core::fmt::Write
debug infos about the structure memory
usage, expanding all levels of nested structures.Source§fn mem_dbg_depth(&self, max_depth: usize, flags: DbgFlags) -> Result<(), Error>
fn mem_dbg_depth(&self, max_depth: usize, flags: DbgFlags) -> Result<(), Error>
mem_dbg
, but expanding only up to max_depth
levels of nested structures.Source§fn mem_dbg_depth_on(
&self,
writer: &mut impl Write,
max_depth: usize,
flags: DbgFlags,
) -> Result<(), Error>
fn mem_dbg_depth_on( &self, writer: &mut impl Write, max_depth: usize, flags: DbgFlags, ) -> Result<(), Error>
core::fmt::Write
debug infos about the structure memory
usage as mem_dbg_on
, but expanding only up to
max_depth
levels of nested structures.