rust-xdr icon indicating copy to clipboard operation
rust-xdr copied to clipboard

Upgrade to newer Rust?

Open calderonth opened this issue 4 years ago • 5 comments

Hi there,

I have been trying to use this PoC code to generate some functioning code but since the blog post was written in 2017 most of the Rust ecosystem has changed and libraries it relied have evolved significantly (futures/tokio). So nothing works with an up to date Rust.

I am wondering what it would take to port some of the code to the newer APIs as I am interested in using Rust for a PoC with XDR RPC.

Thanks!

Thomas

calderonth avatar Jun 16 '20 20:06 calderonth

Hey Thomas!

oof, yeah this code was very wrapped up in the futures 0.1 ecosystem which I would certainly not recommend using anymore. IIRC the serde version used here is also ancient.

It's been a while since I've thought about this code. I'll take a look at it, but I'm guessing that it's pretty non-trivial to upgrade. It'd be kinda fun though :)

benbrittain avatar Jun 16 '20 21:06 benbrittain

it looks like this https://docs.rs/serde-xdr/0.5.1/serde_xdr/ is a replacement for half of this repo. (I can't attest to it's quality yet though)

and the other half is the codegen, which should actually be much easier than it was in 2017

benbrittain avatar Jun 16 '20 21:06 benbrittain

Thanks for the reply, I'm starting with Rust but am keen to have some sort of basic plumbing working the same way you did the previous PoC.

I'm thinking of skipping the codegen part for now and get a really basic service working with the newer serde_xdr library and see how it fits in the new asyn/await paradigm. However, I'm still new to Rust and the new async/await paradigm, so might take me a while.

calderonth avatar Jun 16 '20 21:06 calderonth

serde_xdr is unaware of the async/await paradigm, it'll just be (de)serialization logic. You'll want to tie it to something like smol or another async executor.

Here is a good example of using that: https://github.com/stjepang/smol/blob/master/examples/simple-client.rs

Also, don't feel pressure to use any of the async/await stuff! Often a threadpool and traditional blocking IO is more than sufficient.

benbrittain avatar Jun 16 '20 22:06 benbrittain

So serde_xdr is used by https://github.com/jvff/onc-rpc/ it doesn't really do the codegen part as it's more manual but I've managed to compile a basic version. However, it's also relying on some of those old libraries that are now deprecated.

calderonth avatar Jun 17 '20 16:06 calderonth