From cb9ba2bc8d0877ac4a113209b14483d7d1e23acb Mon Sep 17 00:00:00 2001 From: Quanzheng Long Date: Tue, 17 Mar 2026 19:43:04 -0700 Subject: [PATCH] imp --- rust-core/src/lib_py.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/rust-core/src/lib_py.rs b/rust-core/src/lib_py.rs index 6f4e034af..dd57bcce7 100644 --- a/rust-core/src/lib_py.rs +++ b/rust-core/src/lib_py.rs @@ -36,17 +36,13 @@ impl PyRustEngine { self.inner.add_async_channel(name); } - fn publish_json(&self, channel: &str, value_json: &str) -> PyResult<()> { - let value: Value = serde_json::from_str(value_json) - .map_err(|e| PyValueError::new_err(format!("Invalid JSON value: {e}")))?; - self.inner - .publish_json(channel, value) - .map_err(PyValueError::new_err) - } - fn publish_obj(&self, py: Python<'_>, channel: &str, value: Py) -> PyResult<()> { let value_json = py_obj_to_json_string(py, &value.bind(py))?; - self.publish_json(channel, &value_json) + let parsed: Value = serde_json::from_str(&value_json) + .map_err(|e| PyValueError::new_err(format!("Invalid Python JSON value: {e}")))?; + self.inner + .publish_json(channel, parsed) + .map_err(PyValueError::new_err) } fn wait_any_of_json(&self, any_of_json: &str) -> PyResult {