Skip to main content

encode_compact

Function encode_compact 

Source
pub fn encode_compact(value: &LinoValue) -> String
Expand description

Encode a value to the compact, single-line Links Notation format.

Every string is base64-encoded and the whole document is written on one line. decode reads this form as well, so stored files remain readable by the library after switching to the default readable output.

§Arguments

  • value - The value to encode

§Returns

A string in compact Links Notation format

§Example

use lino_objects_codec::{encode_compact, decode, LinoValue};

let data = LinoValue::object([("name", LinoValue::String("Alice".to_string()))]);
let encoded = encode_compact(&data);
// String "Alice" is base64-encoded as "QWxpY2U="
assert!(encoded.contains("QWxpY2U="));
assert_eq!(decode(&encoded).unwrap(), data);