raphtory-api 0.17.0

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

impl<'source> FromPyObject<'source> for Direction {
    fn extract_bound(ob: &Bound<'source, 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' }",
            ))),
        }
    }
}