-
Notifications
You must be signed in to change notification settings - Fork 119
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
Producer::send can't send Vec<u8> or [u8] #60
Comments
I'm totally fine adding Long term, I don't feel like I've fully thought through the implications of the Alternatively, we could change |
I fiddled around with it earlier today when I originally came across this problem and made I think there could be a third solution, maybe
then,
I haven't actually tried this though, but something to think about. It could even be something like:
Then bound |
Unfortunately
This works if you impl #[derive(Debug, Clone, Serialize)]
pub struct Foo {
pub a: String,
pub b: u64,
}
impl SerializeMessage for &Foo {
fn serialize_message(input: &Foo) -> Result<producer::Message, Error> {
let payload = serde_json::to_vec(input).map_err(..)?;
Ok(producer::Message { payload, ..producer::Message::default() })
}
} then you should be able to still call |
Fixed in #61 (at least until we make |
As far as I can tell, it's not possible to send binary data to a
Producer
.send
requires:There is a SerializeMessage impl for
[u8]
, but none forVec<u8>
.If you try to send a
[u8]
, rustc will complain that the value is potentially unsized:If you try to send a
Vec<u8>
or&Vec<u8>
, it won't work because there is no SerializeMessage impl for it.fix: Adding a bound like
T: SerializeMessage + ?Sized
is a quick fix to get[u8]
data working.Vec<u8>
should probably also be implemented. In the long run, it may be worth looking at the interplay betweenmessage: &T
andserialize_message(input: &Self)
.Depending on what you're looking for, I can make one of these changes.
The text was updated successfully, but these errors were encountered: