-
Notifications
You must be signed in to change notification settings - Fork 1k
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
feat: Add Status with Details Constructor #308
feat: Add Status with Details Constructor #308
Conversation
Where should I add the tests? Wasn't quite sure where to place them as they require a generated proto fixture. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a great start, left one comment once that is addressed I think we can merge!
tonic/src/status.rs
Outdated
} | ||
|
||
/// Create a new `Status` with the associated code, message, and protobuf details field. | ||
pub fn with_details(code: Code, message: impl Into<String>, details: impl Message) -> Status { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually believe we should not include a prost based one here. I think we can just have the one above that takes a Bytes and we remove the impl Into. We can also rename the one above to with_details
. then let the user choose if they want to encode via prost or something else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. Just copy pasta from the PR I inherited. I'm fairly new to Rust so I appreciate your patience. Is this cargo check --no-default-features
CI check to enforce that there's no unnecessary coupling of external crates to the core library?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Changes are just a Copy pasta of this pr in tower-rs.
Motivation
Reference #292 for motivation.
Solution
The prescribed solution exposes two constructors with
Status::with_details
andStatus::with_raw_details
that allow the caller to construct a Status with aCode
,String
, andBytes
or aMessage
to be converted into bytes.