joeyame / Model-Based-Sim-Framework

This is a simulation framework I have created to try and determine what an effective model-based simulation framework might look like in the modern era of programming.
MIT License
1 stars 0 forks source link

More Cohesion Between Python Inputs and Actual Models #2

Open joeyame opened 2 years ago

joeyame commented 2 years ago

Right now, the simulation is defined within the Python infrastructure, and then Rust Structs are created to match. There isn't too much cohesion though. I want to explore directly setting a rust object equal to a python object, and see if this can be done in a more idiomatic way.

joeyame commented 2 years ago

Accidentally discovered this while tackling #4. Found a much more cohesive way to convert python objects to rust. Code went from lines to just 1:

Ok( Rc::<ForceEffector>::new( input.extract()? ) )

This requires using the pyo3::FromPyObject derive trait on the ForceEffector struct, and automatically maps all the inputs to the rust structure!