pub struct WriteAdapter<W: ?Sized>(/* private fields */);Expand description
Writer adapter over any std::io::Write sink.
Wraps any W: std::io::Write and exposes it as a wincode Writer, allowing
serialization into files, network streams, or other I/O sinks.
§Examples
Serialize a tuple into a Vec<u8> via WriteAdapter:
use wincode::{Serialize, io::{Writer, std_write::WriteAdapter}};
let tuple = (42u32, true, 1234567890i64);
let mut buf = Vec::new();
let mut writer = WriteAdapter::new(&mut buf);
<(u32, bool, i64)>::serialize_into(&mut writer, &tuple).unwrap();
writer.finish().unwrap();
assert_eq!(buf, wincode::serialize(&tuple).unwrap());Implementations§
Trait Implementations§
Source§impl<W: Write + ?Sized> Writer for WriteAdapter<W>
impl<W: Write + ?Sized> Writer for WriteAdapter<W>
Source§fn write(&mut self, src: &[u8]) -> WriteResult<()>
fn write(&mut self, src: &[u8]) -> WriteResult<()>
Write exactly
src.len() bytes from the given src into the writer.Source§fn finish(&mut self) -> WriteResult<()>
fn finish(&mut self) -> WriteResult<()>
Finalize the writer by performing any required cleanup or flushing. Read more
Source§unsafe fn as_trusted_for(&mut self, n_bytes: usize) -> WriteResult<impl Writer>
unsafe fn as_trusted_for(&mut self, n_bytes: usize) -> WriteResult<impl Writer>
Source§unsafe fn write_t<T: ?Sized>(&mut self, src: &T) -> WriteResult<()>
unsafe fn write_t<T: ?Sized>(&mut self, src: &T) -> WriteResult<()>
Write
T as bytes into the source. Read moreSource§unsafe fn write_slice_t<T>(&mut self, src: &[T]) -> WriteResult<()>
unsafe fn write_slice_t<T>(&mut self, src: &[T]) -> WriteResult<()>
Write
[T] as bytes into the source. Read moreAuto Trait Implementations§
impl<W> Freeze for WriteAdapter<W>
impl<W> RefUnwindSafe for WriteAdapter<W>where
W: RefUnwindSafe + ?Sized,
impl<W> Send for WriteAdapter<W>
impl<W> Sync for WriteAdapter<W>
impl<W> Unpin for WriteAdapter<W>
impl<W> UnsafeUnpin for WriteAdapter<W>where
W: UnsafeUnpin + ?Sized,
impl<W> UnwindSafe for WriteAdapter<W>where
W: UnwindSafe + ?Sized,
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