Trait ToJson

Source
pub trait ToJson {
    type Kind: JsonValueKind;

    // Required method
    fn json_encode__jsony(&self, output: &mut TextWriter<'_>) -> Self::Kind;
}
Expand description

A trait for converting a value into JSON.

Required Associated Types§

Source

type Kind: JsonValueKind

Represents the kind of JSON value that will be produced.

This can be a string, object, array, or any value that could be one of those or a scalar (e.g., number).

Required Methods§

Source

fn json_encode__jsony(&self, output: &mut TextWriter<'_>) -> Self::Kind

Converts self to JSON and appends it to the given TextWriter. Note: this method is prefixed to avoid collisions in macros that that invoke it via method resolution.

Implementations on Foreign Types§

Source§

impl ToJson for bool

Source§

impl ToJson for f32

Source§

impl ToJson for f64

Source§

impl ToJson for i8

Source§

impl ToJson for i16

Source§

impl ToJson for i32

Source§

impl ToJson for i64

Source§

impl ToJson for i128

Source§

impl ToJson for isize

Source§

impl ToJson for str

Source§

impl ToJson for u8

Source§

impl ToJson for u16

Source§

impl ToJson for u32

Source§

impl ToJson for u64

Source§

impl ToJson for u128

Source§

impl ToJson for usize

Source§

impl ToJson for String

Source§

impl<'a, T: ToJson + ToOwned + ?Sized> ToJson for Cow<'a, T>

Source§

type Kind = <T as ToJson>::Kind

Source§

fn json_encode__jsony(&self, output: &mut TextWriter<'_>) -> T::Kind

Source§

impl<K: ToJson<Kind = AlwaysString>, V: ToJson> ToJson for BTreeMap<K, V>

Source§

impl<K: ToJson<Kind = AlwaysString>, V: ToJson, S> ToJson for HashMap<K, V, S>

Source§

impl<T: ToJson + ?Sized> ToJson for &T

Source§

type Kind = <T as ToJson>::Kind

Source§

fn json_encode__jsony(&self, output: &mut TextWriter<'_>) -> T::Kind

Source§

impl<T: ToJson + ?Sized> ToJson for Box<T>

Source§

type Kind = <T as ToJson>::Kind

Source§

fn json_encode__jsony(&self, output: &mut TextWriter<'_>) -> T::Kind

Source§

impl<T: ToJson + ?Sized> ToJson for Rc<T>

Source§

type Kind = <T as ToJson>::Kind

Source§

fn json_encode__jsony(&self, output: &mut TextWriter<'_>) -> T::Kind

Source§

impl<T: ToJson + ?Sized> ToJson for Arc<T>

Source§

type Kind = <T as ToJson>::Kind

Source§

fn json_encode__jsony(&self, output: &mut TextWriter<'_>) -> T::Kind

Source§

impl<T: ToJson> ToJson for Option<T>

Source§

impl<T: ToJson> ToJson for [T]

Source§

impl<T: ToJson> ToJson for Vec<T>

Source§

impl<T: ToJson, const N: usize> ToJson for [T; N]

Source§

impl<V: ToJson, S> ToJson for HashSet<V, S>

Implementors§