Re:Connect-Web: TypeScript library for calling RPC servers f...
by jeffbee on Thursday August 04, 2022 @07:17PM
(#32349508)
Well, I always try to keep in mind the distinction between protobuf the structured encoding and protobuf the code generator. You can use the former without the latter. Considering that the project doesn't even ship a codegen for Rust, you're already doing that. So if there's some more convenient API you'd like, you can just have it. You can also do this with protoc plugins and the official codegen, or you can hand-roll your own protocol parsers which isn't that crazy with such a simple format.
I'm very annoyed that all fields are optional. Which means I have to do additional validation on server side and in a language like rust it's double annoying because now you have `T` or `Option<T>` and it's confusing for some types:
- `string` will be rust's `String` except it is an empty string by default - All "custom" types are `Option<T>` even if that makes no sense semantically
So now you have to check if a string is empty, which I guess is technically a string anyway. However, now you have no idea, it is an empty string as a value or lack of value? You end up wrapping `string` into a `StringValue` and now linter is complaining that you shouldn't use those.
Overall parser for protobuf messages got simpler, but now enforcing safety is on server's implementation.