rusterlium / rustler

Safe Rust bridge for creating Erlang NIF functions
https://docs.rs/crate/rustler
Apache License 2.0
4.24k stars 222 forks source link

Import of serde_rustler #586

Closed filmor closed 3 months ago

filmor commented 6 months ago

Hi all, please have a look. This started as a direct import of https://github.com/sunny-g/serde_rustler/ into our codebase (@sunny-g, thanks again for your work!).

Changes

The simple example code now looks like this:

#[nif]
pub fn readme(SerdeTerm(animal): SerdeTerm<Animal>) -> SerdeTerm<Animal> /* or `impl Encoder` */ {
    println!("\n deserialized animal from README example: {:?}", animal);
    SerdeTerm(animal)
}

As far as I can see, it's not feasible to completely replace our Encoder/Decoder construction as serde does not allow for a "passthrough" (i.e. we allow a Term to be "encoded" to Term and vice-versa) and can also not be extended to do that.

Issues

License

@sunny-g Your project is missing a license, we'd need one from you to proceed with this. If you don't really care, the simplest would probably to donate your code to the project, but this has to be explicit. If you put it under MIT/Apache license, we'd have to carry your copyright along.

filmor commented 6 months ago

The CI errors are the same that we have in #581 right now

filmor commented 5 months ago

On the license: The crates.io says it's MIT, which is a subset of Apache 2, so we should be fine importing it. The source code doesn't contain license notes or a license file, so there is nothing to retain. Our MIT license note is quite out-dated anyhow, so I will adjust it as follows (provided everyone is fine with it):

  Copyright (c) 2016 hansihe
+ Copyright (c) 2016-2024 The Contributors of the Rustler Project
+ Serde support derived from `serde_rustler` Copyright (c) 2019-2021 sunny-g

@sunny-g Please comment if

  1. This is fine with you
  2. You want your full name instead of your Github handle
  3. You are fine with leaving the explicit copyright out in favour of a mention in the Changelog or Readme

@rusterlium/core Please have a look at the approach, it would be nice to get some comments/feedback as this is quite a large chunk of (at least slightly) opionated code to be added to our codebase.

sunny-g commented 5 months ago

@filmor sorry for the delay

just updated the repo to include an MIT LICENSE file, and either name ref is fine by me, though I guess it should be my name since that is what's in the LICENSE file.

Let me know what else you need - glad to see this getting first-party support!

sunny-g commented 5 months ago

Great work! I only found minor nitpicks (but it is a lot of code, so we might find something else later on). Thanks for your work @sunny-g and @filmor !

it was my first rust project, and a ton's changed since I wrote it, so be kind :)