Skip to main content

IntoWriter

Trait IntoWriter 

Source
pub trait IntoWriter
where Self: Sealed,
{ type Ok; type Writer: Writer<Ok = Self::Ok>; // Required method fn into_writer(self) -> Self::Writer; }
Expand description

Coerce a type into a Writer.

§Examples

use musli::{Context, IntoWriter, Writer};
use musli::context;

let mut buffer = Vec::new();
let mut writer = (&mut buffer).into_writer();
let cx = context::new();

writer.write_bytes(&cx, b"Hello")?;
writer.finish(&cx)?;

assert_eq!(buffer, b"Hello");

Required Associated Types§

Source

type Ok

The output of the writer which will be returned after writing.

Source

type Writer: Writer<Ok = Self::Ok>

The writer type.

Required Methods§

Source

fn into_writer(self) -> Self::Writer

Convert the type into a writer.

Implementations on Foreign Types§

Source§

impl<'a> IntoWriter for &'a mut [u8]

Source§

impl<'a, W> IntoWriter for &'a mut W
where W: ?Sized + Writer,

Source§

type Ok = <W as Writer>::Ok

Source§

type Writer = &'a mut W

Source§

fn into_writer(self) -> Self::Writer

Implementors§

Source§

impl<W> IntoWriter for Wrap<W>
where W: Write,

Available on crate feature std only.