How do you design API around request context? #75
Replies: 2 comments
-
I ended up cloning stuff in the closures as that is probably how Rust APIs should work as the values behind references could change between finishing the closure code and accessing them to serialize. |
Beta Was this translation helpful? Give feedback.
-
Using Whatever you return from your rspc resolver will most likely need to be owned to satisfy the borrow checker so I would just have |
Beta Was this translation helpful? Give feedback.
-
Hi, my app is local only so I store all data in my own services. When returning them, I return references to them. I think it should be possible to use the references, serialize their values and return the references back. I am new to Rust and perhaps my question is rather a design problem but I feel lost now.
Compilation error
Are we expected to not use any references and always move data with ownership?
From the example: https://rspc.dev/server/router#attaching-procedures
Beta Was this translation helpful? Give feedback.
All reactions