Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid intermediate JSON AST creation #1

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Conversation

aruediger
Copy link
Contributor

No description provided.

fn serve_ws(
&self,
ctx: Ctx,
raw_req: Value,
service_id: &str,
) -> BoxStream<'static, Result<Value, ErrorKind>>;
) -> BoxStream<'static, Result<Resp, ErrorKind>>;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return the Serializable instead of the AST

.map(|resp_result| {
resp_result
.map(|resp| {
serde_json::to_value(&resp)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

skip this step

&self,
_ctx: (),
req: Self::Req,
) -> BoxStream<'static, Result<Self::Resp, String>> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like we need to box Self::Resp here but that fails with

the trait formats::_::serde::Serializecannot be made into an objectformats::::_serde::Serialize cannot be made into an objectrustc(E0038)

which https://crates.io/crates/erased-serde might solve.

let services = Arc::new(maplit::btreemap! {"test" => TestService::new().boxed()});
let services = Arc::new(maplit::btreemap! {
"test" => TestService::new().boxed(),
"test2" => TestService2::new().boxed(),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this now fails as the return type of serve differs.

@aruediger aruediger requested a review from dvc94ch March 29, 2021 12:11
@aruediger aruediger changed the title Avoid intermediate JSON ASTs creation Avoid intermediate JSON AST creation Mar 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant