pub struct IoEncoder<W: Write> { /* private fields */ }Available on crate feature
std only.Expand description
Streaming encoder that writes directly into any Write-shaped sink.
Each IoEncoder::write call calls into the underlying writer for the
bytes the type produces. The encoder does not buffer; if you wrap a
raw socket / file, wrap it in a std::io::BufWriter first.
§Examples
use pack_io::IoEncoder;
let mut sink: Vec<u8> = Vec::new();
let mut enc = IoEncoder::new(&mut sink);
enc.write(&42_u64).unwrap();
enc.write(&"hello").unwrap();
assert!(!sink.is_empty());Implementations§
Source§impl<W: Write> IoEncoder<W>
impl<W: Write> IoEncoder<W>
Sourcepub fn writer_mut(&mut self) -> &mut W
pub fn writer_mut(&mut self) -> &mut W
Borrow the underlying writer mutably.
Sourcepub fn into_inner(self) -> W
pub fn into_inner(self) -> W
Consume the encoder and return the underlying writer.
Trait Implementations§
Auto Trait Implementations§
impl<W> Freeze for IoEncoder<W>where
W: Freeze,
impl<W> RefUnwindSafe for IoEncoder<W>where
W: RefUnwindSafe,
impl<W> Send for IoEncoder<W>where
W: Send,
impl<W> Sync for IoEncoder<W>where
W: Sync,
impl<W> Unpin for IoEncoder<W>where
W: Unpin,
impl<W> UnsafeUnpin for IoEncoder<W>where
W: UnsafeUnpin,
impl<W> UnwindSafe for IoEncoder<W>where
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
Mutably borrows from an owned value. Read more