Skip to content
This repository has been archived by the owner on Aug 15, 2021. It is now read-only.

Use serde::ser::StdError shim type rather than std::error::Error #180

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

Conversation

cbeck88
Copy link

@cbeck88 cbeck88 commented Feb 15, 2020

This is for alloc vs. std modes compatibility, a code comment
explains in detail the purpose of this, which is admittedly subtle.

After this commit, builds like

~/cbor$ cargo build --no-default-features --features=alloc,serde/std

succeed locally for me.


I'm evaluating using cbor in a large
project, I think a patch like this would be super helpful to us.

The gist of it is, we have a bunch of SGX enclaves written in rust,
and servers that pass messages to them in rust. I would like to use
cbor/alloc in the enclaves to deserialize messages across the FFI
boundary.

It would be great if no_std infra crates (that get used in both servers and enclacves) in our codebase
can unconditionally select cbor/alloc, omit any reference to an std flag (to minimize
configuration), and these crates can be consumed both by enclaves, and
by servers that also rely on third party crates from crates.io that may enable
serde/std. I think this patch will make that possible, I'm going to test it.

This is for `alloc` vs. `std` modes compatibility, a code comment
explains in detail the purpose of this, which is admittedly subtle.

After this commit builds like

```
~/cbor$ cargo build --no-default-features --features=alloc,serde/std
```

succeed locally for me
@stevenroose
Copy link
Contributor

It looks like serde_json is instead using serde::de::StdError: https://github.com/serde-rs/json/blob/4bcc3625c34b4f9b6c76013b8a5afcaed5a1f1da/src/error.rs#L317

It probably is not a meaningful difference.

@stevenroose
Copy link
Contributor

stevenroose commented May 22, 2020

What is a meaningful difference though is that serde_json is only providing the source method on the std feature. Instead of only doing that for the Error::Io variant.

I think matching as closely as possible what serde_json does, would be a good idea. Given that serde_json is maintained by the same folks as serde itself.

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