Allow handlers to return anything that impls : serde::Serialize. This is backward-compatible with the current serde_json::Value return type, but also allows for () return types or any other serde-compatible type - the main point here is to be able to return anything that is #[derive(Serialize)].
This is an inefficient implementation, as it uses both serde_json::value::to_value and cpython_json::from_value to convert. However, this two-step conversion was necessary previously if using serde, so in many cases it's no less efficient than before! Directly converting using a function like fn to_object<S: Serialize>(py: Python, s: S) -> Result<PyObject, Error> would be ideal, but that first needs to be written.
Allow handlers to return anything that impls
: serde::Serialize
. This is backward-compatible with the currentserde_json::Value
return type, but also allows for()
return types or any other serde-compatible type - the main point here is to be able to return anything that is#[derive(Serialize)]
.This is an inefficient implementation, as it uses both
serde_json::value::to_value
andcpython_json::from_value
to convert. However, this two-step conversion was necessary previously if using serde, so in many cases it's no less efficient than before! Directly converting using a function likefn to_object<S: Serialize>(py: Python, s: S) -> Result<PyObject, Error>
would be ideal, but that first needs to be written.