Skip to content

Commit 306c934

Browse files
committed
wip try a full lookup tree
1 parent 7b83c59 commit 306c934

File tree

4 files changed

+520
-174
lines changed

4 files changed

+520
-174
lines changed

src/input/input_abstract.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::convert::Infallible;
22
use std::fmt;
33

4+
use jiter::JsonValue;
45
use pyo3::exceptions::PyValueError;
56
use pyo3::types::{PyDict, PyList, PyString};
67
use pyo3::{intern, prelude::*, IntoPyObjectExt};
@@ -73,6 +74,10 @@ pub trait Input<'py>: fmt::Debug {
7374
None
7475
}
7576

77+
fn as_json(&self) -> Option<&JsonValue<'_>> {
78+
None
79+
}
80+
7681
fn as_kwargs(&self, py: Python<'py>) -> Option<Bound<'py, PyDict>>;
7782

7883
type Arguments<'a>: Arguments<'py>

src/input/input_json.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ impl From<JsonValue<'_>> for LocItem {
4343
}
4444

4545
impl<'py, 'data> Input<'py> for JsonValue<'data> {
46+
fn as_json(&self) -> Option<&JsonValue<'_>> {
47+
Some(self)
48+
}
49+
4650
#[inline]
4751
fn py_converter(&self) -> impl IntoPyObject<'py> + '_ {
4852
self

src/lookup_key.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,10 @@ impl LookupPath {
423423
pub fn first_key(&self) -> &str {
424424
&self.first_item.key
425425
}
426+
427+
pub fn rest(&self) -> &[PathItem] {
428+
&self.rest
429+
}
426430
}
427431

428432
#[derive(Debug, Clone)]
@@ -437,8 +441,8 @@ pub(crate) enum PathItem {
437441
/// we store both the string and pystring to save creating the pystring for python
438442
#[derive(Debug, Clone)]
439443
pub(crate) struct PathItemString {
440-
key: String,
441-
py_key: Py<PyString>,
444+
pub key: String,
445+
pub py_key: Py<PyString>,
442446
}
443447

444448
impl fmt::Display for PathItem {

0 commit comments

Comments
 (0)