Macro convey::render_json
source · macro_rules! render_json {
() => { ... };
}
Expand description
Shorthand for writing the render_json
method of the Render
trait
Examples
#[macro_use] extern crate convey;
#[macro_use] extern crate serde_derive;
#[derive(Serialize)]
struct Message {
author: String,
body: String,
}
impl convey::Render for Message {
// Look at the `human` module if you care about those meat bags.
render_for_humans!(this -> []);
// We're lucky, or type implements `Serialize`. Nothing to do!
render_json!();
}
fn main() -> Result<(), convey::Error> {
let mut out = convey::new().add_target(convey::human::stdout()?)?;
out.print(Message { author: "Pascal".into(), body: "Lorem ipsum dolor".into() })?;
Ok(())
}