Derive macro for PyO3's FromPyObject
trait. The derived implementation turns a Python's dict into your Rust struct.
Add the library to your Cargo.toml
together with PyO3:
[dependencies]
pyo3 = "0.7.0"
dict_derive = "0.1.0"
Import the derive implementation and use it on your structs: ```rust extern crate dict_derive;
use dict_derive::FromPyObject;
struct User { name: String, email: String, age: u32, } ```
Then you can use your structs as arguments in your PyO3 functions: ```rust extern crate pyo3; use pyo3::prelude::*; use pyo3::wrap_pyfunction;
fn getcontactinfo(user: User) -> PyResult
And then call your functions using normal python dicts: ```
import mylib mylib.getcontactinfo({"name": "Thor", "email": "thor@asgard.com", "age": 23}) 'Thor - thor@asgard.com' ```