[][src]Trait stringio::write::StrWrite

pub trait StrWrite {
    fn write(&mut self, buf: &str) -> Result<usize>;
fn flush(&mut self) -> Result<()>;
fn write_fmt(&mut self, args: Arguments) -> Result<()>; fn write_all(&mut self, buf: &str) -> Result<()> { ... }
fn by_ref(&mut self) -> &mut Self { ... } }

This trait is designed to provide a similar interface to io::Write, but is designed to operate on strings. Unlike fmt::Write, it can report partial writes, but it guarantees that a whole number of code points were written with every write. Generally this involves buffering partial code points as necessary.

Required methods

fn write(&mut self, buf: &str) -> Result<usize>

Write a str to the writer. Like io::Write::write, this function returns the number of bytes written; it additionally guarantees that the number of written bytes encompasses a whole number of code points. Like with io::Write, it also guarantees that errors mean that 0 bytes were written, and that the write can therefore (potentially) be retried.

fn flush(&mut self) -> Result<()>

Flush this output stream, ensuring that all intermediately buffered contents reach their destination.

fn write_fmt(&mut self, args: Arguments) -> Result<()>

Write some format arguments to the stream. This makes StrWrite compatible with write!, println!, etc.

Loading content...

Provided methods

fn write_all(&mut self, buf: &str) -> Result<()>

Continuously write buf to the stream until either the whole thing is written or an error occurs. An implementation of this function is provided by default, which calls write in a loop, but in general implementors should wrap the underlying write_all method, if available.

fn by_ref(&mut self) -> &mut Self

Get a mutable reference to this writer

Loading content...

Implementors

impl<'a, T: Write> StrWrite for T[src]

fn write_all(&mut self, buf: &str) -> Result<()>[src]

fn by_ref(&mut self) -> &mut Self[src]

impl<W: Write> StrWrite for StrWriter<W>[src]

fn by_ref(&mut self) -> &mut Self[src]

Loading content...