raphtory-api 0.18.5

Raphtory common interface and APIs
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::core::Direction;
use pyo3::{exceptions::PyTypeError, prelude::*};

impl<'py> FromPyObject<'_, 'py> for Direction {
    type Error = PyErr;
    fn extract(ob: Borrowed<'_, 'py, PyAny>) -> PyResult<Self> {
        let value: &str = ob.extract()?;
        match value {
            "out" => Ok(Direction::OUT),
            "in" => Ok(Direction::IN),
            "both" => Ok(Direction::BOTH),
            _ => Err(PyTypeError::new_err(PyTypeError::new_err(
                "Direction must be one of { 'out', 'in', 'both' }",
            ))),
        }
    }
}