Skip to main content

encode

Function encode 

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

Encode a value to the readable, indented Links Notation format.

This is a convenience function that uses a thread-local codec instance.

§Arguments

  • value - The value to encode

§Returns

A string in readable Links Notation format

§Example

use lino_objects_codec::{encode, LinoValue};

let data = LinoValue::object([
    ("name", LinoValue::String("Alice".to_string())),
    ("age", LinoValue::Int(30)),
]);
let encoded = encode(&data);
// Names and values are written as they are, one per line
assert_eq!(encoded, "(\n  name \"Alice\"\n  age 30\n)");