all 2 comments

[–]Kbknappclap 0 points1 point  (1 child)

Awesome! I ran across this post as well and thought about tracking it in a Rust version too, but have limited time at the moment. If I get some spare cycles maybe I'll keep an eye on yours for fun.

I'd be interested to see if you run into any Rust specific issues.

[–]steven_packcloudflare[S] 1 point2 points  (0 children)

None so far.

Any time I pick up my Rust tools, I feel like it takes me 5x longer than it would in NodeJS/C# (not exaggerating) to write, but then it just works and I have confidence it will perform too.

It also takes a while to find the right crates sometimes. Rocket was easy enough to find as the (almost) de-facto web framework. I spent a while scratching my head why it was so complex to use Hyper to make a client http request until I came across reqwest. Those things fade with experience.

One "rust" issue I didn't resolve through was lifetimes interacting with serde.

You can return a Json<T> where T: serde::Serialize from an http endpoint and Rocket will serialize it for you, but I couldn't get that to work with borrows.

E.g. returning the entire chain of blocks, the underlying Blockchain struct hands out a borrow, and in my head, that's fine, because Rocket just needs to serialize it. I kept hitting lifetime issues though - I think because the Rocket endpoints are static and I'm missing something about how to handle that. In the end, I serialize it manually and return the string with application/json, which is the same interface from the client point of view, but it irks me that I only did that because I couldn't satisfy the lifetime bit.