You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For manipulation of ResponseTypes it would be useful to
Derive PartialOrd over ResponseType so that consumers can compare entire error categories e.g. check if response type is an error.
Implement a built-in function like is_error(). Currently if a user wants to determine this, the most elegant version would still have to do a conversion to MessageClass:
I'm hesitant to implement your third request by assigning discriminants directly, as that would break the public API. I'd much rather introduce an impl From<ResponseType> for u8 conversion, as is already the case for several other types. Does that work for you?
Suppose we then also add is_error() on the type, do you still need the PartialOrd implementation? Because you now have the facilities to determine if it's an error, and if you still want to do range requests you can do that on the u8 obtained by the newly implemented numeric conversion.
I think that's fair. I'm not aware of a downside to implementing PartialOrd, so in my opinion it would be nicer to have the more ergonomic comparison response_type >= ResponseType::BadRequest rather than u8::from(response_type) >= u8::from(ResponseType::BadRequest) though. This would be especially helpful when checking response code ranges that are not just errors e.g. between 400 and 500 responses.
For manipulation of ResponseTypes it would be useful to
PartialOrd
over ResponseType so that consumers can compare entire error categories e.g. check if response type is an error.is_error()
. Currently if a user wants to determine this, the most elegant version would still have to do a conversion to MessageClass:The text was updated successfully, but these errors were encountered: