Module python_comm::as_python_dict_use [−][src]
Expand description
to use AsPythonDict
Usage
use python_comm::{as_python_dict_use::*, use_pyo3::*};
use rust_decimal_macros::dec;
#[derive(AsPythonDict)]
struct ClassDict {
f1: i32,
f2: String,
f3: Decimal,
f4: NaiveDate,
f5: NaiveDateTime,
}
#[pyfunction]
fn func(a: ClassDict) -> Result<ClassDict, PyErr> {
Ok(ClassDict{
f1: 2,
f2: "2".to_string(),
f3: dec!(2),
f4: NaiveDate::from_ymd(2002, 2, 2),
f5: NaiveDate::from_ymd(2002, 2, 2).and_hms(2, 2, 2)
})
}
// In Python:
// b = func (
// {
// "f1": 1,
// "f2": "1",
// "f3": Decimal(1),
// "f4": datetime.datetime(2001, 1, 1).date(),
// "f5": datetime.datetime(2001, 1, 1, 1, 1, 1)
// }
// )
// b["f1"]
Re-exports
pub use crate::raise_error_use::*;
Derive Macros
AsPythonDict, no_simple_cov