Trait SerdeExt

Source
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§

Source

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());
Source

fn pretty_print(&self)

Provided Methods§

Source

fn boxed(self) -> Box<dyn SerdeExt>
where Self: Sized + Serialize + 'static,

Implementors§

Source§

impl<T> SerdeExt for T
where T: ?Sized + Serialize,