2023-08-04 07:23:31 +00:00
|
|
|
use pyo3::{basic::CompareOp, prelude::*};
|
2019-08-02 11:23:10 +00:00
|
|
|
use tantivy as tv;
|
2019-06-04 09:09:58 +00:00
|
|
|
|
|
|
|
/// Tantivy schema.
|
|
|
|
///
|
|
|
|
/// The schema is very strict. To build the schema the `SchemaBuilder` class is
|
|
|
|
/// provided.
|
2023-08-04 07:23:31 +00:00
|
|
|
#[pyclass(frozen)]
|
|
|
|
#[derive(PartialEq)]
|
2019-06-04 09:09:58 +00:00
|
|
|
pub(crate) struct Schema {
|
2019-08-02 11:23:10 +00:00
|
|
|
pub(crate) inner: tv::schema::Schema,
|
2019-06-04 09:09:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[pymethods]
|
2023-08-04 07:23:31 +00:00
|
|
|
impl Schema {
|
|
|
|
fn __richcmp__(
|
|
|
|
&self,
|
|
|
|
other: &Self,
|
|
|
|
op: CompareOp,
|
|
|
|
py: Python<'_>,
|
|
|
|
) -> PyObject {
|
|
|
|
match op {
|
|
|
|
CompareOp::Eq => (self == other).into_py(py),
|
|
|
|
CompareOp::Ne => (self != other).into_py(py),
|
|
|
|
_ => py.NotImplemented(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|