| 1 |
# cffi-mixed |
| 2 |
|
| 3 |
A package for testing maturin with a cffi wrapper with a rust backend and a python wrapper. |
| 4 |
|
| 5 |
Read the [cffi guide](https://cffi.readthedocs.io/en/latest/index.html) to learn how to use the generated `ffi` and `lib` objects. |
| 6 |
|
| 7 |
The package contains a `Point` type implemented in rust and a `Line` class consisting of two points implemented in python |
| 8 |
|
| 9 |
## Usage |
| 10 |
|
| 11 |
```bash |
| 12 |
pip install . |
| 13 |
``` |
| 14 |
|
| 15 |
```python |
| 16 |
import cffi_mixed |
| 17 |
|
| 18 |
from cffi_mixed import Line |
| 19 |
|
| 20 |
point = cffi_mixed.lib.get_origin() |
| 21 |
point.x = 10 |
| 22 |
point.y = 10 |
| 23 |
assert cffi_mixed.lib.is_in_range(point, 15) |
| 24 |
|
| 25 |
assert Line(2, 5, 6, 8).length() == 5 |
| 26 |
``` |
| 27 |
|
| 28 |
## Testing |
| 29 |
|
| 30 |
Install tox: |
| 31 |
|
| 32 |
```bash |
| 33 |
pip install tox |
| 34 |
``` |
| 35 |
|
| 36 |
Run it: |
| 37 |
|
| 38 |
```bash |
| 39 |
tox |
| 40 |
``` |
| 41 |
|
| 42 |
The tests are in `test_cffi_mixed.py`, while the configuration is in tox.ini |