-
-
Notifications
You must be signed in to change notification settings - Fork 53
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
Rust support #44
Comments
Hi Mathieu, Can you elaborate what you mean by the "protocol/ser/deser logic", maybe with a link? To a Rust noob like me it sounds like you suggest to (re)use the interface from Protocol Buffers? |
What I meant by protocol is the Colfer data format, sorry. As I'd like to use Colfer in my environment (which is hybrid Rust/JS/Go/C), would you like me to just go ahead and implement something in idiomatic rust? The only problem I see with idiomatic Rust is that it'll drift away from the code generation logic you implemented. |
Oh whauw! :D I would be extremely pleased with any help on the subject. Please feel free to make another API if you see room for improvement. The main reason for the existing design is to minimise memory allocation. It should be at least possible to reuse the buffers and structs. Maybe you don't need it because of Rust's stack allocation? Maybe I should do the compiler/template work so you can fully focus on the implementation and I learn a bit about the language? Could you write an implementation of Not sure whether you are on a schedule? I'm on holliday until the 20th. The compler follow-up should be done within 2 days. |
Glad you're hyped with the proposal! And I'm aiming to use it in our backend architecture as well (distributed with serialized binary messages passed over a message broker) because well, even if it's not a bottleneck in backend development, it's still a welcome optimization, and our backend is part Rust, part Node. I'd like to keep your API to ease maintenance that's for sure, same method everywhere, but I think that for Rust, to keep the project quite idiomatic with what's possible, we have two choices:
|
Those macro features look interesting. One downside of using Rust structs as definition types is maintenance when used with more than one language; how to keep the definitions in sync? The cargo documentation mentions support for code generators explicitly. Would it not be easier to launch colf(1) with a I leave the decision up to you. Don't worry about being in line of what's already there. We need the most elegant solution. |
I've thought about the
About the definitions in sync issue, we could have both options:
|
Two more days of holliday and I'm back home coding. How's the implementation going? Do you have a public repository somewhere? =) |
Please note that you need some way to lock the compiler version for consistent builds. As noted in the README, I recommend to put the generated code in the SCM. This also eliminates |
Hey, I've been super busy (on a schedule) over the last few days, and couldn't do anything more than I wrote last saturday. I've been writing a rust version of generated code (by hand) just to check the implementation of serialization/deserialization. Pretty sure most of it is plain wrong/broken since I've wrote it in only one run without testing anything. The repo is located here: https://github.com/YellowInnovation/colfer-rs I think the option of using build.rs (and |
Got some time to spare later this week. Can you please declare your project public domain [CC0] so I can use your implementation. If you write a unit test with the test set for your Once you manage the procedural macro's then I'll be more than happy to link to your project from here. I see that you use a switch-loop for the fields with unmarshal. As the field indices are required to count up I found that |
Pattern matching in rust internally works as a scoped function lookup AFAIK so it's not a "switch" per-se as you would understand it in other languages. The semantics of it are close to a My implementation is pretty much broken right now, I've noticed many problems with it (and I think I went to a completely wrong route of implementing it, I tried porting without thinking and actually there's a much better way to write it in Rust), I'd personally advise against even looking at it lmao. |
Hello,
I wanted to ask about rust support.
Considering how such code is usually generated with macros, should we just create a crate that just implements the protocol/ser/deser logic?
Also, conforming with Serde to get automatic ser/deser of rust
struct
would be a very nice addition as well.Cheers,
Mathieu
The text was updated successfully, but these errors were encountered: