Skip to content

Commit ca27e25

Browse files
committed
feat: add support for sending a binary message
refs kayleg#26
1 parent 5814f27 commit ca27e25

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/message.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,14 @@ impl EncodedMessage {
2828

2929
pub fn new<T: serde::Serialize>(data: &T, attributes: Option<HashMap<String, String>>) -> Self {
3030
let json = serde_json::to_string(data).unwrap();
31-
let data = base64::encode(&json);
31+
Self::new_binary(&json, attributes)
32+
}
33+
34+
pub fn new_binary<T: AsRef<[u8]>>(
35+
incoming: &T,
36+
attributes: Option<HashMap<String, String>>,
37+
) -> Self {
38+
let data = base64::encode(&incoming);
3239
EncodedMessage { data, attributes }
3340
}
3441
}

0 commit comments

Comments
 (0)