Skip to main content

graphrecords_python/querying/
failure_kind.rs

1use graphrecords_query::FailureKind as QueryFailureKind;
2use pyo3::prelude::*;
3
4#[pyclass(frozen, eq, hash)]
5#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
6pub struct PyFailureKind(QueryFailureKind);
7
8#[pymethods]
9impl PyFailureKind {
10    #[getter]
11    const fn name(&self) -> &'static str {
12        self.0.name()
13    }
14
15    fn __repr__(&self) -> String {
16        format!("FailureKind.{}", self.0.name())
17    }
18}
19
20impl From<QueryFailureKind> for PyFailureKind {
21    fn from(kind: QueryFailureKind) -> Self {
22        Self(kind)
23    }
24}
25
26impl From<PyFailureKind> for QueryFailureKind {
27    fn from(kind: PyFailureKind) -> Self {
28        kind.0
29    }
30}