pub trait SerdeExt {
// Required methods
fn pretty_string(&self) -> String;
fn pretty_print(&self);
// Provided method
fn boxed(self) -> Box<dyn SerdeExt>
where Self: Sized + Serialize + 'static { ... }
}Expand description
SerdeExt trait to convert any Serializable struct to json string.
Required Methods§
Sourcefn pretty_string(&self) -> String
fn pretty_string(&self) -> String
Converts a serializable struct to pretty json Fails in case the serde fails to convert it to pretty string.
use serde::Serialize;
use schema_registry_client::prelude::*;
#[derive(Serialize)]
pub struct Test{
pub name: String
}
let test = Test{name:"degauss".to_string()};
println!("{}", test.pretty_string());