Trait convey::Render

source ·
pub trait Render {
    fn render_for_humans(&self, fmt: &mut Formatter) -> Result<(), Error>;
    fn render_json(&self, fmt: &mut Formatter) -> Result<(), Error>;
}
Expand description

Implement this for your own components

Required Methods

How to render your type for humans

How to render your type to JSON

If your type implements Serialize, this can easily just be fmt.write(self). Alternatively, you might want to use something like serde_json’s json! macro.

Implementations on Foreign Types

Render automatically works with references

Examples

let mut out = convey::new().add_target(test_target.target())?;
out.print(text("owned element"))?;
out.print(&text("reference to an element"))?;

Render a string slice

Examples

let mut out = convey::new().add_target(test_target.target())?;
out.print("Hello, World!")?;

Render a string

Examples

let mut out = convey::new().add_target(test_target.target())?;
out.print(String::from("Hello, World!"))?;

Implementors