Skip to main content

TextOut

Trait TextOut 

Source
pub trait TextOut {
    // Required methods
    fn write_str(&mut self, s: &str) -> Result<(), Fail>;
    fn flush(&mut self) -> Result<(), Fail>;

    // Provided method
    fn has_committed(&self) -> bool { ... }
}
Expand description

The fragment boundary every renderer writes to, which is one of alchemy’s shared types. A consumer of text fragments.

Fragments arrive in order and are concatenated; where the boundaries fall carries no meaning. flush pushes everything held so far to the final destination, and a renderer calls it exactly once, at the end of the protocol it renders, so that a document that failed half way is not flushed as if it were whole.

Required Methods§

Source

fn write_str(&mut self, s: &str) -> Result<(), Fail>

Source

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

Provided Methods§

Source

fn has_committed(&self) -> bool

Whether any text has reached the final destination, so that a failure found now leaves partial output behind. A renderer asks this when it fails and reports committed_output from the answer, which is how a host knows to print output: "partial" rather than "none". The default is the conservative answer for an output that cannot tell: whatever the renderer handed over may be out. render’s WriteOut answers exactly, from the bytes its writer received; a fragment that is still buffered is not committed, and into_inner drops it rather than sending it after the fact.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<O> TextOut for &mut O
where O: TextOut + ?Sized,

Source§

fn write_str(&mut self, s: &str) -> Result<(), Fail>

Source§

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

Source§

fn has_committed(&self) -> bool

Source§

impl<O> TextOut for Box<O>
where O: TextOut + ?Sized,

Source§

fn write_str(&mut self, s: &str) -> Result<(), Fail>

Source§

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

Source§

fn has_committed(&self) -> bool

Implementors§