fp_bindgen/serializable/
serde_json.rs1use super::Serializable;
2use crate::prelude::TypeMap;
3use crate::types::{CargoDependency, CustomType, Type, TypeIdent};
4use std::collections::BTreeMap;
5
6impl Serializable for serde_json::Value {
7 fn ident() -> TypeIdent {
8 TypeIdent::from("Value")
9 }
10
11 fn ty() -> Type {
12 Type::Custom(CustomType {
13 ident: Self::ident(),
14 rs_ty: "serde_json::Value".to_owned(),
15 rs_dependencies: BTreeMap::from([("serde_json", CargoDependency::with_version("1.0"))]),
16 serde_attrs: Vec::new(),
17 ts_ty: "any".to_owned(),
18 ts_declaration: None,
19 })
20 }
21}
22
23impl<K, V> Serializable for serde_json::Map<K, V>
24where
25 K: Serializable,
26 V: Serializable,
27{
28 fn ident() -> TypeIdent {
29 TypeIdent {
30 name: "serde_json::Map".to_string(),
31 generic_args: vec![
32 (TypeIdent::from("K"), vec![]),
33 (TypeIdent::from("V"), vec![]),
34 ],
35 ..Default::default()
36 }
37 }
38
39 fn ty() -> Type {
40 Type::Map(
41 "serde_json::Map".to_owned(),
42 TypeIdent::from("K"),
43 TypeIdent::from("V"),
44 )
45 }
46
47 fn collect_types(types: &mut TypeMap) {
48 types.entry(Self::ident()).or_insert_with(Self::ty);
49 K::collect_types(types);
50 V::collect_types(types);
51 }
52}