Json

Trait Json 

Source
pub trait Json<Target: Serialize + DeserializeOwned>: Sized + Debug {
    // Required methods
    fn to_json(self) -> Target;
    fn from_json(json: Target) -> Result<Self>;
}
Expand description

A trait for types that can be encoded and decoded to and from JSON.

Required Methods§

Source

fn to_json(self) -> Target

Converts the value to its JSON representation.

Source

fn from_json(json: Target) -> Result<Self>

Converts the value from its JSON representation.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Json<bool> for bool

Source§

fn to_json(self) -> bool

Source§

fn from_json(json: bool) -> Result<Self>

Source§

impl Json<i8> for i8

Source§

fn to_json(self) -> i8

Source§

fn from_json(json: i8) -> Result<Self>

Source§

impl Json<i16> for i16

Source§

fn to_json(self) -> i16

Source§

fn from_json(json: i16) -> Result<Self>

Source§

impl Json<i32> for i32

Source§

fn to_json(self) -> i32

Source§

fn from_json(json: i32) -> Result<Self>

Source§

impl Json<i64> for i64

Source§

fn to_json(self) -> i64

Source§

fn from_json(json: i64) -> Result<Self>

Source§

impl Json<i128> for i128

Source§

fn to_json(self) -> i128

Source§

fn from_json(json: i128) -> Result<Self>

Source§

impl Json<u8> for u8

Source§

fn to_json(self) -> u8

Source§

fn from_json(json: u8) -> Result<Self>

Source§

impl Json<u16> for u16

Source§

fn to_json(self) -> u16

Source§

fn from_json(json: u16) -> Result<Self>

Source§

impl Json<u32> for u32

Source§

fn to_json(self) -> u32

Source§

fn from_json(json: u32) -> Result<Self>

Source§

impl Json<u64> for u64

Source§

fn to_json(self) -> u64

Source§

fn from_json(json: u64) -> Result<Self>

Source§

impl Json<u128> for u128

Source§

fn to_json(self) -> u128

Source§

fn from_json(json: u128) -> Result<Self>

Source§

impl Json<()> for ()

Source§

fn to_json(self)

Source§

fn from_json(json: ()) -> Result<Self>

Source§

impl Json<usize> for usize

Source§

fn to_json(self) -> usize

Source§

fn from_json(json: usize) -> Result<Self>

Source§

impl Json<String> for String

Source§

fn to_json(self) -> String

Source§

fn from_json(json: String) -> Result<Self>

Source§

impl Json<String> for Vec<u8>

Source§

fn to_json(self) -> String

Source§

fn from_json(json: String) -> Result<Self>

Source§

impl Json<String> for [u8; 1]

Source§

fn to_json(self) -> String

Source§

fn from_json(json: String) -> Result<Self>

Source§

impl Json<String> for [u8; 2]

Source§

fn to_json(self) -> String

Source§

fn from_json(json: String) -> Result<Self>

Source§

impl Json<String> for [u8; 3]

Source§

fn to_json(self) -> String

Source§

fn from_json(json: String) -> Result<Self>

Source§

impl Json<String> for [u8; 4]

Source§

fn to_json(self) -> String

Source§

fn from_json(json: String) -> Result<Self>

Source§

impl Json<String> for [u8; 5]

Source§

fn to_json(self) -> String

Source§

fn from_json(json: String) -> Result<Self>

Source§

impl Json<String> for [u8; 6]

Source§

fn to_json(self) -> String

Source§

fn from_json(json: String) -> Result<Self>

Source§

impl Json<String> for [u8; 8]

Source§

fn to_json(self) -> String

Source§

fn from_json(json: String) -> Result<Self>

Source§

impl Json<String> for [u8; 12]

Source§

fn to_json(self) -> String

Source§

fn from_json(json: String) -> Result<Self>

Source§

impl Json<String> for [u8; 16]

Source§

fn to_json(self) -> String

Source§

fn from_json(json: String) -> Result<Self>

Source§

impl Json<String> for [u8; 17]

Source§

fn to_json(self) -> String

Source§

fn from_json(json: String) -> Result<Self>

Source§

impl Json<String> for [u8; 32]

Source§

fn to_json(self) -> String

Source§

fn from_json(json: String) -> Result<Self>

Source§

impl Json<String> for [u8; 64]

Source§

fn to_json(self) -> String

Source§

fn from_json(json: String) -> Result<Self>

Source§

impl Json<String> for [u8; 96]

Source§

fn to_json(self) -> String

Source§

fn from_json(json: String) -> Result<Self>

Source§

impl Json<String> for [u8; 128]

Source§

fn to_json(self) -> String

Source§

fn from_json(json: String) -> Result<Self>

Source§

impl Json<String> for [u8; 144]

Source§

fn to_json(self) -> String

Source§

fn from_json(json: String) -> Result<Self>

Source§

impl Json<String> for [u8; 256]

Source§

fn to_json(self) -> String

Source§

fn from_json(json: String) -> Result<Self>

Source§

impl Json<String> for [u8; 784]

Source§

fn to_json(self) -> String

Source§

fn from_json(json: String) -> Result<Self>

Source§

impl<K, V> Json<BTreeMap<K, V>> for BTreeMap<K, V>

Source§

fn to_json(self) -> BTreeMap<K, V>

Source§

fn from_json(json: BTreeMap<K, V>) -> Result<Self>

Source§

impl<K, V> Json<Vec<(K, V)>> for BTreeMap<K, V>

Source§

fn to_json(self) -> Vec<(K, V)>

Source§

fn from_json(json: Vec<(K, V)>) -> Result<Self>

Source§

impl<K, V> Json<Vec<(K, V)>> for HashMap<K, V>

Source§

fn to_json(self) -> Vec<(K, V)>

Source§

fn from_json(json: Vec<(K, V)>) -> Result<Self>

Source§

impl<K, V> Json<HashMap<K, V>> for HashMap<K, V>

Source§

fn to_json(self) -> HashMap<K, V>

Source§

fn from_json(json: HashMap<K, V>) -> Result<Self>

Source§

impl<M: Serialize + DeserializeOwned + Debug, N: Serialize + DeserializeOwned + Debug, P, Q> Json<(M, N)> for (P, Q)
where P: Json<M>, Q: Json<N>,

Source§

fn to_json(self) -> (M, N)

Source§

fn from_json(json: (M, N)) -> Result<Self>

Source§

impl<M: Serialize + DeserializeOwned, N> Json<Option<M>> for Option<N>
where N: Json<M>,

Source§

fn to_json(self) -> Option<M>

Source§

fn from_json(json: Option<M>) -> Result<Self>

Source§

impl<M: Serialize + DeserializeOwned, N> Json<Vec<M>> for [N; 1]
where N: Json<M> + Default,

Source§

fn to_json(self) -> Vec<M>

Source§

fn from_json(json: Vec<M>) -> Result<Self>

Source§

impl<M: Serialize + DeserializeOwned, N> Json<Vec<M>> for [N; 2]
where N: Json<M> + Default,

Source§

fn to_json(self) -> Vec<M>

Source§

fn from_json(json: Vec<M>) -> Result<Self>

Source§

impl<M: Serialize + DeserializeOwned, N> Json<Vec<M>> for [N; 3]
where N: Json<M> + Default,

Source§

fn to_json(self) -> Vec<M>

Source§

fn from_json(json: Vec<M>) -> Result<Self>

Source§

impl<M: Serialize + DeserializeOwned, N> Json<Vec<M>> for [N; 4]
where N: Json<M> + Default,

Source§

fn to_json(self) -> Vec<M>

Source§

fn from_json(json: Vec<M>) -> Result<Self>

Source§

impl<M: Serialize + DeserializeOwned, N> Json<Vec<M>> for [N; 5]
where N: Json<M> + Default,

Source§

fn to_json(self) -> Vec<M>

Source§

fn from_json(json: Vec<M>) -> Result<Self>

Source§

impl<M: Serialize + DeserializeOwned, N> Json<Vec<M>> for [N; 6]
where N: Json<M> + Default,

Source§

fn to_json(self) -> Vec<M>

Source§

fn from_json(json: Vec<M>) -> Result<Self>

Source§

impl<M: Serialize + DeserializeOwned, N> Json<Vec<M>> for [N; 8]
where N: Json<M> + Default,

Source§

fn to_json(self) -> Vec<M>

Source§

fn from_json(json: Vec<M>) -> Result<Self>

Source§

impl<M: Serialize + DeserializeOwned, N> Json<Vec<M>> for [N; 12]
where N: Json<M> + Default,

Source§

fn to_json(self) -> Vec<M>

Source§

fn from_json(json: Vec<M>) -> Result<Self>

Source§

impl<M: Serialize + DeserializeOwned, N> Json<Vec<M>> for [N; 16]
where N: Json<M> + Default,

Source§

fn to_json(self) -> Vec<M>

Source§

fn from_json(json: Vec<M>) -> Result<Self>

Source§

impl<M: Serialize + DeserializeOwned, N> Json<Vec<M>> for [N; 32]
where N: Json<M> + Default,

Source§

fn to_json(self) -> Vec<M>

Source§

fn from_json(json: Vec<M>) -> Result<Self>

Source§

impl<M: Serialize + DeserializeOwned, N> Json<Vec<M>> for [N; 64]
where N: Json<M> + Default,

Source§

fn to_json(self) -> Vec<M>

Source§

fn from_json(json: Vec<M>) -> Result<Self>

Source§

impl<M: Serialize + DeserializeOwned, N> Json<Vec<M>> for [N; 96]
where N: Json<M> + Default,

Source§

fn to_json(self) -> Vec<M>

Source§

fn from_json(json: Vec<M>) -> Result<Self>

Source§

impl<M: Serialize + DeserializeOwned, N> Json<Vec<M>> for [N; 128]
where N: Json<M> + Default,

Source§

fn to_json(self) -> Vec<M>

Source§

fn from_json(json: Vec<M>) -> Result<Self>

Source§

impl<M: Serialize + DeserializeOwned, N> Json<Vec<M>> for [N; 144]
where N: Json<M> + Default,

Source§

fn to_json(self) -> Vec<M>

Source§

fn from_json(json: Vec<M>) -> Result<Self>

Source§

impl<M: Serialize + DeserializeOwned, N> Json<Vec<M>> for [N; 256]
where N: Json<M> + Default,

Source§

fn to_json(self) -> Vec<M>

Source§

fn from_json(json: Vec<M>) -> Result<Self>

Source§

impl<M: Serialize + DeserializeOwned, N> Json<Vec<M>> for [N; 784]
where N: Json<M> + Default,

Source§

fn to_json(self) -> Vec<M>

Source§

fn from_json(json: Vec<M>) -> Result<Self>

Source§

impl<M: Serialize + DeserializeOwned, N> Json<Vec<M>> for Vec<N>
where N: Json<M>,

Source§

fn to_json(self) -> Vec<M>

Source§

fn from_json(json: Vec<M>) -> Result<Self>

Source§

impl<M: Serialize + DeserializeOwned, N: Serialize + DeserializeOwned, P, Q> Json<ResultJson<M, N>> for Result<P, Q>
where P: Json<M>, Q: Json<N>,

Source§

fn to_json(self) -> ResultJson<M, N>

Source§

fn from_json(json: ResultJson<M, N>) -> Result<Self>

Implementors§