Struct Writer

struct Writer<B> { ... }

A BufMut adapter which implements io::Write for the inner value.

This struct is generally created by calling writer() on BufMut. See documentation of writer() for more details.

Implementations

impl<B: BufMut> Writer<B>

fn get_ref(self: &Self) -> &B

Gets a reference to the underlying BufMut.

It is inadvisable to directly write to the underlying BufMut.

Examples

use bytes::BufMut;

let buf = Vec::with_capacity(1024).writer();

assert_eq!(1024, buf.get_ref().capacity());
fn get_mut(self: &mut Self) -> &mut B

Gets a mutable reference to the underlying BufMut.

It is inadvisable to directly write to the underlying BufMut.

Examples

use bytes::BufMut;

let mut buf = vec![].writer();

buf.get_mut().reserve(1024);

assert_eq!(1024, buf.get_ref().capacity());
fn into_inner(self: Self) -> B

Consumes this Writer, returning the underlying value.

Examples

use bytes::BufMut;
use std::io;

let mut buf = vec![].writer();
let mut src = &b"hello world"[..];

io::copy(&mut src, &mut buf).unwrap();

let buf = buf.into_inner();
assert_eq!(*buf, b"hello world"[..]);

impl<B> Freeze for Writer<B>

impl<B> RefUnwindSafe for Writer<B>

impl<B> Send for Writer<B>

impl<B> Sync for Writer<B>

impl<B> Unpin for Writer<B>

impl<B> UnsafeUnpin for Writer<B>

impl<B> UnwindSafe for Writer<B>

impl<B: $crate::fmt::Debug> Debug for Writer<B>

fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result

impl<B: BufMut + Sized> Write for Writer<B>

fn write(self: &mut Self, src: &[u8]) -> Result<usize>
fn flush(self: &mut Self) -> Result<()>

impl<T> Any for Writer<B>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for Writer<B>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for Writer<B>

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> From for Writer<B>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into for Writer<B>

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for Writer<B>

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for Writer<B>

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>