tomhoule / purescript-waterslide-rs

Generate Purescript types from your Rust types. (unmaintained)
Apache License 2.0
41 stars 4 forks source link

purescript-waterslide-rs

travis badge crates.io badge docs.rs badge

logo

NOTE: This library is currently unmaintained. Please contact @tomhoule if you would like to do something about it.

Wouldn't it be nice if you could share your data type definitions between your Rust backend and your Purescript app? Now you can!

Waterslide generates Purescript type definitions from Rust structs and enums. It works on stable Rust.

Basic usage

You might want to put the module generation code in a separate binary, which is easy to do with Cargo.

Important: on the Purescript side, you want to use the Data.Argonaut.Generic.Aeson codec to encode and decode the JSON types.

Important*: on the Rust side, your enums have to be annotated with #[serde(tag = "tag", content = "contents")]

These restrictions will be lifted in the future by the development of an Argonaut codec that mirrors serde_json's defaults.

For running code, take a look at the basic example. The tests also provide a lot of usage examples, notably for generic types.

Features

Roadmap

Things I want to add in the coming weeks (in no particular order):

Acknowledgments

The idea of this library came from Haskell's purescript-bridge package.

Contributing

That would be awesome! There are no particular guidelines for pull requests (maybe in the future). We adhere to the Rust Code of Conduct.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.