kafka-protocol-rs icon indicating copy to clipboard operation
kafka-protocol-rs copied to clipboard

Feature: Add method to requests and responses to return the ApiKey (i16)

Open phughk opened this issue 10 months ago • 0 comments

I am using the crate to construct client requests. Requests in themselves don't generate the appropriate headers (RequestHeader does), so I am adding those myself. To do that, I am needing the ApiKey for the Request - I see that it is implemented as a trait with a const, but when I am operating on the structs I don't actually have access to the trait const conveniently (ApiVersionsRequest::default().KEY). Maybe it could be cast, but I think the easier approach would be the following.

fn get_key<R: Request>(inner: &R) -> i16 {
    R::KEY
}

And just have that as a default impl on the trait.

phughk avatar Feb 05 '25 13:02 phughk