fluvio-protocol 0.50.1

Fluvio streaming protocol
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use std::io::Cursor;

use fluvio_protocol::{Decoder, Encoder};

#[test]
fn test_encode_str() {
    let value = "hello";
    assert_eq!(value.write_size(0), 7); // 7 bytes for the string "hello"
    let mut dest = Vec::new();
    value.encode(&mut dest, 0).expect("Failed to encode string");

    // decode the string back to its original form
    let mut buf = Cursor::new(dest);
    let decoded = String::decode_from(&mut buf, 0).expect("Failed to decode string");
    assert_eq!(decoded, "hello");
}