Skip to content

Commit

Permalink
wip try a full lookup tree
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhewitt committed Feb 13, 2025
1 parent 7b83c59 commit 306c934
Show file tree
Hide file tree
Showing 4 changed files with 520 additions and 174 deletions.
5 changes: 5 additions & 0 deletions src/input/input_abstract.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::convert::Infallible;
use std::fmt;

use jiter::JsonValue;
use pyo3::exceptions::PyValueError;
use pyo3::types::{PyDict, PyList, PyString};
use pyo3::{intern, prelude::*, IntoPyObjectExt};
Expand Down Expand Up @@ -73,6 +74,10 @@ pub trait Input<'py>: fmt::Debug {
None
}

fn as_json(&self) -> Option<&JsonValue<'_>> {
None
}

fn as_kwargs(&self, py: Python<'py>) -> Option<Bound<'py, PyDict>>;

type Arguments<'a>: Arguments<'py>
Expand Down
4 changes: 4 additions & 0 deletions src/input/input_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ impl From<JsonValue<'_>> for LocItem {
}

impl<'py, 'data> Input<'py> for JsonValue<'data> {
fn as_json(&self) -> Option<&JsonValue<'_>> {
Some(self)
}

#[inline]
fn py_converter(&self) -> impl IntoPyObject<'py> + '_ {
self
Expand Down
8 changes: 6 additions & 2 deletions src/lookup_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,10 @@ impl LookupPath {
pub fn first_key(&self) -> &str {
&self.first_item.key
}

pub fn rest(&self) -> &[PathItem] {
&self.rest
}
}

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

impl fmt::Display for PathItem {
Expand Down
Loading

0 comments on commit 306c934

Please sign in to comment.