pub fn encode_string(
str: &str,
including_table: bool,
) -> (Box<dyn SymbolTable>, Vec<u8>)
Expand description
encode a single string if including_table is true, it will encode the symbol table to bytes and add it the encoding bytes header, i.e., | symbol table bytes | string encoding bytes |
ยงExample
use fsst_rust::core::codec::Decoder;
use fsst_rust::encode_string;
let str = "hello world".to_string();
let (_, encoding) = encode_string(&str, true);
let (table_end_pos, decoder) = Decoder::from_table_bytes(&encoding);
let decode_str = decoder.decode(&encoding[table_end_pos..].to_vec());
assert_eq!(str, decode_str);