Macro stdweb::js_deserializable
[−]
[src]
macro_rules! js_deserializable { ($kind:tt) => { ... }; (impl< $($impl_arg:tt),* > for $kind:ty where $($bounds:tt)*) => { ... }; (impl< $($impl_arg:tt),* > for $kind:ty) => { ... }; }
A macro which makes it possible to convert an instance of a given type
implementing Serde's Deserialize
into a Value using
TryInto.
For types defined outside of your crate you can also use the Serde newtype to make them deserializable indirectly.
Examples
#[derive(Deserialize, Debug)] struct Person { name: String, age: i32 } js_deserializable!( Person ); let value = js! { return { number: 123, string: "Hello!" }; }; let structure: StructureSerializable = value.try_into().unwrap(); assert_eq!( structure.number, 123 ); assert_eq!( structure.string, "Hello!" );
This macro also accepts generics just as the js_serializable! does.