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

[Feature request] Support for serializing Path/PathBuf #598

Closed begleynk closed 1 month ago

begleynk commented 4 months ago

Would it be possible to implement Encoder/Decoder for Rust's Path/Pathbuf types?

I'm currently working on a project where I own all the types in a complex struct, but because the standard library's Path/PathBuf can't be serialized over to Elixir, it's forcing me to create wrapper types. This would be a huge ergonomic benefit.

Happy to contribute a PR if this is straightforward.

Thanks for all your work on Rustler ❤️

filmor commented 4 months ago

If all you are looking for is Path(Buf) <-> binary string, I don't see a problem with that.

begleynk commented 4 months ago

Yup that's fine by me 👍 The Elixir Path module just works on binary strings, so this seems reasonable.

I'll try to contribute a PR for this in the coming days/weeks.