rust-rdkafka
rust-rdkafka copied to clipboard
FromBytes signature impossible to satisfy?
Good morning. Thanks for a great library!
It seems to me there's an error in the function signature of the FromBytes
trait, it's specified to return a reference to a value created within the same function:
https://docs.rs/rdkafka/0.29.0/rdkafka/message/trait.FromBytes.html
Also, another minor issue is the only argument to the from_bytes(_: &[u8])
function is _
, which makes it look like the argument is not supposed to be used (and compiler will ignore error if it's not used). I think it should be named.
I think it should be something like this instead?
pub trait FromBytes {
type Error;
fn from_bytes(bytes: &[u8]) -> Result<Self, Self::Error>;
}
The imporant difference above is the OK-type in the return Self
instead of &Self
If I'm missing something and there's actually some way to make this work in it's current form, may I suggest posting an example for the docs? I've been searching online, but I've found no concrete examples of code implementing the FromBytes
trait.