Skip to content
This repository has been archived by the owner on Jun 13, 2019. It is now read-only.

Serialize return value bound #11

Merged
merged 4 commits into from
Oct 27, 2017
Merged

Conversation

arcnmx
Copy link
Contributor

@arcnmx arcnmx commented Aug 24, 2017

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.

@arcnmx arcnmx mentioned this pull request Aug 29, 2017
@iliana iliana merged commit e2fcdb2 into iliana:master Oct 27, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants