Skip to main content

ReadAdapter

Struct ReadAdapter 

Source
pub struct ReadAdapter<R: ?Sized>(/* private fields */);
Expand description

Reader adapter over any std::io::Read source.

Wraps any R: std::io::Read and exposes it as a wincode Reader, allowing deserialization from files, network streams, or other I/O sources.

§Examples

Deserialize a tuple via ReadAdapter:

use wincode::io::std_read::ReadAdapter;

let tuple = (42u32, true, 1234567890i64);
let buf = wincode::serialize(&tuple).unwrap();
let reader = ReadAdapter::new(&buf[..]);
let out: (u32, bool, i64) = wincode::deserialize_from(reader).unwrap();
assert_eq!(out, tuple);

Implementations§

Source§

impl<R: Read> ReadAdapter<R>

Source

pub fn new(inner: R) -> Self

Trait Implementations§

Source§

impl<R: Read + ?Sized> Reader<'_> for ReadAdapter<R>

Source§

fn copy_into_slice(&mut self, dst: &mut [u8]) -> ReadResult<()>

Attempts to copy and consume exactly dst.len() bytes. Read more
Source§

const BORROW_KINDS: u8 = 0

Borrow capabilities of this reader. Read more
Source§

fn supports_borrow(&self, kind: BorrowKind) -> bool

Checks if this reader supports the given borrow kind. Read more
Source§

fn take_array<const N: usize>(&mut self) -> ReadResult<[u8; N]>

Return exactly N bytes as [u8; N] and advance by N. Read more
Source§

fn take_byte(&mut self) -> ReadResult<u8>

Return the next byte and advance by 1. Read more
Source§

fn take_borrowed(&mut self, len: usize) -> ReadResult<&'a [u8]>

Return a borrowed slice of exactly len bytes and advance the reader by len. Read more
Source§

fn take_borrowed_mut(&mut self, len: usize) -> ReadResult<&'a mut [u8]>

Return a mutably borrowed slice of exactly len bytes and advance the reader by len. Read more
Source§

fn take_scoped(&mut self, len: usize) -> ReadResult<&[u8]>

Return a call-site scoped slice of exactly len bytes and advance by len. Read more
Source§

unsafe fn as_trusted_for( &mut self, n_bytes: usize, ) -> ReadResult<impl Reader<'a>>

Advance the parent by n_bytes and return a Reader that can elide bounds checks within that n_bytes window. Read more
Source§

unsafe fn as_trusted_for_seq( &mut self, len: usize, size: usize, ) -> Result<impl Reader<'a>, ReadError>

Construct a trusted window for a sequence of length len and serialized element size size. Read more
Source§

fn by_ref(&mut self) -> impl Reader<'a>

Get a mutable reference to the Reader. Read more
Source§

fn copy_into_uninit_slice( &mut self, dst: &mut [MaybeUninit<u8>], ) -> ReadResult<()>

Attempts to copy and consume exactly dst.len() bytes into potentially uninitialized storage. Read more
Source§

unsafe fn copy_into_t<T>(&mut self, dst: &mut MaybeUninit<T>) -> ReadResult<()>

Attempts to copy and consume exactly size_of::<T>() bytes from the Reader into dst. Read more
Source§

unsafe fn copy_into_slice_t<T>( &mut self, dst: &mut [MaybeUninit<T>], ) -> ReadResult<()>

Attempts to copy and consume exactly dst.len() * size_of::<T>() bytes from the Reader into dst. Read more

Auto Trait Implementations§

§

impl<R> Freeze for ReadAdapter<R>
where R: Freeze + ?Sized,

§

impl<R> RefUnwindSafe for ReadAdapter<R>
where R: RefUnwindSafe + ?Sized,

§

impl<R> Send for ReadAdapter<R>
where R: Send + ?Sized,

§

impl<R> Sync for ReadAdapter<R>
where R: Sync + ?Sized,

§

impl<R> Unpin for ReadAdapter<R>
where R: Unpin + ?Sized,

§

impl<R> UnsafeUnpin for ReadAdapter<R>
where R: UnsafeUnpin + ?Sized,

§

impl<R> UnwindSafe for ReadAdapter<R>
where R: UnwindSafe + ?Sized,

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